|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.MatrixBase
maspack.matrix.DenseMatrixBase
maspack.matrix.AffineTransform3dBase
maspack.matrix.ScaledRigidTransform3d
public class ScaledRigidTransform3d
A specialized 4 x 4 matrix that implements a three-dimensional rigid body transformation with scaling 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 = 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 ] [ sR 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface maspack.matrix.Matrix |
---|
Matrix.Partition, Matrix.WriteFormat |
Field Summary | |
---|---|
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 |
Fields inherited from interface maspack.matrix.Matrix |
---|
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
ScaledRigidTransform3d |
clone()
|
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 |
boolean |
invert()
Inverts this transform in place. |
boolean |
invert(ScaledRigidTransform3d X)
Inverts transform X and places the result in this transform. |
void |
leftRigidFactor(AffineTransform3d XS,
RigidTransform3d XR)
Factors this affine transform into the product of a stretch-shear transform (with no translation) and a rigid 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 |
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 |
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: [ sI 0 ] [ 0 1 ] |
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 |
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 |
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 |
updateInternalMatrix()
|
Methods inherited from class maspack.matrix.AffineTransform3dBase |
---|
colSize, epsilonEquals, equals, get, get, getColumn, getColumn, getMatrix, getMatrixComponents, getOffset, getRow, getRow, isIdentity, mul, mul, mulInverse, rowSize, set, set, set, setColumn, setIdentity, setRow, setTranslation |
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, get, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, setCRSValues, setDefaultFormat, setSize, toString, trace, 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, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getRow, getSize, getSubMatrix, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, setSize, toString, trace, write, write, write |
Field Detail |
---|
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
Constructor Detail |
---|
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 ScaledRigidTransform3d(Vector3d p, AxisAngle axisAng)
p
- translation vectoraxisAng
- axis-angle describing the rotationMethod Detail |
---|
public void mul(ScaledRigidTransform3d X)
X
- transformation to multiply bypublic void mul(ScaledRigidTransform3d X1, ScaledRigidTransform3d X2)
X1
- first transformationX2
- second transformationpublic void updateInternalMatrix()
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 multiply
public boolean invert()
invert
in class AffineTransform3dBase
public boolean invert(ScaledRigidTransform3d X)
X
- transform to invert
public java.lang.String toString()
toString
in class MatrixBase
MatrixBase.toString(String)
public java.lang.String toString(java.lang.String numberFmtStr)
toString
in class MatrixBase
numberFmtStr
- numeric format string (see 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)
[s0 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
[ s0 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. This transform's scale, s0, remains unchanged.
Xa
- affine transform to pre-multiply this transform bySa
- optional argument to return stretch and shear.public void leftRigidFactor(AffineTransform3d XS, RigidTransform3d XR)
this = XS XR
leftRigidFactor
in class AffineTransform3dBase
XS
- returns the stretch-shear transform (optional argument)XR
- returns the rigid transform (optional argument)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 enabled
java.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()
MatrixBase
public double getScale()
public void setScale(double s)
s
- public void scale(double s)
s
- public 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 clone()
clone
in interface Clonable
clone
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 points
ImproperSizeException
public RigidTransform3d getRigidPart(RigidTransform3d trans)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |