maspack.matrix

## Class RigidTransform3d

• All Implemented Interfaces:
java.io.Serializable, DenseMatrix, LinearTransformNd, Matrix, VectorTransformer3d

```public class RigidTransform3d
extends AffineTransform3dBase```
A specialized 4 x 4 matrix that implements a three-dimensional rigid body transformation in homogeneous coordinates.

A rigid body transformation is used to transform a point from one spatial coordinate frame into another. If x0 and x1 denote the point in the orginal frame 0 and target frame 1, respectively, then the transformation is computed according to

``` x1 = R x0 + p
```
where R is a 3 x 3 rotation matrix and p is a translation vector. In homogenous coordinates, this operation can be represented as
``` [ x1 ]   [ R  p ] [ x0 ]
[    ] = [      ] [    ]
[  1 ]   [ 0  1 ] [  1 ]
```
The components p and R of the transformation represent the position and orientation of frame 0 with respect to frame 1. In particular, the translation vector p gives the origin position, while the columns of R give the directions of the axes.

If X01 is a transformation from frame 0 to frame 1, and X12 is a transformation from frame 1 to frame 2, then the transformation from frame 0 to frame 2 is given by the product

``` X02 = X12 X01
```
In this way, a transformation can be created by multiplying a series of sub-transformations.

If X01 is a transformation from frame 0 to frame 1, then the inverse transformation X10 is a transformation from frame 1 to frame 0, and is given by

```       [  T    T   ]
[ R   -R  p ]
X10 = [           ]
[ 0     1   ]
```

In this class, the fields R and p are exposed, and users can manipulate them as desired. For example, specifying a rotation using Euler angles would be done using the `setEuler` method in R. This allows us to minimize the number of methds in the RigidTransform3d class itself.

Note that for reasons of efficiency, rigid transforms do not perform scaling. If you want scaling as well, then you should use an `AffineTransform3d` object, perhaps with a code fragment such as this:

``` RigidTransform3d XR = RigidTransform3d();
AffineTransform3d XA = new AffineTransform3d();

XR.p.set (10, 20, 30); // for example
XR.R.setRpy (Math.PI, 0, 0);
XA.set (XR);
XA.applyScaling (1, 2, 3);
```
Serialized Form

• ### Nested classes/interfaces inherited from interface maspack.matrix.Matrix

`Matrix.Partition, Matrix.WriteFormat`
• ### Field Summary

Fields
Modifier and Type Field and Description
`static int` `AXIS_ANGLE_STRING`
Specifies a string representation of this transformation as a 7-tuple consisting of a translation vector followed by a rotation axis and the corresponding angle (in degrees).
`static RigidTransform3d` `IDENTITY`
Global identity transform.
`static int` `MATRIX_3X4_STRING`
Specifies a string representation of this transformation as a 3 x 4 matrix (i.e., with the 4th row ommitted).
`static int` `MATRIX_4X4_STRING`
Specifies a string representation of this transformation as a 4 x 4 matrix.
`Vector3d` `p`
Translation vector associated with this transformation.
`RotationMatrix3d` `R`
Rotation matrix associated with this transformation.
• ### Fields inherited from interface maspack.matrix.Matrix

`INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC`
• ### Constructor Summary

