# Transformations

objTransform( Obj, Descrs )
Returns
<object> Transform an object given a set of transformations.
Obj
<object> The object to transform.
Descrs
<matDescr | arrayOf matDescr> A single matrix descriptor or an array of matrix descriptors to apply to the object.
Example:
```# Create a simple reference object
S: unitsphere;
# Translate 2.2 units in Y
S1: objTransform( S, tY( 2.2 ));
# Double the size of the sphere uniformly
S2: objTransform( S, sG( 2 ));
# Scale the sphere into a flat ellipse
S3: objTransform( S, sXYZ( .3, 3.2, 1 ));
# Rotate the ellipse by 90 degrees.
S4: objTransform( S3, rz( 90 ));
```
instance( Obj, Descrs )
Returns
<instance> Generate an instance of an object given a sequence of matrix descriptors.
Obj
<object> The object to instance.
Descrs
<matDescr | arrayOf matDescr> A single matrix descriptor or an array of matrix descriptors to apply to the object.
group( Objs )
Returns
<group> Generate an object which groups an array of objects together.
Objs
<arrayOf object> The array of objects to group.
Returns
<group> Generate an object which groups an object with a group.
Group
<group> A group of objects.
Obj
<object> The object to add to the group.
reflect( Obj, Line )
Returns
<object> Reflect the indicated object about Line.
Obj
<curve | line | point | vector> The geometric object to reflect.
Line
<line> Line to reflect about. There are predefined objects for the coordinate axes: Xaxis, Yaxis, and Zaxis.
Example:

```# Create an arc
Arc: arcThru3Pts( pt(1,-1), pt(0,1), pt(-1,-1) );
# Reflect it about the X-axis
RArc: reflect( Arc, Xaxis );
show( Arc, RArc );
```
reverseObj( Obj )
Returns
<object> Returns the reverse of an object.
Obj
<curve | line | shell | surface> The object to be reversed.
Example:
```# Make a cylinder
Cyl: rightCirCylinder( pt(0,0,0), vec(0,1,0), 1 );
# Since reverseObj doesn't take primitives, we convert to a shell
GeomCyl: makeGeom( Cyl );
# Now reverse the cylinder
ReverseCyl: reverseobj( GeomCyl );
# Translate so we can see both cylinders
TReverseCyl: objTransform( ReverseCyl, tx( 3 ) );
show( GeomCyl, TReverseCyl );
```
Now use tk3d or shape_edit to view the normal vectors of these two cylinders.
rotateX( Angle, Anchor )
or rX( Angle, Anchor )
Returns
<matDescr> Create a matrix to rotate about the X axis.
Angle
<number | curve> The angle in degrees to rotate, positive values rotate counter-clockwise.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
rotateY( Angle, Anchor )
or rY( Angle, Anchor )
Returns
<matDescr> Create a matrix to rotate about the Y axis.
Angle
<number | curve> The angle in degrees to rotate, positive values rotate counter-clockwise.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
rotateZ( Angle, Anchor )
or rZ( Angle, Anchor )
Returns
<matDescr> Create a matrix to rotate about the Z axis.
Angle
<number | curve> The angle in degrees to rotate, positive values rotate counter-clockwise.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
rotateQ( Quaternion, Anchor )
or rQ( Quaternion, Anchor )
Returns
<matDescr> Create a matrix representing a quaternion rotation. (W, (X, Y, Z))
Quaternion
<number, number, number, number | quatcurve> The quaternion that defines the orientation. Either W, X, Y, and Z can be given for a constant orientation or a quatcurve can be given to allow animation via interpolation.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
translateXYZ( OffsetX, OffsetY, OffsetZ, Anchor )
or tXYZ( OffsetX, OffsetY, OffsetZ, Anchor )
Returns
<matDescr> Create a matrix to translate by the given offsets.
OffsetX, OffsetY, OffsetZ
<number | curve> The offsets in the X, Y, and Z directions, respectively.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
translateX( Offset, Anchor )
or tX( Offset, Anchor )
Returns
<matDescr> Create a matrix to translate in the X direction.
Offset
<number | curve> The distance to translate.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
translateY( Offset, Anchor )
or tY( Offset, Anchor )
Returns
<matDescr> Create a matrix to translate in the Y direction.
Offset
<number | curve> The distance to translate.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
translateZ( Offset, Anchor )
or tZ( Offset, Anchor )
Returns
<matDescr> Create a matrix to translate in the Z direction.
Offset
<number | curve> The distance to translate.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
scaleUniform( Scale, Anchor )
or sG( Scale, Anchor )
Returns
<matDescr> Create a matrix to globally (uniformly) scale by the given factor.
Scale
<number | curve> The scaling factor to use.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
scaleXYZ( ScaleX, ScaleY, ScaleZ, Anchor )
or sXYZ( ScaleX, ScaleY, ScaleZ, Anchor )
Returns
<matDescr> Create a matrix to scale each axis by the given factors.
ScaleX, ScaleY, ScaleZ
<number | curve> The scale factor in the X, Y, and Z directions, respectively.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
scaleX( ScaleX, Anchor )
or sX( ScaleX, Anchor )
Returns
<matDescr> Create a matrix to scale in the X direction.
ScaleX
<number | curve> The X scale factor.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
scaleY( ScaleY, Anchor )
or sY( ScaleY, Anchor )
Returns
<matDescr> Create a matrix to scale in the Y direction.
ScaleY
<number | curve> The Y scale factor.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
scaleZ( ScaleZ, Anchor )
or sZ( ScaleZ, Anchor )
Returns
<matDescr> Create a matrix to scale in the Z direction.
ScaleZ
<number | curve> The Z scale factor.
Anchor(OriginAnchor)
<anchor> Optional argument. The anchor to serve as this transformations origin. If nothing is given then the transformation takes place about the global coordinate axis.
axisRotateWith( AlignType, Vec1, Vec2, Flag )
Returns
<matDescr> Create a matrix to align an axis with an vector, or vice-versa.
AlignType
<string> Axis-with type string, one of: "AXIS_X_WITH_Y", "AXIS_X_WITH_Z", "AXIS_Y_WITH_X", "AXIS_Y_WITH_Z", "AXIS_Z_WITH_X", or "AXIS_Z_WITH_Y".
Vec1, Vec2
<vector> The two vectors to align, according to the AlignType.
Flag
<boolean> Flag to specify the sense of the rotation. If true then rotate the specified axes into the given vectors. Otherwise rotate the given vectors into the specified axes.
genTran( a00, a01, ... a33 )
Returns
<matDescr> Create a 4x4 general transformation matrix.
a00, a01, ... a33
<number> The sixteen numbers in a 4x4 matrix, in row-major order.