Accessing Geometric Elements


Accessing Geometric Elements

The main communication between CindyScript and the geometry part of Cinderella is accomplished by accessing the geometric objects of a construction. Geometric elements can be accessed in two different ways: either one can access an element by the name of its label or one can access lists of elements by special CindyScript operators. The interaction between Cinderella and CindyScript gives CindyScript the possibility to read essentially all properties of the elements of a geometric construction. Most properties can also be set by CindyScript. The following sections first describe the possible ways to address geometric objects and then provide a detailed list of the supported properties.

Accessing Elements by Their Names

Every element in a geometric construction has a unique name, its label. This name can be used as a handle in CindyScript. Formally, in CindyScript the element plays the role of a predefined variable. The different properties can be read and set via the . operator (dot operator). For instance, the line of code


sets the size of point A in a construction to the value 20. If a point or a line is contained in an arithmetic operator without a dot operator, then it is automatically converted to a vector representing its position. Thus a point is converted into an [x,y] vector representing its two-dimensional coordinates. A line is converted to an [x,y,z] vector representing its homogeneous coordinates. However,if one intends to set the coordinates of a point, then one has to use the dot operator explicitly. If a handle to a geometric object is not used in an arithmetic expression, then it is still passed to the calculation as the geometric object. Since these concepts are a bit subtle, we will clarify them with a few examples.

Assume that A, B, and C are points in a Cinderella construction. The line


sets the point A to be the midpoint of B and C. These two points are contained in an arithmetic expression, and therefore they are immediately inverted to an [x,y] vector. Setting the position of point A has to be done by explicitly using the .xy property.

The following program sets the color of all three points to green:


In this code the point names are passed as handles to the list pts. Traversing the list with the forall operator puts this handles one after the other into the variable p, from which their color property is accessed.

Lists of Elements

Sometimes it is not necessary to access points individually by their name. In particular, this happens whenever one is interested in performing an operation on all points in a construction. This may happen, for instance, when one wants to calculate the convex hull of a point set. For this, CindyScript provides several operators that return lists of elements. For instance, the operator allpoints() returns a list of all points of a construction. We will demonstrate this with a very tiny example. The following program changes the color of the points depending on their position relative to the y-axis:


The following picture shows the application of the code to a random collection of points.

Working with lists of points

Properties of Geometric Objects

We now start with a complete description of all properties that are currently accessible via CindyScript. Every property is at least readable. For each property we list the type of value expected for the property, whether it is read only or also writeable, and a short description of its purpose. Possible property types are usually as follows:

  • real: a real number
  • int: an integer number
  • bool: either true or false
  • string: a sequence of characters
  • 2-vector: a two-dimensional vector
  • 3-vector: a three-dimensional vector
  • 3x3-matrix: a 3 by 3 matrix

Some properties, like the current position, are only writable for free objects. We mark this by the word "free" in the corresponding column.

Properties Common to All Geometric Objects

coloryes3-vectorThe (red, green, blue) color vector of the object
colorhsbyes3-vectorThe (hue, saturation, black) color vector of the object
isshowingyesboolWhether the object is shown (this is inherited by all elements that depend on the object)
visibleyesboolWhether the object is shown (not inherited by dependent objects)
alphayesrealThe opacity of the object (between 0.0 and 1.0)
labelledyesboolWhether the object shows its label
namenostringThe label of the object
captionyesstringA caption that may replace the name
traceyesboolWhether the object leaves a trace
tracelengthyesintThe length of the trace
selectedyesboolWhether the object is currently selected

Each geometric element has a unique name. the string that represents this name may be accessed by .name. So for instance returns the string "A". The name may not be identical with the caption of the element shown in the construction. If A.caption is the empty string the name is shown, otherwise the caption.

Properties of Points

