Hi. Here's the orange peel again in 3d. I haven't had time to work on the lighting etc., but it's pretty much right. There's also a glitch at one end of the spiral (very clear from the view shown here) and I don't know what's causing it, as the wireframe looks ok. I was very lucky the way the red and orange shells separate into an inside and outside so well. I had a few problems with this one as it uses the towardsxyz command a lot, and I don't really understand what controls the roll of the turtle around the vector after this command has been used. This means I don't know what state the turtle is left in. For instance, after a turtle at [0 0 0] does towardsxyz [100 100 100], the turtle is pointing along the line [0 0 0]-[100 100 100], but which way do its "wings" point? A useful library procedure (for me, at least) would be copyturtle :n, which would set the current turtle in the same position and orientation as turtle :n. Can anyone supply suitable code? Thanks. Tom Lynn
to aaa
cs
setsc [0 0 0]
perspective
setlight [0 0.2] ask -3 [pu setposxyz [100 100 100]]
rt 150 ; Change this to change orientation of peel
setpc [255 160 40]
orangepeel 200 15
; Uncomment the rt 180 in the next line to turn it into a ball.
setpc 4 ;rt 180
orangepeel 200 15
wait 100
polyview
repeat 72 [ask -1 [fd 200 down 5]]
end
to moveto :pxyz
setorientation towardsxyz :pxyz
fd distancexyz :pxyz
end
to orangepeel :radius :strips
; Tracks a spiralling path down around a sphere.
localmake "v 0
localmake "r 0
localmake "hanglestep 7.5
localmake "vanglestep :hanglestep/:strips
localmake "stripheight 360*:vanglestep/:hanglestep
localmake "oldlowerpos [0 0 0]
localmake "oldnextpos [0 0 0]
setturtle 0
localmake "startpos posxyz
pu fd 10
localmake "startposmoved posxyz
bk 10
setturtle 1
pu
setposxyz :startpos
setorientation towardsxyz :startposmoved
until [and not (:v < 180) not (:r < 350)] [
setturtle 1
pu
rt :r
ifelse :v < 180 [up (:v - 90)][up 90]
fd :radius
localmake "nextpos posxyz
if (:v < 180 + :stripheight/2) [
bk :radius
ifelse :v > :stripheight/2
[ifelse :v < 180 [down :stripheight/2][down :stripheight/2-:v+180]]
[down :v]
fd :radius
localmake "lowerpos posxyz
ask 2 [
pu setposxyz :lowerpos
pd polystart
setposxyz :nextpos
ifelse :oldnextpos = [0 0 0] [setposxyz :nextpos][setposxyz :oldnextpos]
ifelse :oldlowerpos = [0 0 0] [setposxyz :nextpos][setposxyz :oldlowerpos]
setposxyz :lowerpos
polyend
make "oldnextpos :nextpos
make "oldlowerpos :lowerpos
]
bk :radius
ifelse :v > :stripheight/2
[ifelse :v < 180 [up :stripheight/2][up :stripheight/2-:v+180]]
[up :v]
fd :radius
]
bk :radius
ifelse :v < 180 [down (:v - 90)][down 90]
lt :r
setturtle 0
pu ; ifelse posxyz = [0 0 0][pu][pd] ; Draw main track
setposxyz :nextpos
localmake "r :r + :hanglestep
if :r > 360 [localmake "r :r - 360]
localmake "v :v + :vanglestep
]
; Reset turtle 0 to original state (though it may have rolled a bit...)
setturtle 0
pu
setposxyz :startpos
setorientation towardsxyz :startposmoved
end
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: filledpeel.gif
Date: 26 Jul 1998, 22:34
Size: 15883 bytes.
Type: GIF-image
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