Logo guide/reference
This Logo guide/reference is adapted from Joshua Bell's Logo Interpreter. The Logo commands specific to VRMath2's 3D Logo are in purple color.
The section numbers are per the Berkeley Logo Reference Manual in Brian Harvey's Computer Science Logo Style volume 2: Advanced Techniques for ease of comparison.
-
Graphics
6.1. Turtle Motion
6.2. Turtle Motion Queries
6.3. Turtle Control
6.4. Turtle Queries
6.5. Pen and Background Control
6.6. Pen Queries
6.9. Primitive Objects
6.10. Material Settings
6.11. Scale Settings and Queries
6.12. Texture Settings
6.13. Font Settings
6.14. Object Settings and Manipulation
6.15. Animation
6.16. Behaviour
6.17. 3D Space and Navigation Control
1. Data Types
- "word
- Text string (terminated by whitespace)
- :variable
- Input definition/variable reference
- [ word ... ]
- List of words or lists, whitespace separated
- { word ... }
- { word ... }@origin
- Array of words whitespace separated
- ( expression )
- Parenthesis can be used to group expressions
- procedure input ...
- Call procedure with default number of inputs
- ( procedure input ... )
- Call procedure with an arbitrary number of inputs
2. Data Structure Primitives
2.1 Constructors
- word expr expr
- (word expr ...)
- Concatenate two (or more) words into one word.
- list thing1 thing2
- (list thing1 thing2 ...)
- Create a new list from the inputs
- array size
- (array size origin)
- Create a new array. The default origin is 1.
- listtoarray list
- (listtoarray list origin)
- Create a new array populated by members of a list
- arraytolist array
- Create a new list populated by members of a array
- sentence thing1 thing2
- (sentence thing1 thing2 ...)
- se thing1 thing2
- (se thing1 thing2 ...)
- Create a new list from the inputs (if non-lists) or members of the inputs (if lists)
- fput thing list
- lput thing list
- Outputs list, but with thing added as a new first/last item
- combine thing1 thing2
- If thing2 is a word, like word; otherwise, like fput
- reverse list
- Outputs a list with the items in reverse order
- gensym
- Outputs a unique string, e.g. G1, G2, etc.
2.2 Data Selectors
- first list
- last list
- Outputs the first or last item from the list, respectively
- butfirst list
- bf list
- butlast list
- bl list
- Outputs the list, except for the first/last item
- firsts listoflists
- Outputs a list of the first item of each sublist
- butfirsts listoflists
- bfs listoflists
- Outputs a list of sublists without the first item
- pick list
- Outputs one item from a list, at random
- item index thing
- Outputs the indexth item of the list or array
- setitem index array value
- Sets the indexth item of the array to value
- remove thing list
- Outputs the list with any occurences of thing removed
- remdup list
- Outputs the list with duplicates removed
2.3 Data Mutators
- push stackname thing
- pop stackname
- Push to/pop from a stack i.e. list variable, e.g. make "s [] then push "s 1. Stacks grow from the front.
- queue stackname thing
- dequeue stackname
- Add/remove from a queue i.e. list variable, e.g. make "q [] then queue "q 1. Queues grow from the end
2.4 Predicates
Predicates return 1 (true) or 0 (false)
- wordp thing
- word? thing
- listp thing
- list? thing
- arrayp thing
- array? thing
- numberp thing
- number? thing
- Test if thing is a word, list, array, or number respectively.
- equalp expr expr
- equal? expr expr
- expr = expr
- notequalp expr expr
- notequal? expr expr
- expr <> expr
- Equality/inequality tests. Compares strings, numbers, or lists (equal if length and all members are equal).
- emptyp expr
- empty? expr
- Test if thing is an empty list or empty string.
- beforep thing1 thing2
- before? thing1 thing2
- Test string collation order.
- memberp thing list
- member? thing list
- Test if thing is equal to any member of list.
- substringp thing1 thing2
- substring? thing1 thing2
- Test if thing1 is a substring of thing2.
2.5 Queries
- count thing
- Outputs length of a list or number of characters in a string
- ascii expr
- Outputs ASCII (actually, Unicode) code point for first character of string
- char expr
- Outputs Unicode character at specified code point
- uppercase expr
- lowercase expr
- Outputs string converted to upper/lowercase
3. Communication
3.1 Transmitters
- print thing
- pr thing
- (print thing1 thing2 ...)
- (pr thing1 thing2 ...)
- Print inputs to the console, separated by spaces, and followed by a newline. Square brackets are only put around sublists.
- type thing
- (type thing1 thing2 ...)
- Like print but with no trailing newline.
- show thing
- (show thing1 thing2 ...)
- Like print but with square brackets around list inputs.
3.2 Receivers
3.3 File Access
3.4 Console (Terminal) Access
- cleartext
- ct
- Clear the console.
4. Arithmetic
4.1 Numeric Operations
Inputs are numbers or numeric expressions, output is a number.
- sum expr expr
- (sum expr ...)
- expr + expr
- difference expr expr
- expr - expr
- product expr expr
- (product expr ...)
- expr * expr
- quotient expr expr
- (quotient expr ...)
- expr / expr
- power expr expr
- expr ^ expr
- Add, subtract, multiply, divide, and raise-to-the-power-of respectively. A single input to quotient returns the reciprocal.
- remainder expr expr
- expr % expr
- modulo expr expr
- Outputs the remainder (modulus). For remainder and % the result has the same sign as the first input; for modulo the result has the same sign as a the second input.
- minus expr
- - expr
- Unary minus sign must begin a top-level expression, follow an infix operator, or have a leading space and no trailing space.
- abs num
- Absolute value
- int num
- round num
- Truncate or round a number, respectively.
- sqrt expr
- exp expr
- log10 expr
- ln expr
- Square root, e to the power of, common logarithm, and natural logarithm, respectively.
- arctan expr
- (arctan x y)
- sin expr
- cos expr
- tan expr
- The usual trig functions. Angles are in degrees.
- radarctan expr
- (radarctan x y)
- radsin expr
- radcos expr
- radtan expr
- The usual trig functions. Angles are in radians.
- iseq first last
- Outputs a list with integers from first to last, inclusive
- rseq first last count
- Outputs a list of count numbers from first to last, inclusive
4.2 Numeric Predicates
- greaterp expr expr
- greater? expr expr
- expr > expr
- greaterequalp expr expr
- greaterequal? expr expr
- expr >= expr
- lessp expr expr
- less? expr expr
- expr <= expr
- lessequalp expr expr
- lessequal? expr expr
- expr <= expr
- Greater than, greater than or equal to, less than, less than or equal to, respectively. Inputs are numbers or numeric expressions, output is 1 (true) or 0 (false).
4.3 Random Numbers
- random expr
- Outputs a random number from 0 through one less than expr
- rerandom
- (rerandom expr)
- Reseeds the random number generator, either to a fixed value or the specified seed.
4.4 Print Formatting
- form expr width precision
- Returns a formatted string with the result of a numeric expression with precision decimal places and padded on the left with spaces (if necessary) to be at least width characters long.
4.5 Bitwise Operations
- bitand expr expr
- (bitand expr ...)
- bitor expr expr
- (bitor expr ...)
- bitxor expr expr
- (bitxor expr ...)
- bitnot expr
- Bitwise and, or, exclusive-or, and not, respectively.
- ashift expr bitcount
- Arithmetic bit shift. If bitcount is negative, shifts to the right, preserving sign.
- lshift expr bitcount
- Logical bit shift. If bitcount is negative, shifts to the right, zero-filling.
5. Logical Operations
- true
- Outputs 1
- false
- Outputs 0
- and expr expr
- (and expr ...)
- or expr expr
- (or expr ...)
- xor expr expr
- (xor expr ...)
- not expr
- Logical "and", "or", "exclusive-or", and "not", respectively. Inputs are numbers or numeric expressions, output is 1 (true) or 0 (false).
6. Graphics
An introduction to Turtle Geometry.
6.1 Turtle Motion
Due to the 3D nature of VRMath2 Logo, the distance is measured by meter (default) or centimeter, instead of pixel. Bacause of the 3D space, there are some extra turning (change of direction) and moving (change of position) commands.
Change location or position
- forward expr
- fd expr
- Move turtle forward expr meter
- back expr
- bk expr
- Move turtle backward expr meter
- east expr
- Move turtle to east expr meter (towards +x)
- west expr
- Move turtle to west expr meter (towards -x)
- north expr
- Move turtle to north expr meter (towards -z)
- south expr
- Move turtle to south expr meter (towards +z)
- up expr
- Move turtle up expr meter (towards sky)
- down expr
- dn expr
- Move turtle down expr meter (towards ground)
- setpos [ expr expr expr ]
- setxyz expr expr expr
- setx expr
- sety expr
- setz expr
- Move turtle to the specified coordinate
- home
- Moves the turtle to center (0, 0 , 0), heading north
Change direction or orientation
- left expr
- lt expr
- Turn expr degrees to the left of the turtle
- right expr
- rt expr
- Turn expr degrees to the right of the turtle
- rollup expr
- ru expr
- Roll Up expr degrees (head up or tail down)
- rolldown expr
- rd expr
- Roll Down expr degrees (head down or tail up)
- tiltleft expr
- tl expr
- Tilt Left expr degrees (left side down or right side up)
- tiltright expr
- tr expr
- Tilt Right expr degrees (right side down or left side up)
- setheading [ expr expr expr expr ]
- seth [ expr expr expr expr ]
- Rotate the turtle to the specified heading or orientation
- lookatpos [ expr expr expr ]
- lookatxyz expr expr expr
- toward [ expr expr expr ]
- towards [ expr expr expr ]
- Rotate the turtle towards the specified [ x y z ] coordinates
Jump series commands (during pendown, move turtle without leaving track)
- jump
- Indicate an end or a start or a new face during faces construction
- jumpon
- jon
- Jump on will make subsequent movements as jump movements, meaning no tracks.
- jumpoff
- joff
- Jump off will cancel jump on effect.
- jumppos [ expr expr expr ]
- jumpxyz expr expr expr
- jumpx expr
- jx expr
- jumpy expr
- jy expr
- jumpz expr
- jz expr
- Move turtle to the specified coordinate
- jumpforward expr
- jf expr
- jumpback expr
- jb expr
- jumpeast expr
- je expr
- jumpwest expr
- jw expr
- jumpnorth expr
- jn expr
- jumpsouth expr
- js expr
- jumpup expr
- ju expr
- jumpdown expr
- jd expr
- jumphome expr
- jh expr
- Move turtle for the specified distance expr
6.2 Turtle Motion Queries
- pos
- getpos
- location
- position
- Outputs the current turtle position as [ x y z ]
- xcor
- getx
- Outputs the current turtle's x position
- ycor
- gety
- Outputs the current turtle's y position
- zcor
- getz
- Outputs the current turtle's z position
- ori
- heading
- getori
- orientation
- direction
- Outputs the current turtle heading as [x y z radian]
6.3 Turtle and Window Control
6.4 Turtle and Window Queries
- meter
- metre
- Set the unit of distance to meter (default).
- centimeter
- centimetre
- cm
- Set the unit of distance to centimeter.
- setturtle expr
- setavatar expr
- Set expr as the turtle. expr is the object id.
- showturtle
- st
- Show the turtle
- hideturtle
- ht
- Hide the turtle
- clean
- Clear the drawing area
- clearscreen
- cs
- Same as clean and home together
- shownp
- shown?
- Outputs 1 if the turtle is shown, 0 if the turtle is hidden
- distanceto [ expr expr expr ]
- distancetoxyz expr expr expr
- Outputs the distance from the turtle to the specified [ x y z ] or x y z
- distancebetween [ expr expr expr ] [ expr expr expr ]
- distancebtw [ expr expr expr ] [ expr expr expr ]
- Outputs the distance between the two specified [ x y z ] coordinates
- avatar
- turtle
- Outputs the current avatar id, or turtle, if current avatar in control
6.5 Pen and Background Control
- point
- line
- face
- Set turtle track mode to point, line or face
- pendown
- pd
- Turtle starts leaving a track
- penup
- pu
- Turtle stops leaving a track
- nextcolor
- nc
- Rotate pen color to the next color in the pallete
- nextcoloron
- ncon
- nextcoloroff
- ncoff
- Set auto next pen color on/off when the turtle moves
- setbackground expr
- setbg expr
- Set background index expr as in the background chooser. Index 45 (setbg 45) will use the current pen color as a single background color in the 3D space
- pencoloron
- pcon
- pencoloroff
- pcoff
- Set pen color on/off for the Face object. When pcoff, the faces created will use material settings (see 6.10)
- setpcname logocolor
- Set pen color using the 16 names below. E.g., setpcname "white
- setpencolor expr expr expr
- setcolor expr expr expr
- setrgb expr expr expr
- setpc expr expr expr
-
Set pen color in R G B. The 3-expr r/g/b values in between 0 to 1000.
The standard Logo colors in VRMath2 are:0: black 1: navy 2: blue 3: aqua 4: teal 5: green 6: olive 7: lime 8: maroon 9: red 10: orange 11: yellow 12: purple 13: white 14: silver 15: gray
- setg expr
- setb expr
- Set pen color's R G B component individually, expr is ranging from 0 to 1000.
6.6 Pen Queries
- pd?
- pendownp
- pendown?
- Outputs 1 if the pen is down, 0 otherwise
- pu?
- penupp
- penup?
- Outputs 1 if the pen is up, 0 otherwise
- penmode
- pm
- Outputs 0: point, 1: line or 2: face mode.
- getpc
- pc
- pencolor
- Outputs the current pen color, as a string of R G B, each ranging from 0 to 1000.
- color
- getcolor
- Outputs the current pen color, as a string of R G B, each ranging from 0 to 1. This is useful for Color Interpolator.
Note: in 3D models, the R G B of color are ranging from 0 to 1. In Logo, they are ranging from 0 to 1000 to suit younger programmers.
6.9 Primitive Objects
- cube
- box
- Create a 1x1x1 (in meter or current scale) cube at the turtle's position and direction
- cylinder
- can
- Create a cylinder with diameter 1 and height 1 (in meter or current scale)
- cone
- Create a cone with base diameter 1 and height 1 (in meter or current scale)
- sphere
- ball
- Create a sphere with diameter 1 (in meter)
- torus
- donut
- Create a torus
- snout
- Create a snout
- dish
- Create a dish
- pyramid
- Create a pyramid
- rectangulartorus
- rectorus
- Create a rectangular torus
- slopedcylinder
- slopedcan
- Create a slopped cylinder
- nozzle
- Create a nozzle
- elevationgrid
- elegrid
- Create a random 10x10 elevation grid to the right and back of the turtle
- extrusion
- Create an extrusion with a sqaure as the crossSection and three spine locations
- arc
- Create a 2D arc
- pie
- Create a 2D pie
- circle
- Create a 2D circle
- disk
- Create a 2D disk
- rectangle
- Create a 2D rectangle
- inline url
- world url
- Insert a world (x3d file) as an object
- picture url
- Insert an image file (.jpg .jpeg .gif .png)
- video url
- Insert a video file (.mp4 .ogv)
- sound url enabled loop
- Insert an audio file (.wav .mp3, oga). enabled (default: true) and loop (default: false) are to be true or false.
- pointlight
- Insert a point light
- dirlight
- directionallight
- Insert a directional light
- spotlight
- Insert a spotlight
- transform
- Insert a transform object (coordinate container)
- label text
- Insert a label. E.g., label "hello or label [Hello world!]
- viewpoint
- Insert a viewpoint with current view
6.10 Material Settings
- setdiffusecolor expr expr expr
- setdc expr expr expr
- Set diffuse color of the material. The three exprs are R G B ranging from 0 to 1000.
- setemissivecolor expr expr expr
- setec expr expr expr
- Set emissive color of the material. The three exprs are R G B ranging from 0 to 1000.
- setspecularcolor expr expr expr
- setsc expr expr expr
- Set specular color of the material. The three exprs are R G B ranging from 0 to 1000.
- setambientintensity expr
- setai expr
- Set the ambient intensity of the material, ranging from 0 to 1000.
- setshininess expr
- setsh expr
- Set the shininess of the material, ranging from 0 to 1000.
- settransparency expr
- settr expr
- Set the transparency of the material, ranging from 0 to 1000.
- setmaterial index_set index_item
- setmat index_set index_item
- Set the material from the pre-defined materials in Material Chooser. The first input index_set is the index of the material groups ranging from 0 to 15. The second input index_item is the item from the material set, and is ranging from 0 to 35.
6.11 Scale Settings and Queries
Change scale setting will only affect objects created after, not before.
- setscale expr expr expr
- Set scale factor in x y z.
- setscalex expr
- setsx expr
- setscalewidth expr
- setscalew expr
- Set scale factor in x dimension.
- setscaley expr
- setsy expr
- setscaleheight expr
- setscaleh expr
- Set scale factor in y dimension.
- setscalez expr
- setsz expr
- setscaledepth expr
- setscaled expr
- Set scale factor in z dimension.
- scale
- Output scale factor of x y z dimensions.
- scalex
- sx
- scalewidth
- Output scale factor of x dimension.
- scaley
- sy
- scaleheight
- Output scale factor of y dimension.
- scalez
- sz
- scaledepth
- Output scale factor of z dimension.
6.12 Texture Settings
- setimagetexture index_set index_item
- setit index_set index_item
- Set image texture from Texture Chooser. The first input index_set is the index of texture groups ranging from 0 to 10. The second input index_item is the index of texture item in the texture group. ranging from 0 to 35.
- setiturl url
- Set image texture's URL to the selected object.
- setitrepeats true|false
- setitrs true|false
- Set the image texture's repeats attribute to true or false. This has effect when the image texture scale s is greater than 1.
- setitrepeatt true|false
- setitrt true|false
- Set the image texture's repeatt attribute to true or false. This has effect when the image texture scale t is greater than 1.
- setitscale expr expr
- setitsc expr expr
- Set the image texture's scale factors in both s and t. expr is ranging from 0.001 to 1000.
- setitscales expr
- setitss expr
- Set the image texture's scale factor in s. expr is ranging from 0.001 to 1000.
- setitscalet expr
- setitst expr
- Set the image texture's scale factor in t. expr is ranging from 0.001 to 1000.
- setittranslation expr expr
- setittr expr expr
- Set the image texture's translation offsets in both s and t. expr is ranging from -1 to 1.
- setittranslations expr
- setitts expr
- Set the image texture's translation offset in s. expr is ranging from -1 to 1.
- setittranslationt expr
- setittt expr
- Set the image texture's translation offset in t. expr is ranging from -1 to 1.
- setitrotation expr
- setitrot expr
- Set the image texture's rotation in expr degrees, ranging from -360 to 360.
- removeimagetexture id
- removeit id
- rmimagetexture id
- rmit id
- Remove image texture of the object id
6.13 Font Settings
The following font settings are of X3D specification. However, most of them have not yet been implemented in X3DOM.
- setlabeltext text
- setlt text
- Set the label text as text when a label object is selected.
- setfontfamily index
- setff index
- Set the font family of label, as defined in the Font Editor in the Property Inspector. index is ranging from 0 to 11.
- setfontjustify index
- setfj index
- Set the font justify of label, as defined in the Font Editor in the Property Inspector. index is ranging from 0 to 15.
- setfontstyle index
- setfs index
- Set the font style of label, as defined in the Font Editor in the Property Inspector. index is ranging from 0 to 3.
- setfonthorizontal true|false
- setfh true|false
- Set the font direction vertical or horizontal.
- setfontlefttoright true|false
- setfl true|false
- Set the font direction from left to right or right to left.
- setfonttoptobottom true|false
- setft true|false
- Set the font direction from top to bottom or bottom to top.
- setfsize expr
- Set font size of the label text, ranging from 0 to 100.
- setfspacing expr
- Set space between individual letter in the label text, ranging from 0 to 100.
6.14 Object Settings and Manipulation
- object
- Output the last created object's id or last selected object's id.
- select id
- Select object by id.
- deselect
- Deselect object.
- hide id
- Hide the object by id. Object hidden will not be rendered in 3D space.
- unhide id
- Unhide the object by id.
- copy id
- Copy the object id to paste later.
- paste
- Paste the copied object.
- delete id
- Delete the object by id
- get id attr
- Get is an universal command to retrieve any attribute's value of any object. The first input is the object's id, the second input is the attribute name attr. Get will output the value of the specified attribute.
- set id attr value_list
- Set is an universal command to change any attribute's value of any object. The first input is the object's id, the second input is the attribute name attr, the value_list is the value to the attribute. E.g., set "obj_0_cube "size [1 2 1]
- move source_id destination_id
- Move an object in or out of a transform object. The first input is the source object's id. The second input is the destination object's id. E.g., if obj_0 is a cube, obj_1 is a transform object, move "obj_0 "obj_1 will make obj_0 the child of obj_1.
- setparent parent_id
- sp parent_id
- Set the parent transform node. Once set, any objects created after will be children of the parent transform node. The default parent transform node is root. Only a transform node can be set as a parent. For example,
SETPARENT "obj_0 ; make transform node obj_0 as parent.
SETPARENT "root ; objects created after this will be children of root. - parent
- Output the curent parent transform id.
6.15 Animation
Animations are produced by TIMESENSOR, INTERPOLATOR and ROUTE as of X3D specification.
- timesensor id cycleInterval loop
- Create or set a timesensor with the first input as the timesensor id, the second input as the cycleInterval, and the third input as loop ("true or "false or true or false).
- coordinateinterpolator id key_list keyValue_list
- coorint id key_list keyValue_list
- Create or set a coordinate interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [ [ [0 0 0] [0 1 0] [0 0 0] ] [ [0 0 0] [0 1 0] [0 0 0] ] [ [0 0 0] [0 1 0] [0 0 0] ] ]) in coordinates. This interpolator outputs a set of coordinates useful to animate shapes created by the turtle track.
- normalinterpolator id key_list keyValue_list
- norint id key_list keyValue_list
- Create or set a normal interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [ [ [0 0 0] [0 1 0] [0 0 0] ] [ [0 0 0] [0 1 0] [0 0 0] ] [ [0 0 0] [0 1 0] [0 0 0] ] ]) in normalised vectors. This interpolator outputs a set of normalised vectors useful to render normalised surfaces.
- positioninterpolator id key_list keyValue_list
- posint id key_list keyValue_list
- Create or set a position interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [ [0 0 0] [0 1 0] [0 0 0] ]) in positions. This interpolator output a single coordinate useful to animate position of object in 3D space.
- orientationinterpolator id key_list keyValue_list
- oriint id key_list keyValue_list
- Create or set an orientation interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [ [0 1 0 0] [0 1 0 3.14] [0 1 0 6.28] ]) in orientations. This interpolator outputs a single orientation useful to animate rotation of object in 3D space.
- colorinterpolator id key_list keyValue_list
- colorint id key_list keyValue_list
- clrint id key_list KeyValue_list
- Create or set a color interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [ [1 0 0] [0 1 0] [0 0 1] ]) in colors. This interpolator outputs a single color useful to animate color of material (e.g., diffuseColor, emissiveColor, specularColor).
- scalarinterpolator id key_list keyValue_list
- scalarint id key_list keyValue_list
- sclrint id key_list keyValue_list
- Create or set a scalar interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [1 3 1]) in single values. This interpolator outputs a single number useful to animate a dimension of object (e.g., height, radius).
- vectorinterpolator id key_list keyValue_list
- vectorint id key_list keyValue_list
- vecint id key_list keyValue_list
- Create or set a vector interpolator with the first input as the id, the second input as the key (e.g., [0, 0.5, 1]), and the third input as the keyValue (e.g., [1 3 1 2 0 2 1 2 3] [0 1 2 1 2 3 2 1 2 ] [1 3 1 2 0 2 1 2 3]) in sets of single values. This interpolator outputs a set of single number useful to animate the height of ElevationGrid.
- route id fromNode fromField toNode toField
- Create or set a route with five inputs as id, fromNode, fromField, toNode, toField respectively.
- removeroute id
- rmroute id
- Remove route with id as id.
- spin id direction cycleInterval
- Spin object with id as id, in one of the six axes directions as direction, with a loop cycleInterval. The direction is a Logo word and only in the twelve below:
right, rt, left, lt, tiltright, tr, tiltleft, tl, rollup, ru, rolldown, rd
The cycleInterval must be a non-zero positive number.
SPIN is a convenient command, which creates a timesensor, an orientationInterpolator, and two routes. For example:
- CS BOX ; create a box with id obj_0
- SPIN "obj_0 "right 10 ; spin the box in the right turn direction with a 10 second cycle
- removespin id
rmspin id - Remove the spin animation on object id.
- travel id path cycleInterval
- Make the object id travel along a path. The path is a Logo list containing at least two coordinates. The cycleInterval specify the cycle time in seconds to travel. For example:
- CS BOX ; create a box with id obj_0
- TRAVEL "obj_0 [ [0 0 0] [0 1 0] [0 0 0] ] 10 ; The box travels from (0,0,0) to (0,1,0) then back to (0,0,0) linearly with a 10 second cycle
- removetravel id
rmtravel id - Remove the travel animation on object id.
- orient id directions cycleInterval
- Make the object id orient with the given directions. The directions is a Logo list containing at least two directions. The cycleInterval specify the cycle time in seconds to orient. For example:
- CS BOX ; create a box with id obj_0
- ORIENT "obj_0 [ [0 0 1 0] [0 -1 0 1.5708 ] [0 0 1 0] ] 10 ; The box orients (rotates) from (0,0,1,0) to (0,-1,0,1.5708) (right 90) then back to (0,0,1,0) linearly with a 10 second cycle
- removeorient id
rmorient id - Remove the orient animation on object id.
- tour id views cycleInterval
- Make the viewpoint object id touring with the given views. The views is a Logo list containing at least two views collected using COLLECTVIEW command. if manual construct, a vew contains a position (x, y, z) and an orientation (x, y, z, r). The cycleInterval specifies the cycle time in seconds to tour. For example:
- CS VIEWPOINT ; create a viewpoint with id as obj_0
- TOUR "obj_0 [ [0 1 5 0 0 0 0] [0 0 1.1498 0 0 0 0 ] [0 1 5 0 0 0 0] ] 10 ; The viewpoint will tour through these three views in a 10-second cycle
- removetour id
rmtour id - Remove tour animation on the viewpoint id.
- collectposition variableName
- collectlocation variableName
collectpos variableName - Start collecting positions of the turtle into variable variableName as a Logo word. After this command, every change of position of the turtle will be collected. You can start moving the turtle to collect a path of coordinates. To commit the collected coordinates into the variable, please use ENDCOLLECT variableName command. Positions collected can be used as the path for the TRAVEL command.
- collectdirection variableName
- collectorientation variableName
collectori variableName - Start collecting orientations of the turtle into variable variableName as a Logo word. After this command, every change of direction of the turtle will be collected. You can start turning the turtle to collect a set of directions. To commit the collected directions into the variable, please use ENDCOLLECT variableName command. Orientations collected can be used as the directions for the ORIENT command.
- collectview variableName
- Collect current view into the variable variableName as a Logo word. A view is a 7-item list containing view position (x, y, z) and orientation (x, y, z, r). The use of this command is intended to be interactive instead of writen in a Logo program (although this is also possible in following mode). So to use this command, you firstly navigate in the 3D window to get a view you like, then specify this command with a variableName. After this, you will nagivate to a next view you like and specify exactly the same command and variableName again. You continue collecting views and at the end, use ENDCOLLECT variableName command to make it a Logo variable. The :variableName can later be used in the TOUR command to create a tour animation applying to a VIEWPOINT object.
- endcollect variableName
- End collection and set the variable variableName as a Logo word in Logo.
6.16 Behaviour
Behaviours are produced by Events and Actions. Events are behaviours trigged by input devices such as a mouse CLICK on an object. Actions are behaviours to be performed on certain Events. Actions have no effect until they are associated with Events. For example:
CS ; clearscreen DIRLIGHT ; create a directional light (obj_0, and the actual light's id is obj_0_dirlight) BALL ; create a sphere (obj_1) TOGGLE "action1 "obj_0_dirlight "on ; create a toggle action named action1, which toggles object's (obj_0_dirlight) attribute (on) between true and false. CLICK "obj_1 "action1 ; associate action1 with obj_1's click event. So when the sphere is clicked, it toggles the directional light.
Events
- click id action
- Perform action when object id is clicked.
- removeclick id
- rmclick id
- Remove click event on the object id.
Actions
- update name id attr value
- Create an update action named name, which updates the attribute attr of object id with value. value can be number, word or list.
- toggle name id attr
- Create a toggle action named name, which toggles the attribute attr of object id. The attr must be an attribute with values true or false.
- playnote name instrument note
- Create a playnote action named name, which plays the instrument instrument of note note. The instrument must be a number from 1 to 3 (1: Piano, 2: Acoustic Guitar, 3: Trumpet). The note must be a number from 1 to 88, or from A-1 to C7. Note number 40 is the same as C3 and 41 is the same as C#3.
- goto name id
- Create a goto action named name, which focuses the object with id as id in view. If the object is a viewpoint, then this action will goto the viewpoint.
- rmaction name
- removeaction name
- Remove the action named name from the internal action registry. Note: this will not remove the effect once it has been associated with an event onto an object.
6.17 3D Space and Navigation Control
The following commands correspond to the functions in the toolbar in the 3D window.
- examine
- Change navigation mode to Examine.
- walk
- Change navigation mode to Walk.
- fly
- Change navigation mode to Fly.
- turtleeye
- te
- Change navigation mode to TurtleEye (as looking through the turtle's eyes).
- follow
- Change navigation mode to Follow.
- navmode
- Return current navigation mode. 0: Examine, 1: Walk, 2: Fly, 3: TurtleEye, 4: Follow.
- restoreview
- rv
- Restore original viewpoint.
- showall
- sa
- Fit all objects into view in the 3D window.
- showobject id
- so id
- Fit object id into view in the 3D window.
- setrotationcenter x y z
- setrc x y z
- Set rotation center to the given coordinate x y z for Examine mode.
- rotationcenter
- rc
- getrc
- Return rotation center (x,y,z) of the Examine mode.
- headlighton
- hlon
- Turn on headlight.
- headlightoff
- hloff
- Turn off headlight.
- headlight
- hl?
- Return current headlight status. 0: off, 1: on.
- getview
- Return current view as a 7-item list. The first 3 items are the view position, and the last 4 items are the view orientation.
- getviewpos
- Return current view position [x, y, z] as a list. These are the first 3 items of GETVIEW.
- getviewori
- Return current view orientation quaternion [x, y, z, r] as a list. These are the last 3 items of GETVIEW.
7. Workspace Management
7.1 Procedure Definition
- to procname inputs ... statements ... end
- Define a new named procedure with optional inputs
- def procname
- Outputs the definition of a named procedure as a string
- copydef newname oldname
- Copy a procedure. If a procedure newname already existed it will be overridden. Primitive procedures can't be overridden unless REDEFP is TRUE.
7.2 Variable Definition
- make varname expr
- Update a variable or define a new global variable. The variable name must be quoted, e.g. make "foo 5
- name expr varname
- Like make but with the inputs reversed
- local varname
- (local varname ...)
- A subsequent make will create the variable(s) in the local scope instead of the global scope
- localmake varname expr
- Define a variable in the local scope (shortcut for local then make
- thing varname
- Outputs the value of variable. :foo is a shortcut for thing "foo
- global varname
- Reserve the variable at the global scope. This doesn't do anything useful.
7.3 Property Lists
- pprop plistname propname value
- Set the property propname in the property list plistname to value value.
- gprop plistname propname
- Get the value of the property propname in the property list plistname, or the empty list if no such property.
- remprop plistname propname
- Remove the property propname in the property list plistname.
- plist plistname
- Return a list of properties in the property list plistname, alternating property name, property value.
7.4 Workspace Predicates
Predicates return 1 (true) or 0 (false)
- procedurep name
- procedure? name
- Test if there is a procedure with the given name.
- primitivep name
- primitive? name
- Test if there is a built-in procedure with the given name.
- definedp name
- defined? name
- Test if there is a user-defined procedure with the given name.
- namep name
- name? name
- Test if there is a variable with the given name.
- plistp name
- plist? name
- Test if there is a property list with the given name.
7.5 Workspace Queries
- contents
- Outputs a list with three members. The first is a list of user-defined procedure names. The second is a list of defined variables. The third is a list of non-empty property list names. Only non-buried procedures, variables, and property lists are included.
- buried
- Outputs a list with three members. The first is a list of user-defined procedure names The second is a list of defined variables. The third is a list of non-empty property list names. Only buried procedures, variables, and property lists are included.
- procedures
- Outputs a list of user-defined non-buried procedure names.
- primitives
- Outputs a list of primitive non-buried procedure names.
- globals
- Outputs a list of defined non-buried global variables.
- names
- Outputs a list with two members. The first is an empty list. The second is a list of defined non-buried variables.
- plists
- Outputs a list with three members. The first is an empty list. The second is an empty list. The third is a list of non-empty non-buried property list names.
- namelist name
- namelist namelist
- Return a contents-style list with the given variable names.
- pllist plname
- pllist plnamelist
- Return a contents-style list with the given property lists.
7.7 Workspace Control
- reset
- Reset scale, material, texture, distance unit to default value.
- erase contentslist
- Takes a three member list, where the first is a list of user-defined procedure names to erase, the second is a list of defined variables to erase, the third is a list of property lists to erase. Primitive procedures can't be erased unless REDEFPis TRUE.
- erall
- Erase all non-buried user-defined procedures, variables and property lists.
- erps
- Erase all non-buried user-defined procedures.
- erns
- Erase all non-buried variables.
- erpls
- Erase all non-buried property lists.
- ern varname
- ern varnamelist
- Erase the named variable(s).
- epl plname
- epl plnamelist
- Erase the named property list(s).
- bury contentslist
- Takes a three member list, where the first is a list of user-defined procedure names to bury, the second is a list of defined variables to bury, the third is a list of property lists to bury.
- buryall
- Bury all user-defined procedures, variables, and property lists.
- unbury contentslist
- Takes a three member list, where the first is a list of user-defined procedure names to unbury, the second is a list of defined variables to unbury, the third is a list of property lists to unbury.
- unburyall
- Unbury all user-defined procedures, variables, and property lists.
- buriedp contentslist
- buried? contentslist
- Return 1 if the first named user-defined procedure, variable, or property list exists and is buried, 0 otherwise.
8. Control Structures
8.1 Control
- run [ statements ... ]
- Run the specified statements once
- runresult [ statements ... ]
- Run the specified statements once. If the statements return a value, the result is a list with the value as a single member. Otherwise, the result is an empty list.
- repeat expr [ statements ... ]
- Repeat statements expr times
- forever [ statements ... ]
- Repeat statements forever. Used inside a user-defined procedure that terminates with output or stop
- repcount
- Outputs the current iteration number of the current repeat or forever
- if expr [ statements ... ]
- Execute statements if the expression is non-zero
- ifelse expr [ statements ... ] [ statements ... ]
- Execute first set of statements if the expression is non-zero, otherwise execute the second set
- test expr
- Test the specified expression, save the result in the local scope for subsequent use by iftrue or iffalse
- iftrue [ statements ...]
- ift [ statements ...]
- iffalse [ statements ...]
- iff [ statements ...]
- Run the statements if the result of the last local test was non-zero (true) or zero (false) respectively.
- stop
- End the running procedure with no output value
- output expr
- op expr
- End the running procedure and output the specified value
- wait time
- Pauses execution. time is in 60ths of a second.
- bye
- Terminate the program
- .maybeoutput expr
- Like output if expr returns a value, like stop otherwise
- ignore expr
- Evaluate and ignore results of the expression
- for controllist [ statements ...]
- Typical for loop. The controllist specifies three or four members: the local varname, start value, limit value, and optional step size.
- do.while [ statements ...] expr
- Runs the specified statements at least once, and repeats while the expression is non-zero (true).
- while expr [ statements ...]
- Runs the specified statements only while the expression remains non-zero (true).
- do.until [ statements ...] expr
- Runs the specified statements at least once, and repeats while the expression is zero (false).
- until expr [ statements ...]
- Runs the specified statements only while the expression remains zero (false).
- case value [ clauses ... ]
- For each clause in order: If the clause is of the form [ ELSE expr ] then expr is evaluated and returned. Otherwise, if the clause is of the form [ [ matches ] expr ] and value is a member of matches then expr is evaluated and returned.
- cond [ clauses ... ]
- For each clause in order: If the clause is of the form [ ELSE expr ] then expr is evaluated and returned. Otherwise, if the clause is of the form [ [ expr1 ] expr2 ] and expr1 evaluates to non-zero (true) then expr2 is evaluated and returned.
8.2 Template-based Iteration
These higher-level procedures support only the named procedure form of template. The first input is the name of a procedure to call.
- apply procname list
- Call procname with the members of list as inputs
- invoke procname input1
- (invoke procname input1 ...)
- Call procname with the specified inputs as inputs
- foreach procname list
- call procname for each item in the list
- map procname list
- Outputs a list composed of the results of calling procname for each item in the list
- filter procname list
- Outputs a list composed of the input list where procname called on the item returns non-zero (true)
- find procname list
- Outputs the first item in list for which calling procname on it returns non-zero (true). If not found, the empty list is returned.
- reduce procname list
- (reduce procname list initial)
- Call procname repeatedly with two inputs - the current value and the next list item. If initial is not specified, the first list element is used instead.
9. Environment Management
9.1 Date and Time
- getdate
- Returns the day of the month (from 1-31)
- getday
- Returns the day of the week (from 0-6)
- getyear
- getfullyear
- Returns the year (four digits)
- gethours
- Returns the hour (from 0-23)
- getmilliseconds
- Returns the milliseconds (from 0-999)
- getminutes
- Returns the minutes (from 0-59)
- getmonth
- Returns the month (from 0-11)
- getseconds
- Returns the seconds (from 0-59)
- gettime
- Returns the number of milliseconds since midnight Jan 1, 1970
- getdatestring
- Converts the date portion of a Date object into a readable string. E.g., Sat Feb 15 2014
- gettimestring
- Converts the time portion of a Date object to a string. E.g., 14:29:32 GMT+1000 (EST)
- 5335 reads