xfreerealThe x-coordinate of the point
yfreerealThe y-coordinate of the point
xyfree2-vectorThe xy-coordinates of the point
coordfree2-vectorThe xy-coordinates of the point
homogfree3-vectorThe homogeneous coordinates of the point
anglefreerealApplies only to PointOnCircle objects. The angle of the point on the circle
sizeyesintThe size of the point (0..40)
imagerotyesrealA rotation angle if the point is equipped with an image

Properties of Lines

homogfree3-vectorThe homogeneous coordinates of the line
anglefreerealThe angle of the line
slopefreerealThe slope of the line
sizeyesintThe size of the line (0..10)

Properties of Circles and Conics

centernorealThe center of the circle
radiusfreerealThe radius of the circle
matrixnorealThe matrix describing the quadratic form of the circle or conic
sizeyesintThe size of the border line (0..10)

Properties of Texts

textyesstringThe content of the text
pressedyesbooleanThe state of this text if it is a button
xyyes2-vectorThe position of the text

Properties of Animations

runyesboolWhether the animation is running
speedyesrealThe relative animation speed

Properties of Transformations

matrixno3x3 matrixThe homogeneous matrix of the transformation
inverseno3x3 matrixThe homogeneous matrix of the inverse transformation

Properties of CindyLab Objects

It is not only geometric properties that can be accessed by CindyScript. The simulation parameters of CindyLab constructions can also be read and sometimes set via CindyScript.

Properties of All CindyLab Elements

simulateyesboolWhether the object takes part in the physics simulation or is neglected

Properties of Masses

massyesrealThe mass of the object
chargeyesintThe charge of the object
frictionyesrealThe individual friction of the object
radiusyesrealThe radius if the mass is treated as a ball
posxyesrealThe x-component of the mass's position
posyyesrealThe y-component of the mass's position
posyes2-vectorThe mass's position vector
vxyesrealThe x-component of the velocity
vyyesrealThe y-component of the velocity
vyes2-vectorThe velocity vector
fxnorealThe x-component of the force acting on the particle
fynorealThe y-component of the force acting on the particle
fno2-vectorThe force vector acting on the particle
kineticnorealThe kinetic energy of the particle
kenorealThe kinetic energy of the particle

Sometimes one is interested to add a user defined force potential between masses. This can be done by scripting a suitable piece of code in the Integeration Tick event. Since internally the position of masses has a finer time scale than usual geometric movements it is necessary to access their position via the pos, posx and posy accessors.

Properties of Springs and Coulomb Forces

lnorealThe current length of the spring
lrestnorealThe rest length of the spring
ldiffnorealThe distance to the rest length of the spring
strengthyesrealThe spring constant
fnorealThe force vector caused by the spring
amplitudeyesrealThe amplitude for actuation
speedyesrealThe speed for actuation
phaseyesrealThe phase for actuation (between 0.0 and 1.0)
potentialnorealThe potential energy in the spring
penorealThe potential energy in the spring

Property for Velocities

factoryesrealThe multiplication factor between graphical representation and actual velocity

Properties of Gravity

strengthyesrealThe strength of the gravity field
potentialnorealThe potential energy of all masses in the gravity field
penorealThe potential energy of all masses in the gravity field

Properties of Suns

massyesrealThe mass of the sun
potentialnorealThe potential energy of all masses in the sun field
penorealThe potential energy of all masses in the sun field

Properties of Magnetic Areas

strengthyesrealThe strength of the magnetic field
frictionyesrealThe friction in the magnetic area

Properties of Bouncers and Floors

xdampyesrealDamping in the x-direction
ydampyesrealDamping in the y-direction

Properties of the Environment

The environment can be accessed by the built-in operator simulation(). The following slots of the environment can be accessed:

gravityyesrealThe global gravity
frictionyesrealThe global friction
kineticnorealThe overall kinetic energy
kenorealThe overall kinetic energy
potentialnorealThe overall potential energy
penorealThe overall potential energy

Inspecting Elements

You can also use the generic CindyScript function inspect(<element>) to access all the attributes that are available in the Inspector. For example, if a point A exists in the construction, the function


will return the array of strings


