Hello everybody!
First of all--many thanks to those, who have made the archive look so
great. I would like very much to contribute a GIF there compatible with
those of Ray Catzel and Yehuda, but it will take some time, may be the
hole life. :-)
Instead, I'm sending just a code for ants chasing each other in 3d
space. Hope, you'll enjoy it as much as I do.
The changing in position of -1 turtle leads to quite different pictures.
I offer to make changes using SELECTBOX. It would be better to give a
name to the turtle position, not pointing the coordinates ("high above
the cube", for example), but I'm not sure how it should sound in
English.
--- Chasing Ants in 3D -----------
to ants_3d.main
cs
perspective
setturtle -1
localmake "choice selectbox[Choose position for turtle # -1]~
[[20 1000 50]
[300 500 500]
[-200 -100 800] ]
if :choice=1 [setposxyz [20 1000 50]]
if :choice=2 [setposxyz [300 500 500]]
if :choice=3 [setposxyz [-200 -100 800]]
if :choice=0 [stop]
ants_set
; initial positions of four ants
ants_cube
; a drawing of a cube, on the tops of which
; the ants are placed
ants_move
; recursive procedure imitating the ants' movement
; towards each other
end
to ants_cube
setturtle 0 setpc [255 0 0]
repeat 4[repeat 4[fd 200 rt 90] fd 200 downpitch 90]
setpc [0 0 0]
end
to ants_move
if dist_0_3 < 4 [stop]
for [i 0 3][localmake "num remainder :i+1 4 setturtle :num
localmake "place posxyz
setturtle :i
setorientation towardsxyz :place fd 2]
ants_move
end
to ants_set
setturtle 0
pu setxyz -100 0 100 pd label "0
setturtle 1
pu setxyz 100 200 100 pd label "1
setturtle 2
pu setxyz 100 0 -100 pd label "2
setturtle 3
pu setxyz -100 200 -100 pd label "3
end
to dist_0_3
;estimates the distance between two turtles (#0 and #3)
setturtle 3
localmake "pos1 posxyz
setturtle 0
localmake "dx2 (xcor-first :pos1)*(xcor-first :pos1)
localmake "dy2 (ycor-first bf :pos1)*(ycor-first bf :pos1)
localmake "dz2 (zcor-last :pos1)*(zcor-last :pos1)
op sqrt :dx2+:dy2+:dz2
end
--------------------------
All the best,
Olga
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
---------------------------------------------------------------
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