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. You can also 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. In contrast to the translate and rotate operations, the parameter values are not added but overwritten. Note that the size operation sets the size in absolute values (for example, meters or yards) and does not perform a relative scaling.
  • center(axes)—Translates the scope of the current shape so that its center corresponds to the center of the scope of the previous shape on the shape stack, according to the axes. The latter determines in which axis direction (of the previous shape on the shape stack) the translation is performed.

Relative operator

For the t() and s() operations, you can 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 the following:

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 ', and 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 and 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 you 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; in other words, the rotation changes the global translation direction.
  • The relative operator ' is used—in this example, 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-axis

See the t operation, s operation, r operation, and center operation topics in the CGA reference for more details.