movement and vectors
- anchor
- around
- autoorbit
- back bk
- barriers
- caught
- clearfrag
- direction
- distance
- divergence
- down dn
- drift
- dropanchor
- encroaching
- extrapolate
- face
- facingp
- fence
- fixate fix
- forward fd
- forwarddir
- heading hd
- home
- inside
- jump
- left lt
- leftarc larc
- leftmarc lmarc
- location
- lower lo
- move
- near
- nearme
- noautoorbit
- nostealth
- notether
- orbitdistance
- orbitdown odn
- orbitleft olt
- orbitright ort
- orbitup oup
- orbitvector
- orientation
- orientationorder
- origin
- originvectors
- pitch pt
- pos
- position
- pullin pui
- pullout puo
- raise ra
- randomvectors randvec
- right rt
- rightarc rarc
- rightmarc rmarc
- rightdir
- roll ro
- rollleft rl
- rollright rr
- setanchor
- setbarriers
- setbounds sbds
- setheading seth shd
- setorbitdistance
- setorientation
- setorientationorder
- setorigin
- setoriginvectors
- setpitch setp spi
- setpos spo
- setposition spn
- setroll setr sro
- setvectors
- setx
- setxy
- sety
- setz
- showme
- slideleft sl
- slideright sr
- spin
- stealth
- tether
- towards
- up
- updir
- unproject
- vectors
- xcor xpos
- ycor ypos
- zcor zpos
- zeroheading
- zeroorientation
- zeropitch
- zeroroll
- zoom
anchor
Takes: none
Returns: list
Returns the location of the current anchor. The anchor is the ‘pivot point’ of the orbit commands and pullin / pullout.
show anchor
around
Takes: position (list) | vector (list) | length (number) | radius (number)
Returns: turtles (list)
Returns a list of turtles within the cylinder created by the given parameters, in the direction indicated by the vector away from the position with the given length and radius. Useful for collision detection. See also inside, encroaching.
snappy:show without turtle around position forwarddir 200 20
[myrtle]
autoorbit
Takes: direction (word) | degrees (number) | time (60ths of a second)
Returns: Automatically orbits the current view turtle in the specified direction the specified number of degrees every specified 60ths of a second. noautoorbit turns it off. Subsequent autoorbits cancel previous ones.
autoorbit “left 2 5
autoorbit "up 0.5 10
back bk
Takes: turtlesteps (number)
Returns: none
Moves the current turtle back the specified number of turtle steps.
back 20
barriers
Takes: none
Returns: list
Lists the existing barriers. See setbarriers
show barriers
caught
Takes: none
Returns: number
Returns a value if the calling turtle passes a fence or wrap threshold. caught returns 1 if the turtle hits / passes the X1 threshold provided to wrap / fence, 2 if X2, 3 if Y1, 4 if Y2, 5 if Z1, 6 if Z2. clearcaught resets it to 0.
show caught
clearfrag
Takes: none
Returns: none
Clears the current list of frag points. See frag
clearfrag
direction
Takes: position (list)
Returns: vectors (list)
Returns a list of vectors that would point the calling turtle at the supplied list of co-ordinates.
show direction myrtle:position snappy:position
[[0 1 0] [0 0 1] [1 0 0]]
snappy:setvectors direction myrtle:position
distance
Takes: position (list) | position (list)
Returns: distance (number)
Returns the distance from the first given set of co-ordinates to the second given set of co-ordinates.
show distance myrtle:position snappy:position
show distance [0 0 0] [100 100 100]
divergence
Takes: [vector1 vector2] (list) | [vector3 vector4] (list)
Returns: degrees (number)
Divergence returns the degrees of difference (divergence) between vector1 and vector3 in a clockwise direction, that direction established using vector2 and vector4, which need to be the axis you would be pivoting on to measure that difference. So if you’re measuring the degrees of difference between two forward vectors in terms of left and right, the second vector needs to be the up vector. If you were measuring the difference in terms of up and down, you would give the right vector. Divergence is extremely useful for ball games.
show divergence {item 1 myrtle:vectors item 3 myrtle:vectors} {item 1 snappy:vectors item 3 myrtle:vectors}
90
down dn
Takes: degrees (number)
Returns: none
Tilts the calling turtle’s nose down by the given number of degrees. See up
down 45
drift
Takes: steps vector
Returns: Causes the selected turtle to ‘drift’ the specified number of steps in the direction specified by vector. You can use drift to simulate momentum or gravity, particularly in concert with workers. See forwarddir
drift 10 forwarddir
forward 10 make "forward forwarddir newworker [repeat 5 [drift 1 :forward]]
dropanchor
Takes: none
Returns: none
Sets the selected turtle’s orbit anchor point to its current position. See setanchor
repeat 10 [penup forward 60 dropanchor pullout 50 pendown repeat 36 [orbitleft 10]]
encroaching
Takes: position (list) | vectors (list) | [left right forward backward above below] (list)
Returns: turtles (list)
Returns a list of turtles encroaching within the ‘box’ specified by the third list input. This is a more sophisticated version of inside, which allows for a box of any orientation, based on the provided vectors. See around, inside
show encroaching position vectors [10 10 10 10 10]
extrapolate
Takes: position (list) | vector (list) | distance (number)
Returns: list
Returns a list of target co-ordinates based on the starting position, a vector and the distance in turtle-units along that vector.
show extrapolate position forwarddir 5
face
Takes: position (list of 3) | position (list of 3)
Returns: vector (list)
face takes two lists of co-ordinates (x, y and z) and then returns a list of vectors (list of three lists of three) which if applied to a turtle cause it to ‘face’ the second set of co-ordinates if positioned at the first set of co-ordinates.
setvectors face position [100 100 100]
facingp
Takes: boolean
Returns: co-ordinates (list) | degrees (number)
boolean
returns true if a vector from the calling turtle to the supplied co-ordinates diverges less than the supplied number of degrees from the calling turtle's forward vector. See divergence
reset
snappy:show facingp myrtle:position 10
true
myrtle:show facingp snappy:position 10
false
fence
Takes: none
Returns: none
Causes the calling turtle to halt if it reaches the screen boundaries set by setbounds. See setbounds, bounds, window, wrap, caught
fence
fixate fix
Takes: position
Returns: none
Both sets the anchor point and points the selected turtle at it. Compare with setanchor, which does not change the orientation of the selected turtle.
snappy:fixate myrtle:position
fixate [0 0 0]
points Snappy (the camera turtle) at Myrtle.
forward fd
Takes: turtle-spaces (number)
Returns: none
Moves the turtle forward the given number of turtle steps. Draws a line if the pen is down. See pendown, back
forward 20
forwarddir
Takes: none
Returns: vector (list)
Returns the calling turtle’s forward vector.
show forwarddir
heading hd
Takes: none
Returns: degrees
Returns the heading (x-axis) of the selected turtle in degrees. Heading is an accumulated, relative value that cannot be used in isolation to accurately reproduce an orientation when the turtle moves in three dimensions – for that, use orientation / setorientation. See pitch and roll
print heading
home
Takes: none
Returns: none
Returns the currently selected turtle to the home position.
home
inside
Takes: [[x1 y1 z1] [x2 y2 z2]]
Returns: list
Returns a list of turtles inside the area denoted by the provided sets of co-ordinates.
show inside [[-100 -100 -100] [100 100 100]
[myrtle]
jump
Takes: steps (number)
Returns: none
Moves the turtle forward the given number of turtle steps without drawing, regardless of the pen state.
jump 20
left lt
Takes: degrees
Returns: none
Turns the selected turtle to the left the specified number of degrees. See right
left 90
lt 45
leftarc larc
Takes: degrees or [degrees segments] | radius
Returns: none
Creates an arc forward and to the left from the turtle’s position, placing the turtle at its end. Arcs do not wrap across borders tidily in wrap mode. If the first parameter is specified as a list, the first value in the list is the degrees, the second is the number of segments in the arc to be created, which overrides the internal algorithm used to calculate the number of segments. See leftmarc, rightarc
leftarc 90 40
leftmarc lmarc
Takes: degrees | radius
Returns: none
Creates an arc forward and to the left from the turtle’s position using the mark primitive, placing the turtle at its end. See rightmarc.
leftmarc 90 40
location
Takes: co-ordinates (list)
Returns: list
Returns a list of isRight, isAbove, isAhead where a value of 1 indicates the target co-ordinates are in those areas relative to the turtle’s forward view, 0 indicates that the co-ordinates are on the same plane as the calling turtle as appropriate, and -1 indicates the co-ordinates are in the opposite region (eg a -1 for isRight indicates it is to the left of the turtle’s forward vector / view).
snappy:show location myrtle:position
[0 0 1]
myrtle:show location snappy:position
[0 1 0]
lower lo
Takes: turtle-units
Returns: none
‘Lowers’ the turtle (moves back along its up vector). Same as doing ‘down 90 forward turtle-units up 90’. For example, Myrtle in her home position when turtleSpaces is started will move away from the Snappy camera turtle if you lower her. See raise
lower 100
move
Takes: distance (turtle-units) | degrees OR [degrees degrees]
Returns: none
Moves the turtle in the specified direction the specified number of turtle-units without altering its orientation or vectors. If a list of two values is specified, moves both left-right (first value) and up-down (second value) in that order.
move 20 45
move 20 [45 45]
repeat 3600 [move repcount / 1000 repcount]
near
Takes: position (list) | radius (number)
Returns: list
Returns a list of all the turtles within the specified radius of turtle-units from the specified position. See nearme
show near [0 0 0] 10
nearme
Takes: distance (number)
Returns: turtles (list)
Returns a list of turtles within the specified distance of the calling turtle, except the calling turtle itself. See near, nearp
show nearme 200
noautoorbit
Takes: none
Returns: none
Turns off any existing autoorbit. See autoorbit.
noautoorbit
nostealth
Takes: none
Returns: none
Causes calling turtle to appear in lists generated by near. See stealth
nostealth
notether
Takes: none
Returns: none
Untethers the selected turtle from the orbit anchor point. When the turtle is untethered, the anchor point moves relative to it.
notether
orbitdistance
Takes: none
Returns: turtle-units (number)
Returns the distance between a turtle and its anchor point. See setanchor, dropanchor
show orbitdistance
orbitdown odn
Takes: degrees (number)
Returns: none
Orbits down from (beneath) the turtle around its anchor point the specified number of degrees. Note that the turtle goes to its destination directly regardless of the status of fluid, and if the pen is down a line will be drawn between the start and destination with no intermediary points. See setanchor, dropanchor
orbitdown 90
orbitleft olt
Takes: degrees (number)
Returns: none
Orbits the turtle left around its anchor point the specified number of degrees. Note that the turtle goes to its destination directly regardless of the status of fluid, and if the pen is down a line will be drawn between the start and destination with no intermediary points. See setanchor, dropanchor
orbitleft 90
orbitright ort
Takes: degrees (number)
Returns: none
Orbits the turtle right around its anchor point the specified number of degrees. Note that the turtle goes to its destination directly regardless of the status of fluid, and if the pen is down a line will be drawn between the start and destination with no intermediary points. See setanchor, dropanchor
orbitup oup
Takes: degrees (number)
Returns: none
Orbits up from (above) the turtle around its anchor point the specified number of degrees. Note that the turtle goes to its destination directly regardless of the status of fluid, and if the pen is down a line will be drawn between the start and destination with no intermediary points. See setanchor, dropanchor
orbitup 90
orbitvector
Takes: vector (list) | degrees (number)
Returns: none
Orbits the specified number of degrees around the turtle’s anchor point using the specified vector. To orbit in the opposite direction, specify a negative number of degrees. Note that the turtle goes to its destination directly regardless of the status of fluid, and if the pen is down a line will be drawn between the start and destination with no intermediary points. See setanchor, dropanchor
orbitvector updir 10
orientation
Takes: none
Returns: list
Returns the current orientation, in the order specified by orientationorder. So if orientation order is set to “phr, then the first value returned by orientation will be pitch, the second heading and the third roll. See orientationorder
show orientation
orientationorder
Takes: none
Returns: word
Returns the current order heading, pitch and roll are processed when setorientation, setheading, setpitch or setroll is used.
show orientationorder
"hpr
origin
Takes: none
Returns: list
Returns the current origin co-ordinates. See setorigin, home
show origin
[0 0 0]
originvectors
Takes: none
Returns: list
Returns the current origin vectors. See setoriginvectors, origin, home
show originvectors
pitch pt
Takes: none
Returns: pitch (number)
Returns the pitch (attitude) of the current turtle
print pitch
pos
Takes: none
Returns: [x y] (list)
Returns the x and y co-ordinates of the turtle. For all three dimensions, use position
show pos
position
Takes: none
Returns: [x y z] (list)
Returns the co-ordinates of the turtle. For just the first two dimensions, use pos
show position
pullin pui
Takes: turtle-spaces (number)
Returns: none
Pulls the calling turtle toward its anchor point the specified number of turtle-spaces. Stops if it reaches its anchor point.
pullin 40
pullout puo
Takes: turtle-spaces (number)
Returns: none
Pulls the calling turtle out away from its anchor point the specified number of turtle-spaces.
dropanchor repeat 20 [penup pullout 10 pendown repeat 36 [orbitleft 10]]
raise ra
Takes: turtle-units (number)
Returns: none
Raises (elevates) the currently selected turtle by the specified number of turtle-units. Draws a line if the pen is down. See lower
raise 20
randomvectors randvec
Takes: none
Returns: none
Orients the currently selected turtle randomly in three dimensions. This does NOT alter the current pitch, heading or roll values.
pendown repeat 10 [randomvectors fd 100 home]
right rt
Takes: degrees
Returns: none
Turns the selected turtle the specified number of degrees to the right. If the specified number of degrees is negative, turns it to the left. See left
right 90
rightarc rarc
Takes: degrees or [degrees segments] | radius
Returns: none
Creates an arc forward and to the right from the turtle’s position, placing the turtle at its end. Arcs do not wrap properly across borders in wrap mode. If a list is provided for the first parameter, the second item in the list specifies the number of segments to be used in the construction of the rarc. See leftarc, rightmarc.
rightarc 90 40
rightmarc rmarc
Takes: degrees | radius
Returns: none
Creates an arc forward and to the right from the turtle’s position using the mark primitive, placing the turtle at its end. See leftmarc.
rightmarc 90 40
rightdir
Takes: none
Returns: vector
Returns the right vector of the selected turtle.
show rightdir
roll ro
Takes: none
Returns: number
Returns the current roll value. See setroll
show roll
rollleft rl
Takes: degrees (number)
Returns: none
Rolls the currently selected turtle to the left by the provided number of degrees.
rollleft 90
rollright rr
Takes: degrees (number)
Returns: none
Rolls the currently selected turtle to the right by the provided number of degrees.
rollright 45
setanchor
Takes: position
Returns: none
Sets the selected turtle’s orbit anchor to the specified three-dimensional position. Compare with fixate.
setanchor [0 0 0]
setbarriers
Takes: [[[x1 y1 z1][x2 y2 z2]][[x3 y3 z3][x4 y4 z4]]…] (list of lists)
Returns: none
Sets barriers on the calling turtle. The calling turtle cannot venture into the defined area(s). See barriers
setbarriers [[[0 0 0][100 100 100]]]
setbounds sbds
Takes: x1 y1 x2 y2 (list) OR [[x1 y1 z1][x2 y2 z2]] (list of lists) OR radius
Returns: none
Sets the boundary used by wrap and fence. If a single value is provided, the boundary is the radius of a circle / sphere. If a negative single value is provided, the boundary is a hemisphere laid on Z — that is, the turtle cannot travel into negative Z values. If no Z values are provided, sets them to -1000 / 1000. See bounds, fence, wrap
setbounds [-100 -100 100 100]
setbounds [[-100 -100 -100][100 100 100]
setheading seth shd
Takes: degrees (number)
Returns: none
Sets the turtle’s heading (left-right) and updates its orientation appropriately. Be aware that while setheading will alter the value of heading for the purposes of orientation, setorientation may not restore the expected turtle orientation if setheading is used in isolation. If you intend to use setorientation to restore a turtle’s orientation, you should use setorientation to change aspects of a turtle’s orientation also. See orientation
setheading 90
setorbitdistance
Takes: turtle-units (number)
Returns: none
Sets the currently selected turtle’s distance from its anchor point.
setorbitdistance 100
setorientation
Takes: vectors (list)
Returns: none
First unwinds the current orientation in the reverse of orientationorder, then changes the calling turtle’s orientation in the order specified by orientationorder, so that if orientationorder is “PHR then the first orientation changed is pitch, then heading, then the roll. Due to the nature of 3D movements, setorientation can only be used to restore orientations that are the result of relatively simple transforms (that is, series of orientation changing commands such as rollright or down). To restore complex orientations, use both setorientation and setvectors. See setvectors
setorientation [0 90 0]
setorientationorder
Takes: order (word)
Returns: none
Sets the order in which heading, pitch and roll are processed after using setheading, setpitch or setroll. The required word is a three letter combination made up of h, for heading, p, for pitch, and r, for roll. See orientationorder
setorientationorder "hpr
setorientationorder "rhp
setorigin
Takes: [x y z] (list)
Returns: none
Sets the turtle’s origin, the location it goes when it goes home. See origin, home
setorigin [50 50 50]
setoriginvectors
Takes: vectors (list)
Returns: none
Sets the turtle’s origin vectors, the orientation the turtle ends up in when it goes home. See originvectors, vectors, home
setoriginvectors vectors
setpitch setp spi
Takes: degrees (number)
Returns: none
Sets the turtle’s pitch (up-down) and updates its orientation appropriately. Be aware that while setpitch will alter the value of pitch for the purposes of orientation, setorientation may not restore the expected turtle orientation if setpitch is used in isolation. If you intend to use setorientation to restore a turtle’s orientation, you should use setorientation to change aspects of a turtle’s orientation also. See orientation
setpitch 180
setpos spo
Takes: [x y] (list)
Returns: none
Sets the x and y co-ordinates of the calling turtle’s position. If the pen is down, a line is drawn between the turtle’s old position and new position. Does not affect z. Exists for compatibility with two-dimensional logos.
setpos [20 30]
setposition spn
Takes: [x y z] (list)
Returns: none
Sets the turtle’s co-ordinates. If the pen is down, a line is drawn between the turtle’s old position and its new position.
pendown repeat 100 [setposition {-200 + random 400 -200 + random 400 -200 + random 400}]
setroll setr sro
Takes: degrees (number)
Returns: none
Sets the turtle’s roll (rollleft-rollright) and updates its orientation appropriately. Be aware that while setroll will alter the value of roll for the purposes of orientation, setorientation may not restore the expected turtle orientation if setroll is used in isolation. If you intend to use setorientation to restore a turtle’s orientation, you should use setorientation to change aspects of a turtle’s orientation also. See orientation
setroll 90
setvectors
Takes: [[forwarddir] [updir] [rightdir]] (list of lists)
Returns: none
Sets the current turtle’s orientation using vectors.
setvectors [1 -1 0] [1 1 1] [0 0 0]
setx
Takes: number
Returns: none
Sets the turtle’s x position.
setx 100
setxy
Takes: x (number) | y (number)
Returns: none
Sets the turtle’s x and y co-ordinates. This is here for compatibility. As opposed to setpos, which takes the two co-ordinates as a list. See setpos
setxy 10 20
sety
Takes: number
Returns: none
Sets the turtle’s y position.
sety 20
setz
Takes: number
Returns: none
Sets the turtle’s z position.
setz 50
showme
Takes: turtle
Returns: none
Causes the calling turtle to position itself in the default view turtle position over the specified turtle. Usually called by the current view (camera) turtle.
showme "myrtle
slideleft sl
Takes: turtle-steps
Returns: none
‘Slides’ the turtle to the left the given number of turtle-steps.
slideleft 20
slideright sr
Takes: turtle-steps
Returns: none
‘Slides’ the turtle to the right the given number of turtle-steps.
slideright 30
spin
Takes: [vectors] (list) | degrees
Returns: Spins the turtle around the given vector by the given number of degrees in a clockwise direction from behind the vector such that SPIN FORWARDDIR 90 would be the same as ROLLRIGHT 90. Does not affect pitch, heading or roll.
spin forwarddir 90
stealth
Takes: none
Returns: none
Causes the calling turtle not to appear in lists returned by near. See nostealth
stealth
tether
Takes: none
Returns: none
Tethers the selected turtle to the orbit anchor point. If the turtle moves, the anchor point remains unchanged. See setanchor, notether
tether
towards
Takes: [x y] (list)
Returns: heading (number)
Returns a heading that would make the turtle face toward the provided co-ordinates. towards assumes the target co-ordinate is on the same Z plane as the turtle. towards is a legacy Apple Logo primitive that is useful in turtleSpaces for compatibility and two-dimensional applications. See heading
setheading towards [30 40]
up
Takes: degrees
Returns: none
Angles the ‘nose’ of the turtle up the specified number of degrees. If looking down at the turtle from above (the default view), up 90 will cause the turtle to point straight up towards you.
up 90
updir
Takes: none
Returns: vector (list)
Returns the calling turtle’s current up vector. See rightdir, forwarddir
show updir
unproject
Takes: position (list)
Returns: [x-percent y-percent (list)
Returns the 2D position of the object as a percentage of the window / screen. For example, if the turtle appears to be in the dead center of the screen, unproject will return 50% across and 50% down. Note: If the co-ordinate is not in the view of the camera, unproject will return spurious results!
unproject myrtle:position
vectors
Takes: none
Returns: [forwarddir updir rightdir]
Returns the orientation vectors of the turtle as a list. This is the most reliable method of storing and restoring the orientation of a turtle, as opposed to the orientation function, which returns relative heading / pitch / roll values.
print vectors
xcor xpos
Takes: none
Returns: xpos (number)
Returns the current x co-ordinate of the turtle.
show xpos
ycor ypos
Takes: none
Returns: ypos (number)
Returns the current y co-ordinate of the turtle.
show ypos
zcor zpos
Takes: none
Returns: zpos (number)
Returns the current z co-ordinate of the turtle.
show zpos
zeroheading
Takes: none
Returns: none
Zeroes the turtle’s heading value. This does not modify the turtle’s orientation. Further changes will modify heading as appropriate. This primitive allows you to establish a new base heading value to work forward from. See heading
zeroheading
zeroorientation
Takes: none
Returns: none
Zeroes the turtle’s orientation values (pitch, heading, roll). This does not modify the turtle’s actual orientation. Further changes will modify orientation values as appropriate. This primitive allows you to establish new base orientation values to work forward from. See orientation
zeroorientation
zeropitch
Takes: none
Returns: none
Zeroes the turtle’s pitch value. This does not modify the turtle’s orientation. Further changes will modify pitch as appropriate. This primitive allows you to establish a new base pitch value to work forward from. See pitch
zeropitch
zeroroll
Takes: none
Returns: none
Zeroes the turtle’s roll value. This does not modify the turtle’s orientation. Further changes will modify roll as appropriate. This primitive allows you to establish a new base roll value to work forward from. See roll
zeroroll
zoom
Takes: none
Returns: number
Returns the turtle’s ‘zoom’ value, which is relevant to its display when it is a view turtle. 100 (as in 100%) is the default value. See setzoom
show zoom