The GeomLab library

Here is a list of the names that are defined when GeomLab starts. These are the names that you can initially used in expressions, both constants that stand for values themselves, and functions that can be applied to other values. Also included in the list are the operators that can be used in expressions.

Numeric functions and operators

x + y, x - y, x * y, x / y
Arithmetic operators.
- x, ~ x
The negative of the number x. Either notation is accepted.
x < y, x <= y, x = y, x <> y, x >= y, x > y
Comparison operators. These compare two numbers and yield a Boolean: either true or false.
int(x)
The integer part of the number x. This is the greatest integer n such that n <= x; it has the property that if k is any integer, then k <= x if and only if k <= n. (EWD)
x div y, x mod y
Integer division and remainder. These are defined by x div y = int(x/y) and x mod y = x - y * (x div y).
sqrt(x)
The square root of x.
sin(x), cos(x), tan(x)
Trigonometric functions. These expect an argument in degrees.
numeric(x)
Yields true if x is a number, false otherwise.

Booleans

true, false
The two Boolean constants.
not p, p & q, p or q
Boolean operators. Note that & and or evaluate only their left-hand argument if that is enough to determine the result.

Lists

x : xs
The list obtained by adding x to the beginning of the list xs as a new first element.
head(xs)
If xs is a non-empty list, the first element of xs.
tail(xs)
If xs is a non-empty list, the list that contains all but the first element of xs.
xs @ ys
The list containing all elements of list xs, followed by all elements of list ys.
reverse(xs)
The list containing the same elements as list xs, but in reverse order.
length(xs)
The length of the list xs.

Pictures

blank
A square picture that is completely blank
null
The null picture. This has the properties that null $ p = p = p $ null and null & p = p = p & null for all pictures p.
solid(r, c)
A picture that is a solid block of colour c. The ratio width/height of the picture is the number r.
p $ q
The compound picture obtained by placing p beside q. The two pictures are scaled relative to each other so that they have the same height.
p & q
The compound picture obtained by placing p above q. The two pictures are scaled relative to each other so that they have the same width.
rot(p)
A copy of picture p rotated by anticlockwise by 90°.
flip(p)
A copy of picture p reflected about the vertical axis.
stretch(r, p)
A copy of picture p that has been stretched by a scale factor r in the x direction.
colour(p)
A coloured copy of picture p. Some pre-defined pictures (i.e., the tiles used in making Escher pictures) have an implicit colour scheme that is linked to rotations of the tiles. If picture p contains such tiles, then colour(p) is a picture in which these implicit colours have been made visible.
aspect(p)
The aspect ratio (width/height) of picture p.

Colours

rgb(r, g, b)
The colour with the red, green and blue components specified. Each component is a number between 0 and 1; components that lie outside this range are truncated.
hsv(h, s, v)
The colour with the hue, saturation and value components specified. Again, the components are truncated if necessary so that they lie between 0 and 1.

Picture constants

man, woman, tree, star
Stick-figures of a man, a woman, a pine tree, and a five-pointed star.
A, B, C, D, E, F
Six tiles for use in drawing Escher pictures. These have colours that are made visible using the primitive colour(p).
bend, straight
Two square tiles that respectively show a bent and a straight line.

Convenience

The following constants and functions are included in the initial state of GeomLab for convenience (so that the definitions do not have to be typed in anew every session. Unlike the other names listed in this document, each of these names can be re-defined by entering a new definition.

rot2(p)
A copy of picture p rotated by 180°:
define rot2(p) = rot(rot(p))
rot3(p)
A copy of picture p rotated anticlockwise by 270°:
define rot3(p) = rot(rot(rot(p)))
cycle(p)
Four copies of picture p, assembled in a square pattern:
define cycle(p) = (p $ rot3(p)) & (rot(p) $ rot2(p))
T, U
Two tiles formed by assembling the parts A, B, C and D:
define T = (A $ B) & (C $ D)
define U = (A $ rot3(A)) & (rot(A) $ rot2(A))
frame(c, s, p)
The picture obtained by surrounding a copy of p with a frame that has rotated copies of s at the sides and c at the corners:
 define frame(c, s, p) =
    (c      $ rot3(s) $ rot3(c))
  & (s      $ p       $ rot2(s))
  & (rot(c) $ rot(s)  $ rot2(c))