Using the two-parameter form inspect(<element>,<string>) you can read all the attributes of A that are listed in the above array:




With the three-parameter form inspect(<element>,<string>,<expr>) you can also set the attributes that are not read-only (for example, you cannot change the list of incidences or the definition of an element). The following function will set the font of A to a Serif font:


The inspect command is very powerful, as you can automate all actions you normally would have to do in the Inspector using the mouse. Also, it gives you fine grained control over all properties.

Set a user attribute: attribute(<geo>,<string1>,<string2>)

Description: Sets the user attribute of <geo> identified by <string1> to the value <string2>.

Read a user attribute: attribute(<geo>,<string>)

Description: Returns the user attribute identified by <string> of the geometric element <geo> .

Both versions of the attribute function are mainly used for interaction with the Visage Extension.

Creating and Destroying Elements

Starting with Cinderella version 2.1 you can also create points on the fly from CindyScript. The function

p = createpoint("A",[4,6])

creates a point labelled A at coordinates [4,6], unless there is already an element A. If it exists, it will be moved to the position given as second argument. The value of the function is the point or the already existing element A. This means that repeated executions of the function are not harmful to your code - if you need a free point at "A" you can ensure that it exists using the createpoint-command.

Using the removeelement function you can also remove elements from your construction. Be aware that all dependent elements will be removed as well. The function expects an element as argument, so you can use either




to remove the element named "A".

More functions to create arbitrary elements are also available and discussed in the section section on special operators.

Contributors to this page: Kortenkamp , Richter and Kohler .
Page last modified on Monday 05 of September, 2011 [09:01:26 UTC] by Kortenkamp.

The content on this page is licensed under the terms of the License.

free viagra samplehentai girlsmature pussymilfseeker cialis samplescam clip movie nude webcammother incest order viagra online cialis ukanime rapeparis hilton phone numbers viagra alternatives cialis forum cialis free samplehot girls in pantiesmonster of cocks discount cialis cilias free viagra samplesfree chat rooms cilia structurefree cartoon sex comics buy cialis order viagrafree adult videosplump girl gallerypantyhose gallerycum on her face cheapest cialisbisexual moviestampa bukakehuge black cock thumbnails buy cialis onlineporn star cialis drugwomen having sex cheap generic viagra alternative to viagra natural viagra cheap viagraoral sexteen webcam strip videosnude spanish girlserotic sex cams movies viagra side effectscartoon adultdisney sex animenude blonde hairygang bang swinger cialis viagrabisexual free moviesgay twinkswebcam chat live xxxyoung teens order cialislatina girls thongscum loversjapanese girl viagra cheapyoung japanese girlsmr chews asian beavergangbang squadshoshone indiansmature wiveslive webcam chat girlsfree ebony viagra on lineasian ladyboysteen boys viagra pillsself bondage techniques cailisincest familyfree ebony cheap cialisgay amateur cialis genericbusty asian viagra onlinemature breasts viagra for women free viagrabig boobies cialis generic viagragloryhole gaylatinas in thongs female viagraindian tits viagra 6 free samplesamateur upskirt viagra alternativefree xxx video cialis online discountgalleries of teen girls cialis dosage cheap generic cialisparis hilton pornopussy cat dollsbrutal sexgay peopleblack milfsno tits discount viagrablonde hairy pussyshemale animefree hardcore moviesmom strips for sonfat titscelebrity legsdouble anal levitra vs cialis cialis tadalafil cialis cheapgay bdsmcelebrities exposed viagra generic alternatives to viagra viagra canadabestialitypink porn stars viagra jokesclips of teen sexchicks suck horse cock online viagrasex with horsespainful analglory holes floridafree american bukkake cialis online buy viagrabig cock cum free cialisteen gay porn cialis side effects herbal viagra best price viagra purchase cialis cialis soft tabs cialis vs viagrafree fat girl webcamfree porn movie clipsoral penis suckingebony hardcore viagra pricepantyhose crossed legs cialis and levitralesbiennesblonde boobs buy viagra online