|
|
The basic equation called slope-intercept form is y=mx+b, where m is the slope
( y2-y1/x2-x1 )
Using this equation might turn out to be a bit more complicated than it needs
to be.
You can build this procedurally like this :
#declare p1 = <2,0,0>
#declare p2 = vrotate (p1,<0,72,0>)
#declare p3 = vrotate (p2,<0,72,0>)
#declare p4 = vrotate (p3,<0,72,0>)
#declare p5 = vrotate (p4,<0,72,0>)
This gives you the points of the polygon on the x-z plane. The length of the
sides will obviously not be 2 units long. This gives you a polygon that is
inscribed in a circle 2 units long. You can add #render commands to get the
actual coordinates such as
#render concat("p2.x :",str(p2.x,3,3),"\n")
#render concat("p2.y :",str(p2.y,3,3),"\n")
#render concat("p2.z :",str(p2.z,3,3),"\n")
If you want the sides to be 2 units long, then you need to find the
x-coordinate of point p1.
Well, the polygon can be broken down into 5 isosceles triangles, one angle
beign 72 degrees, the other two angles are 54 degrees. Now we can take any of
these triangles and create right triangles. Lets label the corners A,B, and C,
where angle A is 36, angle B is 54, and angle C is 90. We know that line BC is
1 unit long. The length of line AB is what we need to find. Using the sine
function, we know that : Sin(36) = 1/AB : AB = 1/sin(36) = 1.701301617.
so replacing the above with #declare p1 = <1.701301617,0,0> to get a side
length of 2 units.
Hope this solves the problem.
Josh English
eng### [at] spiritonecom
www.spiritone.com/~english
Duane Tackett wrote:
> Now that I have your attention (with the subject line) I have forgotten
> how to do something seemingly very basic: I nee to translate a line segment
> into x,y coordinates. What I need is a 5 sided regular polygon (pentagon in
> english) and I have forgotten the equation to convert this to x,y points.
> For instance, I want to have a 5 sided object with sides that are 2
> units in length. I have figured out that the degree of the angle between
> each side is 72 (360 degrees divided by 5 sides) but I can't remember the
> equation to translate this. I don't want the points, I want an explanation
> so I'll have one less silly question to ask. Let me know if you can help.
>
> --
> Duane
>
> Check out my web page. I just started, so don't laugh too hard.
> www.geocities.com/siliconvalley/lab/8407
> e-mail me: ddt### [at] junocom
Post a reply to this message
|
|