Skip to content

Operator Index

Infix operators

The following list gives an overview of Special Character Operators ordered by precedence. Precedece is given as a number. The lower the number the higher the binding. Operators of equal precedence are applied from left to right, i.e. Special Character Operators are left-associative.

  • : (20) access to self defined
  • . (25) access to predefined data field
  • ° (25) degree operator
  • _ (50) access to element in list
  • ^ (50) power operator
  • * (100) multiplication (also of vectors and matrices)
  • / (100) division (also of vectors and matrices by scalars)
  • + (200) addition (also of vectors and matrices by scalars)
  • - (200) subtraction (also of vectors and matrices by scalars, binary and unary)
  • ! (200) logic not (unary)
  • == (300) equal
  • > (300) greater
  • < (300) smaller
  • >= (300) greater or equal
  • <= (300) smaller or equal
  • != (300) not equal
  • ~= (300) approximately equal
  • ~< (300) approximately smaller
  • ~> (300) approximately greater
  • ~>= (300) approximately greater or equal
  • ~<= (300) approximately smaller or equal
  • =:= (300) equal after evaluation
  • & (350) logic and
  • % (350) logic or
  • != (350) not equal
  • ~!= (350) approximately not equal
  • .. (350) list of numbers from/to
  • ++ (370) concatenation of lists
  • -- (370) list difference
  • ~~ (370) common elements of two lists
  • :> (370) append element to list
  • <: (370) prepend element to list
  • = (400) variable assignment
  • := (400) function definition
  • :=_ (400) clearing a definition
  • -> (400) modifier declaration
  • , (500) separator for lists and functions
  • ; (500) separator for statements

In what follows we specify Cinderella's predefined functions. After the function name, the number of arguments is indicated in brackets. For easier reference, the functions are grouped in a few categories. Some functions may appear in several categories. Light blue functions are not documented yet.

Basic Functionality

Control structures

  • if (2) if operator
  • if (3) if/else operator
  • trigger (2) trigger a function on value change
  • while (2) while loop
  • repeat (2) repeat loop with # run-variable
  • repeat (3) repeat loop with explicit run-variable
  • forall (2) repeat loop with # run-variable
  • forall (3) forall loop with explicit run-variable
  • eval (1) force evaluation of an expression

Variable management

  • clear (0) clear all variables
  • clear (1) clear a specific variable
  • keys (1) list of local keys associated with an object or a variable
  • createvar (1) create a local variable
  • removevar (1) destroy a local variable
  • regional (arbitrary many arguments) create local variables
  • local (arbitrary many arguments) create local variables (deprecated)
  • release (arbitrary many arguments) remove local variables and return last value (deprecated)

Output

  • print (1) print a value
  • println (0) newline
  • println (1) print a value followed by newline
  • clearconsole (0) clear the output console
  • err (1) debugging printout
  • assert (2) conditional print for error checking
  • format (2) convert a number to a string with specified precision
  • message (1) show a message in the status line

Calculations

Arithmetic functions

  • sqrt (1) square-root
  • exp (1) exponential function
  • log (1) natural logarithm
  • sin (1) sine function
  • cos (1) cosine function
  • tan (1) tangent function
  • arcsin (1) arcsine function
  • arccos (1) arccosine function
  • arctan (1) arctangent function
  • arctan2 (1) binary arctangent function
  • arctan2 (2) binary arctangent function
  • add (2) addition
  • sub (2) subtraction
  • mult (2) multiplication
  • div (2) division
  • mod (2) modulo
  • pow (2) power
  • abs (1) absolute value
  • round (1) rounded value
  • floor (1) closest smaller integer
  • ceil (1) closest larger integer
  • re (1) real part
  • im (1) imaginary part
  • conjugate (1) complex conjugate
  • random (1) random real number
  • randominteger (1) random integer number
  • random (0) random number between 0.0 and 1.0
  • randombool (0) random boolean value
  • randomnormal (0) (0,1)-normal distributed random real value
  • seedrandom (1) seed the random generator

Boolean functions

  • not (1) logical not
  • and (2) logical and
  • or (2) logical or
  • xor (2) logical exclusive or

Predicates

String functions

  • text (1) convert anything to a string
  • substring (3) substring of a string from start index to end index
  • replace (3) replace all occurences of a substring by another string
  • replace (2) apply several replacements given in a list of replacement pairs
  • tokenize (2) tokenize a string and return a list of tokens
  • indexof (2) first index of a substring
  • indexof (3) first index of a substring after position
  • length (1) length of a string
  • format (2) convert a number to a string with specified precision
  • sort sort elements from a list, can in particular be applied to lists of strings
  • fontfamilies (0) a list of all available fonts
  • unicode (1) convert unicode into character
  • candisplay (1) test if a string can be rendered by the current system and font
  • guess (1) convert a number to a string guessing the numbers meaning
  • parse (1) convert string to CindyScript expression

