public class RigidTransform3d extends AffineTransform3dBase
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 + pwhere 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 X01In this way, a transformation can be created by multiplying a series of subtransformations.
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);
Matrix.Partition, Matrix.WriteFormat
Modifier and Type  Field and Description 

static int 
AXIS_ANGLE_STRING
Specifies a string representation of this transformation as a 7tuple
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.

INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
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.

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 leastsquares 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)
Postmultiplies 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)
Postmultiplies this transformation by an implicit second transformation
consisting of a pure rotation, expressed as an axisangle, and places the
result in this transformation.

void 
mulAxisAngle(double ux,
double uy,
double uz,
double ang)
Postmultiplies this transformation by an implicit second transformation
consisting of a pure rotation, expressed as an axisangle, and places the
result in this transformation.

void 
mulEuler(double phi,
double theta,
double psi)
Postmultiplies 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)
Postmultiplies this transformation by an implicit second transformation
consisting of a pure rotation, and places the result in this
transformation.

void 
mulRotX(double ang)
Postmultiplies 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)
Postmultiplies 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)
Postmultiplies 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)
Postmultiplies this transformation by an implicit second transformation
consisting of a pure rotation, expressed by rollpitchyaw angles, and
places the result in this transformation.

void 
mulXyz(double x,
double y,
double z)
Postmultiplies 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.

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
add, checkConsistency, set, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
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
public static final int AXIS_ANGLE_STRING
public static final int MATRIX_3X4_STRING
public static final int MATRIX_4X4_STRING
public final RotationMatrix3d R
public final Vector3d p
public static final RigidTransform3d IDENTITY
public RigidTransform3d()
public RigidTransform3d(Vector3d p, RotationMatrix3d R)
p
 translation vectorR
 rotation matrixpublic RigidTransform3d(double px, double py, double pz)
px
 x translation coordinatepy
 y translation coordinatepz
 z translation coordinatepublic RigidTransform3d(double px, double py, double pz, double roll, double pitch, double yaw)
px
 x translation coordinatepy
 y translation coordinatepz
 z translation coordinateroll
 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)public RigidTransform3d(double px, double py, double pz, double ux, double uy, double uz, double ang)
px
 x translation coordinatepy
 y translation coordinatepz
 z translation coordinateux
 x rotation axis coordinateuy
 y rotation axis coordinateuz
 z rotation axis coordinateang
 angle of rotation about the axis (radians)public RigidTransform3d(RigidTransform3d X)
X
 transform to copypublic void setXyz(double x, double y, double z)
p
field directly.x
 x origin coordinatey
 y origin coordinatez
 z origin coordinatepublic void setRpy(double roll, double pitch, double yaw)
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.roll
 rotation about the z axis (radians)pitch
 rotation about the y axis (radians)yaw
 rotation about the x axis (radians)public void setRpyDeg(double roll, double pitch, double yaw)
setRpy(double, double, double)
, only with the rotation angles specified in
degrees instead of radians.roll
 rotation about the z axis (degrees)pitch
 rotation about the y axis (degrees)yaw
 rotation about the x axis (degrees)public void setXyzRpy(double x, double y, double z, double roll, double pitch, double yaw)
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.x
 x origin coordinatey
 y origin coordinatez
 z origin coordinateroll
 rotation about the z axis (radians)pitch
 rotation about the y axis (radians)yaw
 rotation about the x axis (radians)public void setXyzRpyDeg(double x, double y, double z, double roll, double pitch, double yaw)
setXyzRpy(double, double, double, double, double, double)
, only
with the rotation angles specified in
degrees instead of radians.x
 x origin coordinatey
 y origin coordinatez
 z origin coordinateroll
 rotation about the z axis (degrees)pitch
 rotation about the y axis (degrees)yaw
 rotation about the x axis (degrees)public void mul(RigidTransform3d X)
mul
in class AffineTransform3dBase
X
 transformation to multiply bypublic void mul(RigidTransform3d X1, RigidTransform3d X2)
X1
 first transformationX2
 second transformationpublic void mulInverseBoth(RigidTransform3d X1, RigidTransform3d X2)
