public class ScaledRigidTransform3d extends AffineTransform3dBase implements Clonable
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 original frame 0 and target frame 1, respectively, then the transformation is computed according to
x1 = s 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 ] [ s R p ] [ x0 ] [ ] = [ ] [ ] [ 1 ] [ 0 1 ] [ 1 ]
The inverse of such a transformation is given by by
[ T T ] (-1) [ R/s -R p/s ] A = [ ] [ 0 1 ]
In this class, the fields R, s, 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 methods in the
RigidTransform3d class itself.
Matrix.Partition, Matrix.WriteFormat
Modifier and Type | Field and Description |
---|---|
static int |
AXIS_ANGLE_STRING
Specifies a string representation of this transformation as an 8-tuple
consisting of a translation vector followed by a rotation axis and the
corresponding angle (in degrees) followed by the scale
|
static ScaledRigidTransform3d |
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.
|
double |
s
Scale factor associated with this transform
|
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
Constructor and Description |
---|
ScaledRigidTransform3d()
Creates a new transformation initialized to the identity.
|
ScaledRigidTransform3d(double px,
double py,
double pz)
Creates a new transformation with the specified translation vector.
|
ScaledRigidTransform3d(double px,
double py,
double pz,
double roll,
double pitch,
double yaw)
Creates a new transformation with the specified translation and rotation.
|
ScaledRigidTransform3d(double px,
double py,
double pz,
double ux,
double uy,
double uz,
double ang)
Creates a new transformation with the specified translation and rotation.
|
ScaledRigidTransform3d(ScaledRigidTransform3d X)
Creates a new transformation which is a copy of an existing one.
|
ScaledRigidTransform3d(Vector3d p,
AxisAngle axisAng)
Creates a new transformation with the specified translation vector and
rotation.
|
ScaledRigidTransform3d(Vector3d p,
RotationMatrix3d R)
Creates a new transformation with the specified translation vector and
rotation matrix.
|
Modifier and Type | Method and Description |
---|---|
ScaledRigidTransform3d |
copy()
Creates and returns a copy of this transformer.
|
void |
fit(java.util.ArrayList<Point3d> p,
java.util.ArrayList<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
|
RigidTransform3d |
getRigidPart(RigidTransform3d trans) |
void |
getRotation(RotationMatrix3d R) |
double |
getScale()
Returns the scale factor
|
void |
inverseTransformPnt(Vector3d pr,
Vector3d p0)
Applies an inverse transform to point
p0 and places the
result in pr . |
void |
inverseTransformVec(Vector3d vr,
Vector3d v0)
Applies an inverse transform to vector
v0 and places the
result in vr . |
boolean |
invert()
Inverts this transform in place.
|
boolean |
invert(ScaledRigidTransform3d X)
Inverts transform X and places the result in this transform.
|
void |
mul(ScaledRigidTransform3d X)
Post-multiplies this transformation by another and places the result in
this transformation.
|
void |
mul(ScaledRigidTransform3d X1,
ScaledRigidTransform3d X2)
Multiplies transformation X1 by X2 and places the result in this
transformation.
|
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.
|
void |
mulInverse(ScaledRigidTransform3d X)
Post-multiplies this transformation by the inverse of transformation X 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(ScaledRigidTransform3d X1,
ScaledRigidTransform3d X2)
Multiplies the inverse of transformation X1 by the inverse of
transformation X2 and places the result in this transformation.
|
void |
mulInverseLeft(ScaledRigidTransform3d X1,
ScaledRigidTransform3d X2)
Multiplies the inverse of transformation X1 by transformation X2 and
places the result in this transformation.
|
void |
mulInverseRight(ScaledRigidTransform3d X1,
ScaledRigidTransform3d X2)
Multiplies 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 |
scale(double s)
Post-multiplies this transform by a uniform scaling transform:
[ s I 0 ]
[ 0 1 ]
|
void |
scan(ReaderTokenizer rtok)
Reads the contents of this transformation from a ReaderTokenizer.
|
void |
set(AffineTransform3dBase A) |
void |
set(double[] vals)
Sets the elements of this matrix from an array of doubles.
|
void |
set(int i,
int j,
double value)
Sets a single element of this matrix.
|
void |
set(Matrix M)
Sets the size and values of this matrix to those of another matrix.
|
void |
setColumn(int j,
double[] values)
Sets a column of this matrix from an array of doubles.
|
void |
setRandom()
Sets the elements of this matrix to uniformly distributed random values in
the range -0.5 (inclusive) to 0.5 (exclusive).
|
void |
setRotation(AxisAngle axisAng)
Sets the matrix component of this affine transform to an explicit
rotation.
|
void |
setRotation(Quaternion quat)
Sets the matrix component of this affine transform to an explicit
rotation.
|
void |
setRotation(RotationMatrix3d R)
Sets the matrix component of this affine transform to an explicit
rotation.
|
void |
setRow(int j,
double[] values)
Set a row of this matrix from an array of doubles.
|
void |
setScale(double s)
Sets the scale factor to use in 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.
|
void |
transformCovec(Vector3d nr,
Vector3d n0)
Transforms a covector
c0 and places the result in
cr . |
void |
updateExternalComponents() |
void |
updateInternalMatrix() |
addTranslation, addTranslation, clone, colSize, epsilonEquals, equals, get, get, getColumn, getColumn, getMatrix, getMatrixComponents, getOffset, getRow, getRow, inverseTransformCovec, isAffine, isIdentity, isRigid, mul, mul, mul, mulInverse, mulInverse, mulInverseLeft, mulInverseRight, rowSize, setIdentity, setTranslation, setTranslation, transformPnt, transformVec
add, checkConsistency, 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 double s
public final Vector3d p
public static final ScaledRigidTransform3d IDENTITY
public ScaledRigidTransform3d()
public ScaledRigidTransform3d(Vector3d p, RotationMatrix3d R)
p
- translation vectorR
- rotation matrixpublic ScaledRigidTransform3d(double px, double py, double pz)
px
- x translation coordinatepy
- y translation coordinatepz
- z translation coordinatepublic ScaledRigidTransform3d(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 ScaledRigidTransform3d(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 ScaledRigidTransform3d(ScaledRigidTransform3d X)
X
- transform to copypublic void set(Matrix M)
DenseMatrixBase
set
in interface Matrix
set
in class DenseMatrixBase
M
- matrix whose size and values are copiedpublic void set(AffineTransform3dBase A)
set
in class AffineTransform3dBase
public void set(int i, int j, double value)
set
in interface DenseMatrix
set
in class AffineTransform3dBase
i
- element row indexj
- element column indexvalue
- element valuepublic void set(double[] vals)
(i,j)
is stored at location i*colSize()+j
.set
in interface DenseMatrix
set
in class AffineTransform3dBase
vals
- array from which values are copiedpublic void setColumn(int j, double[] values)
setColumn
in interface DenseMatrix
setColumn
in class AffineTransform3dBase
j
- column indexvalues
- array from which column values are copiedpublic void setRow(int j, double[] values)
setRow
in interface DenseMatrix
setRow
in class AffineTransform3dBase
j
- row indexvalues
- array from which the row is copiedpublic void mul(ScaledRigidTransform3d X)
X
- transformation to multiply bypublic void mul(ScaledRigidTransform3d X1, ScaledRigidTransform3d X2)
X1
- first transformationX2
- second transformationpublic void updateInternalMatrix()
public void updateExternalComponents()
public void mulInverse(ScaledRigidTransform3d X)
X
- right-hand transformationpublic void mulInverseRight(ScaledRigidTransform3d X1, ScaledRigidTransform3d X2)
X1
- left-hand transformationX2
- right-hand transformationpublic void mulInverseLeft(ScaledRigidTransform3d X1, ScaledRigidTransform3d X2)
X1
- left-hand transformationX2
- right-hand transformationpublic void mulInverseBoth(ScaledRigidTransform3d X1, ScaledRigidTransform3d X2)
X1
- left-hand transformationX2
- right-hand 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
- axis-angle 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 roll-pitch-yaw 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(ScaledRigidTransform3d 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 scan(ReaderTokenizer rtok) throws java.io.IOException
The first format is a set of 8 numbers in which the first three numbers give the x, y, and z coordinates of the translation vector, the next three numbers give the x, y, and z coordinates of a rotation axis, and the next number gives a rotation angle, in degrees, about that axis, and the final number gives the scale factor. For example,
[ 10 20 30 0 1 0 90 2.0]defines a transformation with a translation of (10, 20, 30), a rotation of 90 degrees about the y axis, and a scale of 2.0
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
rotX
ang
rotY
ang
rotZ
ang
rotAxis
x y z ang
scale
s
[ rotX 45 trans 0 0 100 rot 1 1 0 90 scale 2]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, a rotation of 90 degrees about the axis (1, 1, 0), and s scaling of 2
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 double getScale()
public void setScale(double s)
s
- scale factorpublic void scale(double s)
s
- scale factorpublic void setRotation(AxisAngle axisAng)
AffineTransform3dBase
setRotation
in class AffineTransform3dBase
axisAng
- axis-angle describing the rotationpublic void setRotation(Quaternion quat)
AffineTransform3dBase
setRotation
in class AffineTransform3dBase
quat
- quaternion describing the rotationpublic void setRotation(RotationMatrix3d R)
AffineTransform3dBase
setRotation
in class AffineTransform3dBase
R
- rotation matrixpublic void getRotation(RotationMatrix3d R)
public ScaledRigidTransform3d copy()
VectorTransformer3d
copy
in interface VectorTransformer3d
copy
in class AffineTransform3dBase
public void fit(java.util.ArrayList<Point3d> p, java.util.ArrayList<Point3d> q) throws ImproperSizeException
p
- set of target 3d pointsq
- set of input 3d pointsImproperSizeException
public RigidTransform3d getRigidPart(RigidTransform3d trans)
public void inverseTransformPnt(Vector3d pr, Vector3d p0)
p0
and places the
result in pr
.inverseTransformPnt
in interface VectorTransformer3d
inverseTransformPnt
in class AffineTransform3dBase
pr
- returns the transformed pointp0
- point to be transformedpublic void transformCovec(Vector3d nr, Vector3d n0)
c0
and places the result in
cr
. If a vector is transformed linearly according to
vr = A v0,then the covector will be transformed according to
-1 T cr = A c0,Normal vectors and gradients are generally transformed as covectors. In the case of normals, the application will need to normalize the result if this transformation is not rigid.
transformCovec
in interface VectorTransformer3d
transformCovec
in class AffineTransform3dBase
nr
- returns the transformed covectorn0
- normal to be transformedpublic void inverseTransformVec(Vector3d vr, Vector3d v0)
v0
and places the
result in vr
.inverseTransformVec
in interface VectorTransformer3d
inverseTransformVec
in class AffineTransform3dBase
vr
- returns the transformed vectorv0
- vector to be transformed