Calculus

  • d (2) numerically differentiate a function
  • tangent(2) calculate the tangent to a function
  • guess (1) convert a number to a string guessing the numbers meaning
  • pslq (1) same as guess
  • roots (1) determine the roots of a polynomial

Lists and Linear Algebra

Elementary list operations

  • take (2) access the n-th element of a list
  • length (1) length of a list
  • contains (2) predicate for membership
  • append (2) append an element to a list
  • prepend (2) prepend an element to a list
  • concat (2) concatenate two lists
  • common (2) common elements of two lists
  • remove (2) list difference

Traversing lists

  • forall (2) forall loop with # run-variable
  • forall (3) forall loop with explicit run-variable
  • apply (2) apply a function to all elements of a list (run variable is #)
  • apply (3) apply a function to all elements of a list (explicit run variable)
  • select (2) select all elements of a list with a certain property (run variable is #)
  • select (3) select all elements of a list with a certain property (explicit run variable)

High-level list operations

  • pairs (1) list of all pairs of elements of a list
  • triples (1) list of all triples of elements of a list
  • directproduct (2) direct product of two lists
  • consecutive (1) list of all pairs of consecutive elements of a list
  • cycle (1) list of all pairs of consecutive elements of a list, cyclically closed
  • reverse (1) reverse a list
  • set (1) remove multiple instances of list elements, yielding a set
  • sort (1) sort elements in a list
  • sort (2) sort elements in a list by explicit function
  • flatten (1) flatten the nesting depth of a list

Lists of geometric objects

Arithmetic list operations

  • sum (1) sum of all list elements
  • sum (2) sum of function values applied to all list elements (run variable is #)
  • sum (3) sum of function values applied to all list elements (explicit run variable)
  • product (1) product of all list elements
  • product (2) product of function values applied to all list elements (run variable is #)
  • product (3) product of function values applied to all list elements (explicit run variable)
  • min (1) minimum of all list elements
  • min (2) minimum of function values applied to all list elements (run variable is #)
  • min (3) minimum of function values applied to all list elements (explicit run variable)
  • max (1) maximum of all list elements
  • max (2) maximum of function values applied to all list elements (run variable is #)
  • max (3) maximum of function values applied to all list elements (explicit run variable)

Vector and matrix operations

  • zerovector (1) create a zero vector of specified length
  • zeromatrix (2) create a zero matrix of specified length
  • rowmatrix (1) convert a vector to a row matrix
  • columnmatrix (1) convert a vector to a column matrix
  • matrixrowcolumn (1) number of rows and colums of a matrix
  • row (2) a specific row of a matrix
  • column (2) a specific column of a matrix
  • submatrix (2) a specific minor of a matrix
  • transpose (1) transpose of a matrix
  • dist (2) numerical value of the distance of two vectors.
  • det (1) determinant of a square matrix
  • hermiteanproduct (2) hermitian scalar product
  • inverse (1) inverse of a square invertible matrix
  • adj (1) adjunct of a square matrix
  • eigenvalues (1) eigenvalues of a square matrix
  • eigenvectors (1) eigenvectors of a square matrix
  • linearsolve (2) solve a system of linear equations
  • convexhull3d (1) convex hull of a list of 3D points

Drawing

Drawing functions

Drawing appearance

  • pointsize (1) set point size
  • linesize (1) set line size
  • textsize (1) set text size
  • pointcolor (1) set point color
  • linecolor (1) set line color
  • textcolor (1) set text color
  • color (1) set overall color
  • alpha (1) set overall alpha
  • gsave (0) store colors, alpha, width, clip, and transformation to stack
  • grestore (0) restore colors, alpha, width, clip and transformation from stack
  • greset (0) reset colors, alpha, width, clip and transformation. Reset stack

Color functions

  • red (1) red RGB-vector
  • green (1) green RGB-vector
  • blue (1) blue RGB-vector
  • grey (1) grey RGB-vector
  • gray (1) gray RGB-vector
  • hue (1) hue RGB-vector

Function plotting

  • plot (1) plot a function with # run variable
  • plot (2) plot a function with explicit run variable
  • fillplot (1) plot a function with integral like highlighting
  • fillplot (2) highlight the difference between two functions
  • colorplot (3) plot a region colored by the values of a function
  • drawfield (1) draw the flux of a vector field
  • drawfieldcomplex (1) draw the flux of a complex function
  • drawforces (1) draw the flux of a force field
  • drawcurves (2) draw an oscillograph for physics
  • mapgrid (1) mapping a rectangular grid

Pixelgraphics

  • drawimage (2) draw a pixelimage, w.r.t. one point
  • drawimage (3) draw a pixelimage, w.r.t. two points
  • drawimage (4) draw a pixelimage, w.r.t. three points
  • drawimage (5) draw a pixelimage, w.r.t. four points
  • mapimage (2) map a pixelimage, w.r.t. a function
  • imagesize (1) getting the size of an image
  • imagergb (3) inquiring the rgba value of a pixel
  • createimage (3) create a pixelimage with name and specified size
  • clearimage (1) erasing a pixelimage
  • removeimage (1) removing a pixelimage
  • canvas (3) using a pixelimage as canvas w.r.t. one point
  • canvas (4) using a pixelimage as canvas w.r.t. two points
  • canvas (5) using a pixelimage as canvas w.r.t. three points

Shapes

  • circle (2) create a circular shape from point and radius
  • polygon (1) create a polygonal shape from a list of points
  • halfplane (2) create a halfplane shape
  • screen (0) create a polygonal shape that covers the screen
  • fill (1) fill a shape
  • draw (1) draw the outline of a shape
  • clip (1) set clippath to a shape

Geometric transformations

  • translate (1) translate the global coordinate system
  • rotate (1) rotate the global coordinate system
  • scale (1) scale the global coordinate system
  • setbasis (1) set global coordinate system to a translation basis
  • setbasis (2) set global coordinate system to a similarity basis
  • setbasis (3) set global coordinate system to an affine basis
  • setbasis (4) set global coordinate system to a projective basis

Layer

Geometry

Geometric Functions

  • moveto (2) move point to position
  • meet (2) intersection of two lines
  • join (2) join of two points
  • perp (1) perpendicular 2-dimensional vector
  • perp (2) perpendicular of line through point
  • perpendicular (2) perpendicular of line through point
  • para (2) parallel of line through point
  • parallel (2) parallel of line through point
  • cross (2) cross-product of two 3-dimensional vectors
  • dist (2) distance of two points
  • area (3) area of triangle given by three points
  • det (3) determinant of matrix of three points in homogeneous coordinates
  • crossratio (4) cross-ratio of four points
  • complex (1) convert xy-point to complex number
  • gauss (1) convert complex number to xy-point
  • point (1) set the geometric type of a vector to point
  • line (1) setting the geometric type of a vector to line
  • geotype (1) retrieve the geometric type of a vector
  • map (2) obtain a transformation matrix for translations
  • map (4) obtain a transformation matrix for similarities
  • map (6) obtain a transformation matrix for affine transformations
  • map (8) obtain a transformation matrix for projective transformations
  • pointreflect (1) obtain a transformation matrix for reflection in a point
  • linereflect (1) obtain a transformation matrix for reflection in a line
  • incidences (1) list of incidences of a geometric object
  • locusdata (1) list of points on a locus

Inspection

Construction manipulation

  • createpoint (2) create a point with name and position (since 2.1)
  • create (3) create a an arbitrary geometric element
  • removeelement (1) delete a named geometric element and the dependent elements of it
  • algorithm (1) Getting the construction algorithm of an element
  • inputs (1) Getting the defining objects of an element
  • element (1) Getting a handle to an element

Sound

MIDI

Sampled Audio

  • playsin (1) play a periodic signal
  • playfunction (1) use a function to generate an audio sample
  • playwave (1) use a list of numbers to generate an audio sample
  • stopsound (0) stop all sample out lines

System functions

Mouse and key input

  • mover (0) last moved object
  • mouse (0) current mouse position in homogeneous coordinates
  • elementsatmouse (0) lists all elements close to the current mouse position
  • key (0) typed character
  • iskeydown (1) asks if a key is currently pressed
  • keydownlist (0) list of all kurrently pressed keys
  • amsdata (0) data from a built-in gravity sensor
  • calibratedamsdata (0) data from a built-in gravity sensor after calibration
  • createtool (3) creating a custom toolbar
  • removetool (1) removing a tool from a custom toolbar

Time

  • resetclock (0) reset the internal clock
  • seconds (0) seconds since last reset
  • simulationtime (0) time synchronized with simulation
  • time (0) current real-world time
  • date (0) current real-world date
  • wait (1) wait for a specified number of milliseconds

File IO

  • setdirectory (1) set current directory
  • load (1) load data from a file
  • import (1) import program code from file
  • openfile (1) open a file with specified name, return a handle
  • closefile (1) close a file given by a handle
  • print (2) print to a file
  • println (2) println to a file
  • setdirectory (1) set the current directory

Networking

Physics and Animations

Physics simulation

  • simulation (0) handle to simulation
  • force (1) probing force at a specific position
  • addforce (2) apply a force to a mass
  • setforce (2) set the force of a mass to a specific value

Animations

Other

Experimental and Undocumented Operators

Use of the following operators is at your own risk.

  • freevariables (1)
  • java (1)
  • curview (0)
  • curkernel (0)
  • curgraphalgorithm (0)
  • attribute (2) read user attribute
  • attribute (3) set user attribute
  • inspectinfo (2) information on attribute
  • createmass (3) create a mass-point with name and position and velocity (currently not supported)