Version 0.55.1

atrafo

Affine transformation data type.

Signatures

  •   identity()
  •   rotation( vector axis, float angle )
  •   rotation( vector onset, vector axis, float angle  )
  •   translation( vector offset )
  •   scaling( float scale )
  •   scaling( float scaleX, float scaleY, float scaleZ )
  •   scaling( vector onset, float scale )
  •   scaling( vector onset, float scaleX, float scaleY, float scaleZ )
  •   atrafo( matrix mat )

Details

Affine transformations are a set of space transformations that include most of the "typical" transformations like rotation, translation and scaling. The different specific constructors can be used to create atrafo objects that represent these operations (see first example below).

The identity() constructor (1) creates a neutral transformation. The rotation() constructors defines a rotation with an angle around a given axis vector that starts in the coordinate system origin (2) or in a given onset space point. Constructor (4) performs a translation along a given offset vector. The scaling constructors (5) and (7) perform a uniform scaling while constructors (6) and (8) scale into each coordinate axis individually. (7) and (8) take an onset space point defining the neutral point of the scaling. Constructor (9) creates a general affine transformation from a given matrix.

An affine transformation can always be expressed by its transformation matrix. From an atrafo object, this can be accessed as its tmatrix member.

Multiple affine transformations can be stacked together by using the << operator. This corresponds to the multiplication of the transformations' matrices. The result is therefore an affine transformation itself (see second example below).

Example

 make rotation( <[ 0.0, 0.0, 1.0 ]>, rad( 45 ) ) >> box()
 

Example

 atrafo t = rotation( <[ 0.0, 0.0, 1.0 ]>, rad( 45 ) ) >>
            scaling( 0.5 )
 echo( t )
 

Output

 atrafo(<[<[0.353553,-0.353553,0,0]>,<[0.353553,0.353553,0,0]>,<[0,0,0.5,0]>]>) 

Casts To

string
modifier

Members

matrix tmatrix

Allows to read/write the transformation matrix of the affine transformation.

Parameters

axis

Vector that determines the rotation axis.

angle

The rotation angle (in rad). The rotation is right handed for positive and left handed for negative values.

onset

Space point that acts as alternative origin for rotation or scaling transformations.

scale

Uniform scaling factor s. For |s| > 1 the transformation is enlarging, for |s| < 1 it is a shrinking transformation. Negative values flip the object.

scaleX

Scaling factor in X direction.

scaleY

Scaling factor in Y direction.

scaleZ

Scaling factor in Y direction.

mat

An three-row matrix that defines the affine transformation.

See also

🗙

Search results for