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 operatorif(3) if/else operatortrigger(2) trigger a function on value changewhile(2) while looprepeat(2) repeat loop with # run-variablerepeat(3) repeat loop with explicit run-variableforall(2) repeat loop with # run-variableforall(3) forall loop with explicit run-variableeval(1) force evaluation of an expression
Variable management¶
clear(0) clear all variablesclear(1) clear a specific variablekeys(1) list of local keys associated with an object or a variablecreatevar(1) create a local variableremovevar(1) destroy a local variableregional(arbitrary many arguments) create local variableslocal(arbitrary many arguments) create local variables (deprecated)release(arbitrary many arguments) remove local variables and return last value (deprecated)
Output¶
print(1) print a valueprintln(0) newlineprintln(1) print a value followed by newlineclearconsole(0) clear the output consoleerr(1) debugging printoutassert(2) conditional print for error checkingformat(2) convert a number to a string with specified precisionmessage(1) show a message in the status line
Calculations¶
Arithmetic functions¶
sqrt(1) square-rootexp(1) exponential functionlog(1) natural logarithmsin(1) sine functioncos(1) cosine functiontan(1) tangent functionarcsin(1) arcsine functionarccos(1) arccosine functionarctan(1) arctangent functionarctan2(1) binary arctangent functionarctan2(2) binary arctangent functionadd(2) additionsub(2) subtractionmult(2) multiplicationdiv(2) divisionmod(2) modulopow(2) powerabs(1) absolute valueround(1) rounded valuefloor(1) closest smaller integerceil(1) closest larger integerre(1) real partim(1) imaginary partconjugate(1) complex conjugaterandom(1) random real numberrandominteger(1) random integer numberrandom(0) random number between 0.0 and 1.0randombool(0) random boolean valuerandomnormal(0) (0,1)-normal distributed random real valueseedrandom(1) seed the random generator
Boolean functions¶
Predicates¶
isinteger(1) test for integerisreal(1) test for real numberiscomplex(1) test for complex numberiseven(1) test for even integerisodd(1) test for odd integerislist(1) test for listismatrix(1) test for nested list in matrix shapeisnumbervector(1) test for list which is a number vectorisnumbermatrix(1) test for list which is a number matrixisstring(1) test for stringisgeometric(1) test for geometric objectisselected(1) test for being selectedispoint(1) test for pointisline(1) test for lineiscircle(1) test for circleisconic(1) test for conicismass(1) test for massissun(1) test for sunisspring(1) test for springisundefined(1) test for being undefined
String functions¶
text(1) convert anything to a stringsubstring(3) substring of a string from start index to end indexreplace(3) replace all occurences of a substring by another stringreplace(2) apply several replacements given in a list of replacement pairstokenize(2) tokenize a string and return a list of tokensindexof(2) first index of a substringindexof(3) first index of a substring after positionlength(1) length of a stringformat(2) convert a number to a string with specified precisionsortsort elements from a list, can in particular be applied to lists of stringsfontfamilies(0) a list of all available fontsunicode(1) convert unicode into charactercandisplay(1) test if a string can be rendered by the current system and fontguess(1) convert a number to a string guessing the numbers meaningparse(1) convert string to CindyScript expression
Calculus¶
d(2) numerically differentiate a functiontangent(2) calculate the tangent to a functionguess(1) convert a number to a string guessing the numbers meaningpslq(1) same asguessroots(1) determine the roots of a polynomial
Lists and Linear Algebra¶
Elementary list operations¶
take(2) access the n-th element of a listlength(1) length of a listcontains(2) predicate for membershipappend(2) append an element to a listprepend(2) prepend an element to a listconcat(2) concatenate two listscommon(2) common elements of two listsremove(2) list difference
Traversing lists¶
forall(2) forall loop with # run-variableforall(3) forall loop with explicit run-variableapply(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 listtriples(1) list of all triples of elements of a listdirectproduct(2) direct product of two listsconsecutive(1) list of all pairs of consecutive elements of a listcycle(1) list of all pairs of consecutive elements of a list, cyclically closedreverse(1) reverse a listset(1) remove multiple instances of list elements, yielding a setsort(1) sort elements in a listsort(2) sort elements in a list by explicit functionflatten(1) flatten the nesting depth of a list
Lists of geometric objects¶
allelements(0) all elements of a constructionallpoints(0) all points of a constructionalllines(0) all lines of a constructionallsegments(0) all segments of a constructionallcircles(0) all circles of a constructionallconics(0) all concics of a constructionallmasses(0) all masses of a simulationallsprings(0) all springs of a simulation
Arithmetic list operations¶
sum(1) sum of all list elementssum(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 elementsproduct(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 elementsmin(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 elementsmax(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 lengthzeromatrix(2) create a zero matrix of specified lengthrowmatrix(1) convert a vector to a row matrixcolumnmatrix(1) convert a vector to a column matrixmatrixrowcolumn(1) number of rows and colums of a matrixrow(2) a specific row of a matrixcolumn(2) a specific column of a matrixsubmatrix(2) a specific minor of a matrixtranspose(1) transpose of a matrixdist(2) numerical value of the distance of two vectors.det(1) determinant of a square matrixhermiteanproduct(2) hermitian scalar productinverse(1) inverse of a square invertible matrixadj(1) adjunct of a square matrixeigenvalues(1) eigenvalues of a square matrixeigenvectors(1) eigenvectors of a square matrixlinearsolve(2) solve a system of linear equationsconvexhull3d(1) convex hull of a list of 3D points
Drawing¶
Drawing functions¶
draw(1) draw a pointdraw(2) draw a segmentdrawpoly(1) draw polygon border from pointlistdrawpolygon(1) same asdrawpolyfillpoly(1) draw filled polygon from pointlistfillpolygon(1) same asfillpolydrawcircle(2) draw a circle from center and radiusfillcircle(2) fill a circle from center and radiusdrawall(1) draw all elements in a listconnect(1) connect a list of pointsdrawtext(2) draw a stringdrawtable(2) draw a tablerepaint(0) force a repaint of the screenrepaint(1) force a repaint after a delay
Drawing appearance¶
pointsize(1) set point sizelinesize(1) set line sizetextsize(1) set text sizepointcolor(1) set point colorlinecolor(1) set line colortextcolor(1) set text colorcolor(1) set overall coloralpha(1) set overall alphagsave(0) store colors, alpha, width, clip, and transformation to stackgrestore(0) restore colors, alpha, width, clip and transformation from stackgreset(0) reset colors, alpha, width, clip and transformation. Reset stack
Color functions¶
red(1) red RGB-vectorgreen(1) green RGB-vectorblue(1) blue RGB-vectorgrey(1) grey RGB-vectorgray(1) gray RGB-vectorhue(1) hue RGB-vector
Function plotting¶
plot(1) plot a function with # run variableplot(2) plot a function with explicit run variablefillplot(1) plot a function with integral like highlightingfillplot(2) highlight the difference between two functionscolorplot(3) plot a region colored by the values of a functiondrawfield(1) draw the flux of a vector fielddrawfieldcomplex(1) draw the flux of a complex functiondrawforces(1) draw the flux of a force fielddrawcurves(2) draw an oscillograph for physicsmapgrid(1) mapping a rectangular grid
Pixelgraphics¶
drawimage(2) draw a pixelimage, w.r.t. one pointdrawimage(3) draw a pixelimage, w.r.t. two pointsdrawimage(4) draw a pixelimage, w.r.t. three pointsdrawimage(5) draw a pixelimage, w.r.t. four pointsmapimage(2) map a pixelimage, w.r.t. a functionimagesize(1) getting the size of an imageimagergb(3) inquiring the rgba value of a pixelcreateimage(3) create a pixelimage with name and specified sizeclearimage(1) erasing a pixelimageremoveimage(1) removing a pixelimagecanvas(3) using a pixelimage as canvas w.r.t. one pointcanvas(4) using a pixelimage as canvas w.r.t. two pointscanvas(5) using a pixelimage as canvas w.r.t. three points
Shapes¶
circle(2) create a circular shape from point and radiuspolygon(1) create a polygonal shape from a list of pointshalfplane(2) create a halfplane shapescreen(0) create a polygonal shape that covers the screenfill(1) fill a shapedraw(1) draw the outline of a shapeclip(1) set clippath to a shape
Geometric transformations¶
translate(1) translate the global coordinate systemrotate(1) rotate the global coordinate systemscale(1) scale the global coordinate systemsetbasis(1) set global coordinate system to a translation basissetbasis(2) set global coordinate system to a similarity basissetbasis(3) set global coordinate system to an affine basissetbasis(4) set global coordinate system to a projective basis
Layer¶
autoclearlayer(2) automatic clearing of layersclearlayer(1) clearing a layerclrscr(0) remove all drawings in a layerlayer(1) setting the drawing layerscreenbounds(0) determining screen boundsscreenresolution(0) determining screen resolution
Geometry¶
Geometric Functions¶
moveto(2) move point to positionmeet(2) intersection of two linesjoin(2) join of two pointsperp(1) perpendicular 2-dimensional vectorperp(2) perpendicular of line through pointperpendicular(2) perpendicular of line through pointpara(2) parallel of line through pointparallel(2) parallel of line through pointcross(2) cross-product of two 3-dimensional vectorsdist(2) distance of two pointsarea(3) area of triangle given by three pointsdet(3) determinant of matrix of three points in homogeneous coordinatescrossratio(4) cross-ratio of four pointscomplex(1) convert xy-point to complex numbergauss(1) convert complex number to xy-pointpoint(1) set the geometric type of a vector to pointline(1) setting the geometric type of a vector to linegeotype(1) retrieve the geometric type of a vectormap(2) obtain a transformation matrix for translationsmap(4) obtain a transformation matrix for similaritiesmap(6) obtain a transformation matrix for affine transformationsmap(8) obtain a transformation matrix for projective transformationspointreflect(1) obtain a transformation matrix for reflection in a pointlinereflect(1) obtain a transformation matrix for reflection in a lineincidences(1) list of incidences of a geometric objectlocusdata(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 elementremoveelement(1) delete a named geometric element and the dependent elements of italgorithm(1) Getting the construction algorithm of an elementinputs(1) Getting the defining objects of an elementelement(1) Getting a handle to an element
Sound¶
MIDI¶
playtone(1) playing a MIDI notestoptone(1) muting a MIDI noteplayfrequency(1) playing a MIDI note with specified freqeuncyplaymelody(1) playing a MIDI melody given by a list of notesmidiaddtrack(1) assigning a MIDI melody given by a list of notes to a trackmidistart(0) starting the MIDI tracksmidistop(0) halting the MIDI tracksmidispeed(1) setting the speed of the MIDI tracksmidispeed(0) getting the speed of the MIDI tracksmidiposition(1) setting the sound pointermidiposition(0) getting the sound pointerinstrument(1) specifying a MIDI instrumentinstrumentnames(0) list all available MIDI instrumentsmidichannel(1) setting the midi channelmidivolume(1) setting the midi volumemidicontrol(2) setting an arbitrary midi control value
Sampled Audio¶
playsin(1) play a periodic signalplayfunction(1) use a function to generate an audio sampleplaywave(1) use a list of numbers to generate an audio samplestopsound(0) stop all sample out lines
System functions¶
Mouse and key input¶
mover(0) last moved objectmouse(0) current mouse position in homogeneous coordinateselementsatmouse(0) lists all elements close to the current mouse positionkey(0) typed characteriskeydown(1) asks if a key is currently pressedkeydownlist(0) list of all kurrently pressed keysamsdata(0) data from a built-in gravity sensorcalibratedamsdata(0) data from a built-in gravity sensor after calibrationcreatetool(3) creating a custom toolbarremovetool(1) removing a tool from a custom toolbar
Time¶
resetclock(0) reset the internal clockseconds(0) seconds since last resetsimulationtime(0) time synchronized with simulationtime(0) current real-world timedate(0) current real-world datewait(1) wait for a specified number of milliseconds
File IO¶
setdirectory(1) set current directoryload(1) load data from a fileimport(1) import program code from fileopenfile(1) open a file with specified name, return a handleclosefile(1) close a file given by a handleprint(2) print to a fileprintln(2) println to a filesetdirectory(1) set the current directory
Networking¶
openurl(1) open a specified URL in a browserjavascript(1) calling javascriptopenconnection(2) open a TCP portprint(2) write to a TCP connectionprintln(2) write to a TCP connectionflush(1) flush output to a TCP portreadln(1) read from a TCP connectioncloseconnection(1) close a TCP connection
Physics and Animations¶
Physics simulation¶
simulation(0) handle to simulationforce(1) probing force at a specific positionaddforce(2) apply a force to a masssetforce(2) set the force of a mass to a specific value
Animations¶
playanimation(0) start the animationpauseanimation(0) pause the animationstopanimation(0) stop the animation
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 attributeattribute(3) set user attributeinspectinfo(2) information on attributecreatemass(3) create a mass-point with name and position and velocity (currently not supported)