X1
 lefthand transformationX2
 righthand transformationpublic void mulXyz(double x, double y, double z)
x
 translation component of the second transformationy
 translation component of the second transformationz
 translation component of the second transformationpublic void mulRotX(double ang)
ang
 rotation about the x axis (in radians) for the second transformpublic void mulRotY(double ang)
ang
 rotation about the y axis (in radians) for the second transformpublic void mulRotZ(double ang)
ang
 rotation about the z axis (in radians) for the second transformpublic void mulAxisAngle(double ux, double uy, double uz, double ang)
ux
 rotation axis x componentuy
 rotation axis y componentuz
 rotation axis z componentang
 rotation angle (in radians)public void mulAxisAngle(AxisAngle axisAng)
axisAng
 axisangle representation of the rotationpublic void mulRotation(RotationMatrix3d R2)
R2
 rotation for the second transformationpublic void mulRpy(double roll, double pitch, double yaw)
RotationMatrix3d.setRpy
for a description of rollpitchyaw angles.roll
 first angle (radians)pitch
 second angle (radians)yaw
 third angle (radians)public void mulEuler(double phi, double theta, double psi)
RotationMatrix3d.setEuler
for a complete description of Euler angles.phi
 first Euler angle (radians)theta
 second Euler angle (radians)psi
 third Euler angle (radians)public boolean mulInverse(Vector4d vr, Vector4d v1)
mulInverse
in class AffineTransform3dBase
vr
 result vectorv1
 vector to multiplypublic boolean invert()
invert
in class AffineTransform3dBase
public boolean invert(RigidTransform3d X)
X
 transform to invertpublic java.lang.String toString()
toString
in class MatrixBase
MatrixBase.toString(String)
public java.lang.String toString(java.lang.String numberFmtStr)
toString
in interface Matrix
toString
in interface VectorTransformer3d
toString
in class MatrixBase
numberFmtStr
 numeric format string (see NumberFormat
)NumberFormat
public java.lang.String toString(java.lang.String numberFmtStr, int outputCode)
numberFmtStr
 numeric format string (see NumberFormat
)outputCode
 desired representation, which should be either
AXIS_ANGLE_STRING
,
MATRIX_4X4_STRING
, or
MATRIX_3X4_STRING
public java.lang.String toString(NumberFormat numberFmt, int outputCode)
numberFmt
 numeric formatoutputCode
 desired representation, which should be either
AXIS_ANGLE_STRING
,
MATRIX_4X4_STRING
, or
MATRIX_3X4_STRING
public void mulAffineLeft(AffineTransform3dBase Xa, Matrix3d Sa)
[ 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 righthanded. 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.
Xa
 affine transform to premultiply this transform bySa
 optional argument to return stretch and shear.public void mulAffineLeft(AffineTransform3dBase Xa, RotationMatrix3d Ra)
[ 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 righthanded. 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.
Xa
 affine transform to premultiply this transform byRa
 Rotational part of the affine transformpublic void scan(ReaderTokenizer rtok) throws java.io.IOException
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 rowmajor 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 rowmajor 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
rotX
ang
rotY
ang
rotZ
ang
rotAxis
x y z ang
[ 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).
scan
in interface Matrix
scan
in class MatrixBase
rtok
 ReaderTokenizer from which to read the transformation. Number Parsing
should be enabledjava.io.IOException
 if an I/O error occured or if the transformation description is not
consistent with one of the above formats.public void setRandom()
DenseMatrixBase
setRandom
in class AffineTransform3dBase
public RigidTransform3d copy()
VectorTransformer3d
copy
in interface VectorTransformer3d
copy
in class AffineTransform3dBase
public AffineTransform3dBase clone() throws java.lang.CloneNotSupportedException
clone
in class AffineTransform3dBase
java.lang.CloneNotSupportedException
public double fit(java.util.List<Point3d> p, java.util.List<Point3d> q) throws ImproperSizeException
p
 set of target 3d pointsq
 set of input 3d pointsImproperSizeException
public boolean isRigid()
true
if this transformer implements a linear
rigid transform.isRigid
in interface VectorTransformer3d
isRigid
in class AffineTransform3dBase