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

Re: LOGO-L> ellipse



At 21:43 13.2.1998 +1100, Richard Impey wrote:
>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
>What am I doing wrong?

Richard,

When re-writing a Logo program from one version of Logo to another, you
have to be aware of the fact that there is no 'standard' Logo.
Unfortunatelly both ellipse procedures were programmed for MSWLogo,
therefore they use some functions and procedures which are not known to
MicroWorlds, even if those procedures are common in many other Logo
implementations (In George's solution it is repcount and setxy). Also
MicroWorlds, unlike many other Logo implementations requires to separate
each operator from its operands with at least one space (both George's and
Jeff's solutions did not keep to this rule).
Though, I normally use Comenius Logo or SuperLogo where the above mentioned
problems do not occur, I tried to modify the ellipse procedures using the
demo version of MicroWorlds 2 for Windows 95 as a kind of excercise:

; George's procedure:

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
make "ang 0                          ; begin with angle = 0
repeat 361                           ; Sweep through 0 - 360 ~
   [
   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
   setpos se :x :y                       ; Draw a line segment
   make "ang :ang + 1                ; Increment the angle
   ]
pu                                   ; Pen up for the trip back to the
                                     ; center of the ellipse
setpos se :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

; Jeff's procedure
; (as the first trial do not try ellipse 20 40 (the result is nice, but
does not look like an ellipse)
; try: 
; pd ellipse 1 2 

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

Peter Tomcsanyi

My favourite Logo:
http://logo.die.fmph.uniba.sk/logo/
http://www.logo.com/catalogue/titles/superlogo/index.html
---------------------------------------------------------------
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