[MWForum]Re: a very simple polygon procedure

Steve Robson mwforum@lists.mathcats.com
Mon, 16 Feb 2004 11:32:40 +0000


<html><div style='background-color:'><DIV class=RTE>
<P>This is very, very simple but draws what you ask it to.</P><FONT face="Courier New">
<P><FONT size=2><STRONG>to poly :sides<BR>repeat :sides[fd 100 rt 360 / :sides]<BR>end</STRONG></FONT></P>
<P><FONT face="Geneva, Arial, Sans-serif" size=2>Then call poly 4 (or whatever)</FONT></FONT><BR><FONT size=2>Cheers</FONT></P>
<P>Steve<BR></P></DIV>
<DIV></DIV>From: Pavel Boytchev <PAVEL@ELICA.NET>
<DIV></DIV>Reply-To: mwforum@lists.mathcats.com 
<DIV></DIV>To: mwforum@lists.mathcats.com 
<DIV></DIV>Subject: Re: [MWForum](no subject) 
<DIV></DIV>Date: Mon, 16 Feb 2004 03:15:00 +0200 
<DIV></DIV>
<DIV></DIV>&gt; &gt;In probing why the number of sides relates to the angles 
<DIV></DIV>&gt; &gt;(having to add up to 360) what angles are refered to? I am 
<DIV></DIV>&gt; &gt;wanting to know why this is so. 
<DIV></DIV>
<DIV></DIV>If you draw a polygon with N sides, the turtle should definitely turn N 
<DIV></DIV>times. Because angles (orientation, turtle's heading) do not change 
<DIV></DIV>during FORWARD movement, the final orientation will be the same as if 
<DIV></DIV>the turtle only turns around (and does not move forward). So, if the 
<DIV></DIV>turtle stays on one place and makes N turns to the left, and if the 
<DIV></DIV>final orientation is the same as the initial one, then all turn angles 
<DIV></DIV>should have a sum = 360. If the angles are the same, then each of them 
<DIV></DIV>should be 360/N. Thus, the following code: 
<DIV></DIV>
<DIV></DIV>repeat :N [ fd 10 lt 360/:N] 
<DIV></DIV>
<DIV></DIV>will draw a square when N=4, and a pentagon when N=5, and the bigger the 
<DIV></DIV>N is, the more circle-like the polygon is. 
<DIV></DIV>
<DIV></DIV>This is a simplification of a more general phenomena. 
<DIV></DIV>
<DIV></DIV>[1] The overall turn angle is not necessarily equal to 360 degrees. It 
<DIV></DIV>can also be 360*K where K is integer number (0, 360, -360, 720, 
<DIV></DIV>-720,...) So if the overall turn angle is 360 degrees, this is just the 
<DIV></DIV>case when K=1 
<DIV></DIV>
<DIV></DIV>[2] If you have both left and right turns, you must convert all of them 
<DIV></DIV>into only left, or into only right (by using that LT :A = RT 0-:A). When 
<DIV></DIV>you calculate the total sum of angles (positive and negative angles), 
<DIV></DIV>the result must be 360*K if the final orientation is the same as the 
<DIV></DIV>initial one. 
<DIV></DIV>
<DIV></DIV>Pavel 
<DIV></DIV>
<DIV></DIV>_______________________________________________ 
<DIV></DIV>MWForum mailing list 
<DIV></DIV>MWForum@lists.mathcats.com 
<DIV></DIV>http://lists.mathcats.com/mailman/listinfo/mwforum 
<DIV></DIV>Attachments archived at: 
<DIV></DIV>http://www.mathcats.com/mwforum/attachments.html 
<DIV></DIV>To unsubscribe or for administrative questions contact 
<DIV></DIV>mailto:mwforum-admin@lists.mathcats.com 
<DIV></DIV></div><br clear=all><hr>Find out more about the new range of Premium Web services from MSN.  <a href="http://g.msn.com/8HMAENUK/2749??PS=">Click here for more information.</a> </html>