Constructors
Constructor and Description
`RigidTransform3d()`
Creates a new transformation initialized to the identity.
```RigidTransform3d(double px, double py, double pz)```
Creates a new transformation with the specified translation vector.
```RigidTransform3d(double px, double py, double pz, double roll, double pitch, double yaw)```
Creates a new transformation with the specified translation and rotation.
```RigidTransform3d(double px, double py, double pz, double ux, double uy, double uz, double ang)```
Creates a new transformation with the specified translation and rotation.
`RigidTransform3d(RigidTransform3d X)`
Creates a new transformation which is a copy of an existing one.
```RigidTransform3d(Vector3d p, AxisAngle axisAng)```
Creates a new transformation with the specified translation vector and rotation.
```RigidTransform3d(Vector3d p, RotationMatrix3d R)```
Creates a new transformation with the specified translation vector and rotation matrix.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`AffineTransform3dBase` `clone()`
`RigidTransform3d` `copy()`
Creates and returns a copy of this transformer.
`double` ```fit(java.util.List<Point3d> p, java.util.List<Point3d> q)```
Sets this rigid transform to one that provides the best fit of q to p in the least-squares sense: p ~ X q
`boolean` `invert()`
Inverts this transform in place.
`boolean` `invert(RigidTransform3d X)`
Inverts transform X and places the result in this transform.
`boolean` `isRigid()`
Returns `true` if this transformer implements a linear rigid transform.
`void` `mul(RigidTransform3d X)`
Post-multiplies this transformation by another and places the result in this transformation.
`void` ```mul(RigidTransform3d X1, RigidTransform3d X2)```
Multiplies transformation X1 by X2 and places the result in this transformation.
`void` ```mulAffineLeft(AffineTransform3dBase Xa, Matrix3d Sa)```
Premultiplies this transform by an affine transform, and places the rigid body component in this transform and the stretch and shear component in S.
`void` ```mulAffineLeft(AffineTransform3dBase Xa, RotationMatrix3d Ra)```
Premultiplies this transform by the rigid body component of an affine transform.
`void` `mulAxisAngle(AxisAngle axisAng)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed as an axis-angle, and places the result in this transformation.
`void` ```mulAxisAngle(double ux, double uy, double uz, double ang)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed as an axis-angle, and places the result in this transformation.
`void` ```mulEuler(double phi, double theta, double psi)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed by Euler angles, and places the result in this transformation.
`boolean` ```mulInverse(Vector4d vr, Vector4d v1)```
Multiplies the column vector v1 by the inverse of this transform and places the result in vr.
`void` ```mulInverseBoth(RigidTransform3d X1, RigidTransform3d X2)```
Multiplies the inverse of transformation X1 by the inverse of transformation X2 and places the result in this transformation.
`void` `mulRotation(RotationMatrix3d R2)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, and places the result in this transformation.
`void` `mulRotX(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the x axis, and places the result in this transformation.
`void` `mulRotY(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the y axis, and places the result in this transformation.
`void` `mulRotZ(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the z axis, and places the result in this transformation.
`void` ```mulRpy(double roll, double pitch, double yaw)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed by roll-pitch-yaw angles, and places the result in this transformation.
`void` ```mulXyz(double x, double y, double z)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure translation, and places the result in this transformation.
`void` `scan(ReaderTokenizer rtok)`
Reads the contents of this transformation from a ReaderTokenizer.
`void` `setRandom()`
Sets the elements of this matrix to uniformly distributed random values in the range -0.5 (inclusive) to 0.5 (exclusive).
`void` ```setRpy(double roll, double pitch, double yaw)```
Sets the rotation of the frame associated with this transform.
`void` ```setRpyDeg(double roll, double pitch, double yaw)```
Sets the rotation of the frame associated with this transform.
`void` ```setXyz(double x, double y, double z)```
Sets the origin of the frame associated with this transform.
`void` ```setXyzRpy(double x, double y, double z, double roll, double pitch, double yaw)```
Sets both the origin and rotation of the frame associated with this transform.
`void` ```setXyzRpyDeg(double x, double y, double z, double roll, double pitch, double yaw)```
Sets both the origin and rotation of the frame associated with this transform.
`java.lang.String` `toString()`
Returns a string representation of this transformation as a 4 x 4 matrix.
`java.lang.String` ```toString(NumberFormat numberFmt, int outputCode)```
Returns a specified string representation of this transformation, with each number formatted according to the a supplied numeric format.
`java.lang.String` `toString(java.lang.String numberFmtStr)`
Returns a string representation of this transformation as a 4 x 4 matrix, with each number formatted according to a supplied numeric format.
`java.lang.String` ```toString(java.lang.String numberFmtStr, int outputCode)```
Returns a specified string representation of this transformation, with each number formatted according to the a supplied numeric format.
• ### Methods inherited from class maspack.matrix.AffineTransform3dBase

`addTranslation, addTranslation, colSize, epsilonEquals, equals, get, get, getColumn, getColumn, getMatrix, getMatrixComponents, getOffset, getRow, getRow, inverseTransformCovec, inverseTransformPnt, inverseTransformVec, isAffine, isIdentity, mul, mul, mulInverse, mulInverse, mulInverseLeft, mulInverseRight, rowSize, set, set, set, setColumn, setIdentity, setRotation, setRotation, setRotation, setRow, setTranslation, setTranslation, transformCovec, transformPnt, transformVec`
• ### Methods inherited from class maspack.matrix.DenseMatrixBase

`add, checkConsistency, set, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix`
• ### Methods inherited from class maspack.matrix.MatrixBase

`containsNaN, determinant, epsilonEquals, equals, frobeniusNorm, frobeniusNormSquared, get, getCCSIndices, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, infinityNorm, isFixedSize, isSymmetric, isWritable, maxNorm, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, scan, setCRSValues, setDefaultFormat, setSize, toString, trace, write, write, write, write, write, write, write, writeToFile`
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Methods inherited from interface maspack.matrix.Matrix

`determinant, epsilonEquals, equals, frobeniusNorm, frobeniusNormSquared, getCCSIndices, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getCRSValues, getRow, getSize, getSubMatrix, infinityNorm, isFixedSize, isSymmetric, maxNorm, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, setSize, toString, trace, write, write, write`
• ### Field Detail

• #### AXIS_ANGLE_STRING

`public static final int AXIS_ANGLE_STRING`
Specifies a string representation of this transformation as a 7-tuple consisting of a translation vector followed by a rotation axis and the corresponding angle (in degrees).
Constant Field Values
• #### MATRIX_3X4_STRING

`public static final int MATRIX_3X4_STRING`
Specifies a string representation of this transformation as a 3 x 4 matrix (i.e., with the 4th row ommitted).
Constant Field Values
• #### MATRIX_4X4_STRING

`public static final int MATRIX_4X4_STRING`
Specifies a string representation of this transformation as a 4 x 4 matrix.
Constant Field Values
• #### R

`public final RotationMatrix3d R`
Rotation matrix associated with this transformation.
• #### p

`public final Vector3d p`
Translation vector associated with this transformation.
• #### IDENTITY

`public static final RigidTransform3d IDENTITY`
Global identity transform. Should not be modified.
• ### Constructor Detail

• #### RigidTransform3d

`public RigidTransform3d()`
Creates a new transformation initialized to the identity.
• #### RigidTransform3d

```public RigidTransform3d(Vector3d p,
RotationMatrix3d R)```
Creates a new transformation with the specified translation vector and rotation matrix.
Parameters:
`p` - translation vector
`R` - rotation matrix
• #### RigidTransform3d

```public RigidTransform3d(double px,
double py,
double pz)```
Creates a new transformation with the specified translation vector.
Parameters:
`px` - x translation coordinate
`py` - y translation coordinate
`pz` - z translation coordinate
• #### RigidTransform3d

```public RigidTransform3d(double px,
double py,
double pz,
double roll,
double pitch,
double yaw)```
Creates a new transformation with the specified translation and rotation.
Parameters:
`px` - x translation coordinate
`py` - y translation coordinate
`pz` - z translation coordinate
`roll` - roll angle (rotation about z axis, radians)
`pitch` - pitch angle (rotation about new y axis, radians)
`yaw` - yaw angle (rotation about new x axis, radians)
• #### RigidTransform3d

```public RigidTransform3d(double px,
double py,
double pz,
double ux,
double uy,
double uz,
double ang)```
Creates a new transformation with the specified translation and rotation.
Parameters:
`px` - x translation coordinate
`py` - y translation coordinate
`pz` - z translation coordinate
`ux` - x rotation axis coordinate
`uy` - y rotation axis coordinate
`uz` - z rotation axis coordinate
`ang` - angle of rotation about the axis (radians)
• #### RigidTransform3d

`public RigidTransform3d(RigidTransform3d X)`
Creates a new transformation which is a copy of an existing one.
Parameters:
`X` - transform to copy
• #### RigidTransform3d

```public RigidTransform3d(Vector3d p,
AxisAngle axisAng)```
Creates a new transformation with the specified translation vector and rotation.
Parameters:
`p` - translation vector
`axisAng` - axis-angle describing the rotation
• ### Method Detail

• #### setXyz

```public void setXyz(double x,
double y,
double z)```
Sets the origin of the frame associated with this transform. This is equivalent to setting the `p` field directly.
Parameters:
`x` - x origin coordinate
`y` - y origin coordinate
`z` - z origin coordinate
• #### setRpy

```public void setRpy(double roll,
double pitch,
double yaw)```
Sets the rotation of the frame associated with this transform. This is equivalent to setting the `R` field directly. The rotation is specified as a rotation `roll` about the z axis, followed by a rotation `pitch` about the y axis, followed by a rotation `yaw` about the x axis.
Parameters:
`roll` - rotation about the z axis (radians)
`pitch` - rotation about the y axis (radians)
`yaw` - rotation about the x axis (radians)
• #### setRpyDeg

```public void setRpyDeg(double roll,
double pitch,
double yaw)```
Sets the rotation of the frame associated with this transform. This is equivalent to `setRpy(double, double, double)`, only with the rotation angles specified in degrees instead of radians.
Parameters:
`roll` - rotation about the z axis (degrees)
`pitch` - rotation about the y axis (degrees)
`yaw` - rotation about the x axis (degrees)
• #### setXyzRpy

```public void setXyzRpy(double x,
double y,
double z,
double roll,
double pitch,
double yaw)```
Sets both the origin and rotation of the frame associated with this transform. This is equivalent to setting the `p` and `R` fields directly. The rotation is specified as a rotation `roll` about the z axis, followed by a rotation `pitch` about the y axis, followed by a rotation `yaw` about the x axis.
Parameters:
`x` - x origin coordinate
`y` - y origin coordinate
`z` - z origin coordinate
`roll` - rotation about the z axis (radians)
`pitch` - rotation about the y axis (radians)
`yaw` - rotation about the x axis (radians)
• #### setXyzRpyDeg

```public void setXyzRpyDeg(double x,
double y,
double z,
double roll,
double pitch,
double yaw)```
Sets both the origin and rotation of the frame associated with this transform. This is equivalent to `setXyzRpy(double, double, double, double, double, double)`, only with the rotation angles specified in degrees instead of radians.
Parameters:
`x` - x origin coordinate
`y` - y origin coordinate
`z` - z origin coordinate
`roll` - rotation about the z axis (degrees)
`pitch` - rotation about the y axis (degrees)
`yaw` - rotation about the x axis (degrees)
• #### mul

`public void mul(RigidTransform3d X)`
Post-multiplies this transformation by another and places the result in this transformation.
Overrides:
`mul` in class `AffineTransform3dBase`
Parameters:
`X` - transformation to multiply by
• #### mul

```public void mul(RigidTransform3d X1,
RigidTransform3d X2)```
Multiplies transformation X1 by X2 and places the result in this transformation.
Parameters:
`X1` - first transformation
`X2` - second transformation
• #### mulInverseBoth

```public void mulInverseBoth(RigidTransform3d X1,
RigidTransform3d X2)```
Multiplies the inverse of transformation X1 by the inverse of transformation X2 and places the result in this transformation.
Parameters:
`X1` - left-hand transformation
`X2` - right-hand transformation
• #### mulXyz

```public void mulXyz(double x,
double y,
double z)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure translation, and places the result in this transformation. If p2 is the translation vector of the second transformation, then this is the equivalent of adding R p2 to this transformations translation vector.
Parameters:
`x` - translation component of the second transformation
`y` - translation component of the second transformation
`z` - translation component of the second transformation
• #### mulRotX

`public void mulRotX(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the x axis, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`ang` - rotation about the x axis (in radians) for the second transform
• #### mulRotY

`public void mulRotY(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the y axis, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`ang` - rotation about the y axis (in radians) for the second transform
• #### mulRotZ

`public void mulRotZ(double ang)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation about the z axis, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`ang` - rotation about the z axis (in radians) for the second transform
• #### mulAxisAngle

```public void mulAxisAngle(double ux,
double uy,
double uz,
double ang)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed as an axis-angle, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`ux` - rotation axis x component
`uy` - rotation axis y component
`uz` - rotation axis z component
`ang` - rotation angle (in radians)
• #### mulAxisAngle

`public void mulAxisAngle(AxisAngle axisAng)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed as an axis-angle, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`axisAng` - axis-angle representation of the rotation
• #### mulRotation

`public void mulRotation(RotationMatrix3d R2)`
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2.
Parameters:
`R2` - rotation for the second transformation
• #### mulRpy

```public void mulRpy(double roll,
double pitch,
double yaw)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed by roll-pitch-yaw angles, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2. See `RotationMatrix3d.setRpy` for a description of roll-pitch-yaw angles.
Parameters:
`roll` - first angle (radians)
`pitch` - second angle (radians)
`yaw` - third angle (radians)
• #### mulEuler

```public void mulEuler(double phi,
double theta,
double psi)```
Post-multiplies this transformation by an implicit second transformation consisting of a pure rotation, expressed by Euler angles, and places the result in this transformation. If R2 is the rotation matrix of the second transformation, then this is the equivalent of multiplying R by R2. See `RotationMatrix3d.setEuler` for a complete description of Euler angles.
Parameters:
`phi` - first Euler angle (radians)
`theta` - second Euler angle (radians)
`psi` - third Euler angle (radians)
• #### mulInverse

```public boolean mulInverse(Vector4d vr,
Vector4d v1)```
Multiplies the column vector v1 by the inverse of this transform and places the result in vr.
Overrides:
`mulInverse` in class `AffineTransform3dBase`
Parameters:
`vr` - result vector
`v1` - vector to multiply
Returns:
false if this transform is singular
• #### invert

`public boolean invert()`
Inverts this transform in place.
Overrides:
`invert` in class `AffineTransform3dBase`
Returns:
true (transform is never singular)
• #### invert

`public boolean invert(RigidTransform3d X)`
Inverts transform X and places the result in this transform.
Parameters:
`X` - transform to invert
Returns:
true (transform is never singular)
• #### toString

`public java.lang.String toString()`
Returns a string representation of this transformation as a 4 x 4 matrix.
Overrides:
`toString` in class `MatrixBase`
Returns:
String representation of this matrix
`MatrixBase.toString(String)`
• #### toString

`public java.lang.String toString(java.lang.String numberFmtStr)`
Returns a string representation of this transformation as a 4 x 4 matrix, with each number formatted according to a supplied numeric format.
Specified by:
`toString` in interface `Matrix`
Specified by:
`toString` in interface `VectorTransformer3d`
Overrides:
`toString` in class `MatrixBase`
Parameters:
`numberFmtStr` - numeric format string (see `NumberFormat`)
Returns:
String representation of this vector
`NumberFormat`
• #### toString

```public java.lang.String toString(NumberFormat numberFmt,
int outputCode)```
Returns a specified string representation of this transformation, with each number formatted according to the a supplied numeric format.
Parameters:
`numberFmt` - numeric format
`outputCode` - desired representation, which should be either `AXIS_ANGLE_STRING`, `MATRIX_4X4_STRING`, or `MATRIX_3X4_STRING`
• #### mulAffineLeft

```public void mulAffineLeft(AffineTransform3dBase Xa,
Matrix3d Sa)```
Premultiplies this transform by an affine transform, and places the rigid body component in this transform and the stretch and shear component in S. More specifically, let this transform be originally described by
```        [  R0  p0  ]
this = [          ]
[   0   1  ]
```
and the affine transform be described by
```        [  A   pa  ]     [  Sa Ra   pa  ]
Xa =   [          ]  =  [              ]
[  0    1  ]     [    0      1  ]
```
where the A component of Xa is factored into Sa Ra using a left polar decomposition with sign adjustment to ensure that Ra is right-handed. Then we form the product
```           [  Sa Ra R0   Sa Ra p0 + pa  ]
Xa this = [                            ]
[      0            1        ]
```
and then set the rotation and translation of this transform to Ra R0 and Sa Ra p0 + pa.
Parameters:
`Xa` - affine transform to pre-multiply this transform by
`Sa` - optional argument to return stretch and shear.
• #### mulAffineLeft

```public void mulAffineLeft(AffineTransform3dBase Xa,
RotationMatrix3d Ra)```
Premultiplies this transform by the rigid body component of an affine transform. More specifically, let this transform be originally described by
```        [  R0  p0  ]
this = [          ]
[   0   1  ]
```
and the affine transform be described by
```        [  A   pa  ]     [  Sa Ra   pa  ]
Xa =   [          ]  =  [              ]
[  0    1  ]     [    0      1  ]
```
where the A component of Xa is factored into Sa Ra using a left polar decomposition with sign adjustment to ensure that Ra is right-handed. Then we form the product
```           [  Sa Ra R0   Sa Ra p0 + pa  ]
Xa this = [                            ]
[      0            1        ]
```
and then set the rotation and translation of this transform to Ra R0 and Sa Ra p0 + pa.
Parameters:
`Xa` - affine transform to pre-multiply this transform by
`Ra` - Rotational part of the affine transform
• #### scan

```public void scan(ReaderTokenizer rtok)
throws java.io.IOException```
Reads the contents of this transformation from a ReaderTokenizer. There are four allowed formats, each of which is delimited by square brackets.

The first format is a set of 7 numbers in which the first three numbers give the x, y, and z ccordinates of the translation vector, the next three numbers give the x, y, and z coordinates of a rotation axis, and the last number gives a rotation angle, in degrees, about that axis. For example,

``` [ 10 20 30  0 1 0 90 ]
```
defines a transformation with a translation of (10, 20, 30{) and a rotation of 90 degrees about the y axis.

The second format format is a set of 12 numbers describing the first three rows of the transformation matrix in row-major order. For example,

``` [ 0  -1  0  10
1   0  0  20
0   0  1  20 ]
```
defines a transformation with a translation of (10,20, 30) and a rotation of 90 degrees about the z axis.

The third format is a set of 16 numbers describing all elements of the transformation matrix in row-major order. The last four numbers, which represent the fourth row, are actually ignored and instead assumed to be 0, 0, 0, 1, in keeping with the structure of the transformation matrix. A transformation with a translation of (30, 40, 50) and a rotation of 180 degrees about the x axis would be represented as

``` [  1  0  0  30
0 -1  0  40
0  0 -1  50
0  0  0  1 ]
```

The fourth format consists of a series of simple translational or rotational transformation, which are the multiplied together to form the final transformation. The following simple transformations may be specified:

`trans` x y z
A translation with the indicated x, y, and z values;
`rotX` ang
A rotation of "ang" degrees about the x axis;
`rotY` ang
A rotation of "ang" degrees about the y axis;
`rotZ` ang
A rotation of "ang" degrees about the z axis;
`rotAxis` x y z ang
A rotation of "ang" degrees about an arbitrary axis parallel to x, y, and z.
For example, the string
``` [ rotX 45 trans 0 0 100 rot 1 1 0 90 ]
```
describes a transformation which the product of a rotation of 45 degrees about the y axis, a translation of 100 units along the z axis, and a rotation of 90 degrees about the axis (1, 1, 0).
Specified by:
`scan` in interface `Matrix`
Overrides:
`scan` in class `MatrixBase`
Parameters:
`rtok` - ReaderTokenizer from which to read the transformation. Number Parsing should be enabled
Throws:
`java.io.IOException` - if an I/O error occured or if the transformation description is not consistent with one of the above formats.
• #### setRandom

`public void setRandom()`
Description copied from class: `DenseMatrixBase`
Sets the elements of this matrix to uniformly distributed random values in the range -0.5 (inclusive) to 0.5 (exclusive).
Specified by:
`setRandom` in class `AffineTransform3dBase`
• #### copy

`public RigidTransform3d copy()`
Description copied from interface: `VectorTransformer3d`
Creates and returns a copy of this transformer.
Specified by:
`copy` in interface `VectorTransformer3d`
Specified by:
`copy` in class `AffineTransform3dBase`
Returns:
deep copy of transform
• #### clone

```public AffineTransform3dBase clone()
throws java.lang.CloneNotSupportedException```
Overrides:
`clone` in class `AffineTransform3dBase`
Throws:
`java.lang.CloneNotSupportedException`
• #### fit

```public double fit(java.util.List<Point3d> p,
java.util.List<Point3d> q)
throws ImproperSizeException```
Sets this rigid transform to one that provides the best fit of q to p in the least-squares sense: p ~ X q
Parameters:
`p` - set of target 3d points
`q` - set of input 3d points
Returns:
scale best fit scaling factor
Throws:
`ImproperSizeException`
• #### isRigid

`public boolean isRigid()`
Returns `true` if this transformer implements a linear rigid transform.
Specified by:
`isRigid` in interface `VectorTransformer3d`
Overrides:
`isRigid` in class `AffineTransform3dBase`