[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOGO-L> ellipse



At 9:43 PM +1100 2/13/98, Richard Impey wrote:
>>Date: Fri, 13 Feb 1998 21:40:57 +1100
>>To:George Mills <mills@softronix.com>
>>From:rimpey@netspace.net.au (Richard Impey)
>>Subject:Re: LOGO-L> ellipse
>>Cc:logo-l@gsn.org	jeffr@mugc.cc.monash.edu.au
>>
>>Unfortunately I couldn't get either George's or Jeff's  ellipses working
>>with MicroWorlds v2 for the Mac.
>>I tried different combinations of values for 'rad_x' and 'rad_y' but had
>>the same error messages.
>>
>>George's.....
>>
>>In the command centre I entered.........
>>
>>                        ellipse1 40 40
>>
>>and the error message was.......
>>
>>                        I don't know how to repcount- in ellipse1
>>
>>Jeff's.......
>>
>>In the command centre I entered.........
>>
>>                        ellipse 20 40
>>
>>and the error message was.......
>>
>>                        size*:eccentricity has no value in ellipse
>>
>>
>>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>>Georges procedure follows.....
>>
>>to ellipse :rad_x :rad_y
>>>;
>>>; There are several methods to describing an ellipse,
>>>; this is just one of them and I prefer it because
>>>; it's easy to conceptualize its size and calculate
>>>; points that are exactly tangent.
>>>;
>>>; However, this is probably not the best method for
>>>; describing elliptical trajectories.
>>>;
>>>make "orig_x first pos               ; Save current turtle pos x
>>>make "orig_y last  pos               ; Save current turtle pos y
>>>pu                                   ; Get to first point on ellipse
>>>                                     ;   without drawing
>>>repeat 361                           ; Sweep through 0 - 360 ~
>>>   [
>>>   make "ang repcount-1              ; For clarity create an
>>>intermediate
>>>                                     ;   variable
>>>   make "x :orig_x-(sin :ang)*:rad_x ; Calculate New X coord
>>>   make "y :orig_y-(cos :ang)*:rad_y ; Calculate New Y coord
>>>   if :ang = 1 [pd]                  ; If we are already on the ellipse
>>>                                     ;   then put the pen down
>>>   setxy :x :y                       ; Draw a line segment
>>>   ]
>>>pu                                   ; Pen up for the trip back to the
>>>                                     ; center of the ellipse
>>>setxy :orig_x :orig_y                ; Restore original pos
>>>; I'll leave it as an excercise to allow the ellipse to be rotated
>>>; according to the turtles heading as MSWLogo's ellipse does
>>>end
>>>
>>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>>Jeff's procedure is as follows...
>>
>>to ellipse :size :eccentricity
>>make "n 0
>>repeat 360
>>[rt :n fd :size lt :n lt :n fd :size*:eccentricity rt :n make "n :n+1]
>>end
>>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>>
>>What am I doing wrong?
>>
>>Cheers Richard

Here's a translation into MicroWorlds Logo:

to ellipse :rad_x :rad_y
make "orig_x first pos
make "orig_y last  pos
make "ang 361
pu
repeat 361
   [  make "ang  :ang - 1
   make "x :orig_x - (sin :ang) * :rad_x
   make "y :orig_y - (cos :ang) * :rad_y
   if not :ang = 360 [pd]
   setpos list :x :y ]
pu setpos list :orig_x :orig_y
end

The differences are:

1. infix arithmetic reporters need spaces around them.   If you type :n+1
MicroWorlds thinks you want the thing that has the three character name
n+1, not the thing that has the name n plus 1.

2. Instead of SETXY there's SETPOS, which takes a list as input.  SETXY 40
50 becomes SETPOS {40 50} and SETXY :XVAL :YVAL becomes SETXY LIST :XVAL
:YVAL.

3.  There's no REPCOUNT in MicroWorlds, although in this case I don't see
the point of using it.  My fix would work in MSWLogo as well.

>>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>>Jeff's procedure is as follows...
>>
>>to ellipse :size :eccentricity
>>make "n 0
>>repeat 360
>>[rt :n fd :size lt :n lt :n fd :size*:eccentricity rt :n make "n :n+1]
>>end
>>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>

Jeff's works, but as you wrote it there weren't spaces around the infix
arithmetic reporters.  It should be

to ellipse :size :eccentricity
make "n 0
repeat 360
[rt :n fd :size lt :n lt :n fd :size * :eccentricity rt :n make "n :n + 1]
end

Also, put the pen down with PD before running it.  Try ELLIPSE 1 .5

...hope this helps.

-Michael


--------------------------------------------------------
Michael Tempel                    tel: 212 579 8028
Logo Foundation                   fax: 212 579 8013
250 West 85th Street              michaelt@media.mit.edu
New York  NY 10024
http://el.www.media.mit.edu/logo-foundation/


---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home