atrafo
Affine transformation data type.
Signatures
- identity()
- translation( vector offset )
- rotation( vector axis, float angle )
- rotation( vector onset, vector axis, float angle )
- 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 class of transformations that include translation, rotation, scaling, and their combinations. They preserve points, straight lines, and planes. Parallel lines remain parallel after an affine transformation.
The `atrafo` data type encapsulates these transformations and allows for their application to geometric entities within trCAD. Transformations can be combined sequentially using the `>>` operator, which corresponds to matrix multiplication of their respective transformation matrices.
Several different constructors are available for creating `atrafo` objects. The identity constructor (1) creates a neutral transformation. The translation constructor (2) performs a translation along a given offset vector. The rotation constructors define rotations with an angle around a given axis vector that starts in the coordinate system origin (3) or in a given onset space point (4). 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. The general affine transformation constructor (9) creates a general affine transformation from a given matrix.
Each transformation can be represented by a 3x4 transformation matrix, which can be accessed through the `tmatrix` member of the `atrafo` object.
Example
make rotation( <[0.0, 0.0, 1.0]>, rad( 45 ) ) >> box()
Applies a 45-degree rotation around the Z-axis to a 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]>]>)
Outputs the transformation matrix of a combined rotation and scaling transformation.
Casts To
- ref_dtype_string
-
- ref_dtype_modifier
-
Members
- matrix tmatrix
-
Accesses the transformation matrix of the affine transformation.
Optional Open Parameter Attributes
- bool readonly
-
Tells the user interface or frontend to disable the setting of the open parameter.
- string style
-
Specifies some limited styling instructions for the user interface or frontend.
Parameters
- axis
-
The vector defining the axis of rotation.
- angle
-
The angle of rotation in radians.
- onset
-
The point that remains fixed during rotation or scaling.
- scale
-
The uniform scaling factor.
- scaleX
-
The scaling factor along the X-axis.
- scaleY
-
The scaling factor along the Y-axis.
- scaleZ
-
The scaling factor along the Z-axis.
- mat
-
A 3x4 matrix defining the affine transformation.