POV-Ray : Newsgroups : povray.general : Dumb, Stupid, Ignorant geometry question. Server Time
13 Aug 2024 15:24:00 EDT (-0400)
  Dumb, Stupid, Ignorant geometry question. (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Duane Tackett
Subject: Dumb, Stupid, Ignorant geometry question.
Date: 2 Sep 1998 06:37:01
Message: <35ed11bd.0@news.povray.org>
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

From: Stephen Lavedas
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 2 Sep 1998 11:50:45
Message: <35ED5B8A.A6B5664E@Ragingbull.com>
Let's see.  First off it's 72 degrees for the external angle, the
internal is obtuse, 108 degrees.  BUT, that's besides the point.  The
math you want is in the loop below...

#declare Side = 1;
#declare Angle = 0;
#declare Length = 2;
#declare X = 0
#declare Y = 0
#while (Side <= 5)
       cylinder {
                <X, Y, 0>
                <X + Length * cos(Angle), Y + Length * sin(Angle), 0>,
0.1                 
                pigment {color rgb <1,0,0>}
       }
       #declare Side = Side + 1;
       #declare X = X + Length * cos(Angle);
       #declare Y = Y + Length * sin(Angle);
       #declare Angle = Angle + 72 * 3.14159/180;
#end

though I can't help but think there must be an easier way to do this by
simply using the rotation command from POVRay, here we basically cut out
that middle man (do this with small enough objects and enough iterations
(correcting the angle of course) and you'll get a circle...

Steve


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

From: Nieminen Mika
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 2 Sep 1998 12:03:26
Message: <35ed5e3e.0@news.povray.org>
Duane Tackett <ddt### [at] junocom> 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.

#declare Point1=<1,0,0>;
#declare Point2=<cos(2*pi/5),sin(2*pi/5),0>;
#declare Point3=<cos(2*pi*2/5),sin(2*pi*2/5),0>;
#declare Point4=<cos(2*pi*3/5),sin(2*pi*3/5),0>;
#declare Point5=<cos(2*pi*4/5),sin(2*pi*4/5),0>;

-- 
                                                           - Warp. -


Post a reply to this message

From: Ron Parker
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 2 Sep 1998 12:05:34
Message: <35ed5ebe.0@news.povray.org>
On Wed, 2 Sep 1998 05:37:18 -0400, Duane Tackett <ddt### [at] junocom> 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.

First, it will help to have the radius of the polygon rather than the length
of the side.  For a polygon of n sides with side s, the radius is

r=(0.5*s)/sin(pi/n)

(assuming your sine function takes its arguments in radians.  If it uses
degrees, use 180 instead of pi.)  To explain this to yourself, consider the 
isosceles triangle formed by two radii, plus the side between them.  If you
draw a line perpendicular to the side, through the center of the triangle, 
you have two right triangles with a hypotenuse of length r and one side of 
length s/2.  That side is opposite an angle of half the angle you calculated,
or 180 divided by the number of sides.  The sine is the opposite divided by 
the hypotenuse, or (s/2)/r, so r is the opposite divided by the sine.

Now, for points i numbered 0 to n-1 (for a pentagon, i is 0, 1, 2, 3, or 4)
you have:

x(i) = r*cos(2*pi*i/n)
y(i) = r*sin(2*pi*i/n)

Again, assuming you use radians.  If you use degrees, substitute 180 for pi.
To justify these formulae to yourself, consider the case where i=1.  Then
you have x(1)=r*cos(2*pi/n) and y(1)=r*sin(2*pi/n).  2*pi/n is the angle 
between two points.  In the case of a pentagon, it's 72 degrees.  If you draw
the radius through point 1 (the first point counterclockwise from the point
that lies on the x axis) and then draw the x and y components of the radius,
you'll find that you have a right triangle.  One of the angles in the right
triangle is the central angle with measure 2*pi/n.  The hypotenuse is r.  
Now you see that the vertical line, whose length is equal to y, is opposite 
the angle of measure 2*pi/n, and the horizontal line, whose length is equal
to x, is adjacent.  So knowing that the sine is the opposite over the
hypotenuse, you have that the opposite, or y, is the sine times the 
hypotenuse.  Similarly, since cosine is adjacent over hypotenuse, x is the
cosine times the hypotenuse.

Now that you understand the math that makes this all work, consider an 
alternative in POV that can save you from having to understand at least 
part of it.  This code generates the points in the XZ plane, as with a torus,
but could easily be modified to put them in the XY plane instead.

#declare Sides=5;
#declare Length=2;
#declare Radius=(0.5*Length)/sin(pi/Sides);

#declare i=0;
#while (i < Sides) 
  #declare Point=vrotate( Radius * x, 360/Sides*i*y );
  /* Do whatever you want with Point here.  Maybe put it an an array. */
  #declare i=i+1;
#end


Post a reply to this message

From: Josh English
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 2 Sep 1998 12:10:48
Message: <35ED6E38.6C8E98DB@spiritone.com>
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

From: JK
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 3 Sep 1998 14:41:48
Message: <35EED3B2.C58483A4@hotmail.com>
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
>

  I personally think it would be much easier if you declare a first point (not
on x=0 or z=0) and then rotate it 72 degrees around the y-axis (for a flat
topped polygon) four times. If you really need the sides to be 2 use this
mathformula:
(s = side r = radius)
s = 2*tan(72/2)*r
that is: r = s/(2*tan(72/2)
That's all.

Good luck.
I hope this _short_ version of math stuff helps.

JK
--
http://surf.to/jkhome


Post a reply to this message

From: Ron Parker
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 3 Sep 1998 16:08:59
Message: <35eee94b.0@news.povray.org>
On Thu, 03 Sep 1998 19:36:50 +0200, JK <kla### [at] hotmailcom> wrote:
>s = 2*tan(72/2)*r
>that is: r = s/(2*tan(72/2)

This is the radius of the _inscribed_ circle.  It's not much help in 
finding the vertex points.


Post a reply to this message

From: JK
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 4 Sep 1998 20:25:54
Message: <35F07703.7FABF1D@hotmail.com>
Ron Parker wrote:

> On Thu, 03 Sep 1998 19:36:50 +0200, JK <kla### [at] hotmailcom> wrote:
> >s = 2*tan(72/2)*r
> >that is: r = s/(2*tan(72/2)
>
> This is the radius of the _inscribed_ circle.  It's not much help in
> finding the vertex points.

  Maybe I need some more math lessons, but does it matter if I use the
inscribed circle? I believe the effect of using this radius in the
equations above is the same, but the equations needed for finding the
side length are different than when using the outscribed circle.

JK


Post a reply to this message

From: Ronald L  Parker
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 5 Sep 1998 21:00:22
Message: <35f1cfd2.157863799@news.povray.org>
On Sat, 05 Sep 1998 01:25:55 +0200, JK <kla### [at] hotmailcom> wrote:

>Ron Parker wrote:
>
>> On Thu, 03 Sep 1998 19:36:50 +0200, JK <kla### [at] hotmailcom> wrote:
>> >s = 2*tan(72/2)*r
>> >that is: r = s/(2*tan(72/2)
>>
>> This is the radius of the _inscribed_ circle.  It's not much help in
>> finding the vertex points.
>
>  Maybe I need some more math lessons, but does it matter if I use the
>inscribed circle? 

Yes.  If you put a point at this distance from the center and 
rotate it 72 degrees, you'll find that it isn't 2 units from
where it started.  However, if you put a 2-unit-long cylinder
at this distance from the center and rotate it 72 degrees, you'll
find that its endpoint matches up perfectly with another such 
cylinder that hasn't been rotated.  Two separate problems, two
separate solutions.


Post a reply to this message

From: Duane Tackett
Subject: Re: Dumb, Stupid, Ignorant geometry question.
Date: 8 Sep 1998 07:30:38
Message: <35f5074e.0@news.povray.org>
(Isn't it kinda loony to send a reply to yourself?  anyways...)

    Thanks to all of you for your help.  I now have the source completed and
I ma happy to announce that I have one last frustration left with this
object (which hopefully soon will be joined by even more frustrating
objects).
    What I have basically is a pentagonal pool surrounded on each side by 5
steps which all descend down to the water (think of it as a pentagon with
the center cut out...with the center cut out...with the center cut out (you
get the picture).  I used the Sin/Cos combinations with the 72 degree
suggestion (so as you can see, I took almost everybody's advice) and I made
a nested if/then to do it all.  (Whew, finally, the problem)  No matter what
I do I can't mathematically keep these sections from joining to each other,
so instead of having 5 sides with 5 steps each, it looks like one gigantic
step and I can't get them to show a crack for some grout.  I could use a
difference thingy, but I am beginning to reach a point where I would rather
do something the "hard" way and have it be precise than to do a difference
and have it approximated.  If you would like, I could post the source.  It's
only about 4k now, so it's not too large...  Let me know...
--
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

Duane Tackett wrote in message <35ed11bd.0@news.povray.org>...
>    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

Goto Latest 10 Messages Next 1 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.