Transformation

The following transformations are available to modify the scope of the current shape:

  • t(tx, ty, tz) — translates the scope's position along the scope axes.
  • r(rx, ry, rz) — rotates the scope around its origin by adding rx, ry and rz to the scope's rotation vector scope.r. It is also possible to rotate around the scope center by writing r(scopeCenter, rx, ry, rz).
  • s(sx, sy, sz) — sets the scope's size to the values of sx, sy and sz. Hence, in contrast to the translate and rotate operations, the parameter values are not added but overwritten. Furthermore, note that the size operation sets the size in absolute values (e.g., meters or yards) and does not perform a relative scaling.
  • center(axes-Selector) — translates the scope of the current shape such that its center corresponds to the center of the scope of the previous shape on the shape stack, according to the axes-Selector. The latter determines in which axis directions (of the previous shape on the shape stack) the translation is performed.

Relative operator

For the t() and s() operations it is possible to conveniently transform the absolute values tx,ty,tz or sx,sy,sz to values relative to the scope size using the operator '.

s('0.5, '1, '1)
t('2, 0, '3)

This is equal to:

s(0.5*scope.sx, 1*scope.sy, 1*scope.sz)
t(2*scope.sx, 0*scope.sy, 3*scope.sz)

Examples

Setting the size

The extruded Lot is set to an absolute size of 5 units in all three dimensions.

Lot --> extrude(10)
        s(5, 5, 5)
Extruded lot set to an absolute size of 5 units in three dimensions

Relative resizing and center

The scope is first sized down by using the s() operation in conjunction with the relative operator ', then centered (relative to the scope of the Lot shape) and finally extruded to a 3D geometry.

Lot --> s('0.8, '1, '0.8) 
        center(xz) 
        extrude(20)
Scope sized down then extruded to 3D geometry

Rotation and center

Each split shape is first rotated around its scope origin and then centered.

Lot -->
   extrude(18)
   split(y) { 
      2 : r(0, 360*split.index/split.total, 0)
          center(xyz) X.
   }*

Using

r(scopeCenter, 0, 360*split.index/split.total, 0)

instead of the r() center() sequence gives the same result.

Each split shape rotated around its scope origin and then centered

Translate - Rotation concatenation

This is the shape we start with.

A --> primitiveCube()
Start shape

First a translation of two units along the x-axis.

A --> primitiveCube()
      t(2, 0, 0)
Translation of two units along the x-axis

Then a rotation of 30 degrees around the y-axis.

A --> primitiveCube() 
      t(2, 0, 0) 
      r(0, 30, 0)
Rotation of 30 degrees around the y-axis

And another translation of 2 units along the x-axis:

  • translations are along the scope's x-axis, i.e. the rotation changes the global translation direction.
  • the relative operator ' is used - here it does not make a difference because scope.sx is 1

A --> primitiveCube() 
      t(2, 0, 0) 
      r(0, 30, 0) 
      t('2, 0, 0)
Translation of 2 units along the x-axi

See the t operation, s operation, r operation, and center operation in the CGA reference for further detail.