[Thread Prev] [Thread Next]
|
Subject: |
Re: a very simple polygon procedure |
|
From: |
mwforum@xxxxxxxxxxxxxxxxxx (Steve Robson) |
|
Date: |
Mon, 16 Feb 2004 11:32:40 +0000 |
This is very, very simple but draws what you ask it to.
to poly :sides repeat :sides[fd 100 rt 360 /
:sides] end
Then call poly 4 (or
whatever) Cheers
Steve
From: Pavel Boytchev
Reply-To: mwforum@xxxxxxxxxxxxxxxxxx
To: mwforum@xxxxxxxxxxxxxxxxxx
Subject: Re: [MWForum](no subject)
Date: Mon, 16 Feb 2004 03:15:00 +0200
> >In probing why the number of sides relates to the angles
> >(having to add up to 360) what angles are refered to? I am
> >wanting to know why this is so.
If you draw a polygon with N sides, the turtle should definitely
turn N
times. Because angles (orientation, turtle's heading) do not change
during FORWARD movement, the final orientation will be the same as
if
the turtle only turns around (and does not move forward). So, if
the
turtle stays on one place and makes N turns to the left, and if the
final orientation is the same as the initial one, then all turn
angles
should have a sum = 360. If the angles are the same, then each of
them
should be 360/N. Thus, the following code:
repeat :N [ fd 10 lt 360/:N]
will draw a square when N=4, and a pentagon when N=5, and the
bigger the
N is, the more circle-like the polygon is.
This is a simplification of a more general phenomena.
[1] The overall turn angle is not necessarily equal to 360 degrees.
It
can also be 360*K where K is integer number (0, 360, -360, 720,
-720,...) So if the overall turn angle is 360 degrees, this is just
the
case when K=1
[2] If you have both left and right turns, you must convert all of
them
into only left, or into only right (by using that LT :A = RT 0-:A).
When
you calculate the total sum of angles (positive and negative
angles),
the result must be 360*K if the final orientation is the same as
the
initial one.
Pavel
_______________________________________________
MWForum mailing list
MWForum@xxxxxxxxxxxxxxxxxx
http://mia.openworldlearning.org/mwforum/
Attachments archived at:
http://www.mathcats.com/mwforum/attachments.html
To unsubscribe or for administrative questions contact
mailto:mwforum-admin@xxxxxxxxxxxxxxxxxx
Find out more about the new range of
Premium Web services from MSN. Click here for more
information.
Previous by thread:
please remove me from the mailing list
Next by thread:
transition form page to page
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|