Script Coordinate System - Cinderella Documentation
Description: The user's guide to the Interactive Geometry Software Cinderella

Skip to content

# Script Coordinate System

## The Coordinate System of CindyScript

There is an important feature of CindyScript that immediately changes the appearance of drawings treated by the script in a controlled and global way. Usually the coordinate system of CindyScript is the same as the coordinate system of the geometric construction. However it is possible to transform the coordinate system by special operators. Then all drawing is performed with respect to this modified reference frame. Care has to be taken when using the transformations: if many of them are applied it may be difficult to determine, where an actual drawing is performed. In order to still make an easy use of the transformation operators CindyScript provides two operators `gsave` and `grestore`. Similar to PostScript like languages these operators push/pop the actual state of the drawing engine to a stack. This state contains (besides the graphical default appearance information) the present coordinate transformation. So a temporal use of coordinate systems may be enclosed by a `gsave()`...`grestore()` construction. We first introduce the operators and than give a combined example.

Caution: In the current version of Cinderella 2.6 the application of the transformations is not yet implemented for circles. For circles only euclidean transformations (rotations, translations, reflections, scalings) are supported. Affine and projective transformations will be provided in a later release.

#### Translating the coordinate system: `translate(<list>)`

Description: This operator assumes that `<list>` is of the form `[<real>,<real>]` and translates the drawing coordinate system by this vector.

#### Rotating the coordinate system: `rotate(<real>)`

Description: This operator takes a real number `<real>` and rotates the current drawing coordinate system by an angle determined by this number. The anlge is given in rad. If one wants to use angles in degree one can do this by the `°` operator (this operator multiplies a number by `pi/180`. So `rotate(30°)` rotates the coordinate system by 30°.

#### Scaling the coordinate system: `scale(<real>)`

Description: This operator takes a real number `<real>` and scales the current drawing coordinate system by this factor.

Examples: The following table shows the effect of applying diverse transformations before invoking a code that draws of a square with vertex coordiantes `[0,0],[0,1],[1,1],[1,0]`.

`translate([1,0]);` | `rotate(30°);` | `scale(2));`

The following table shows different combinations of transformations. The order of the operations may seem a little bit counterintuitive. It results from the fact that the operators transforms the coordinate system rather than the objects that are drawn.

| --- | --- | --- | | | | | | `translate([1,0]); rotate(30°);` | `rotate(30°); translate([-0.5,-0.5]);` | `rotate(30°); scale(2)); translate([-0.5,-0.5]);` |

Recursive or iterated application of transformations can lead to surprising effects. The picture below was generated by the following piece of code (assuming that `square` is a list of objects that draw the unit square).