|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.MatrixObject
maspack.matrix.AffineTransform3dObject
maspack.matrix.RigidTransform3d
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 + 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 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); object
Field Summary | |
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 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. |
Constructor Summary | |
RigidTransform3d()
Creates a new transformation initialized to the identity. |
|
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 | |
boolean |
invert()
Inverts this transform in place. |
boolean |
invert(RigidTransform3d X)
Inverts transform X and places the result in this transform. |
static void |
main(java.lang.String[] args)
|
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 |
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(RigidTransform3d 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(RigidTransform3d X1,
RigidTransform3d X2)
Multiplies the inverse of transformation X1 by the inverse of transformation X2 and places the result in this transformation. |
void |
mulInverseLeft(RigidTransform3d X1,
RigidTransform3d X2)
Multiplies the inverse of transformation X1 by transformation X2 and places the result in this transformation. |
void |
mulInverseRight(RigidTransform3d X1,
RigidTransform3d 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 |
scan(java.io.StreamTokenizer stok)
Reads the contents of this transformation from a StreamTokenizer. |
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.AffineTransform3dObject |
colSize, epsilonEquals, equals, get, get, getColumn, getMatrix, getOffset, getRow, mul, mul, mulInverse, rowSize, set, set, setColumn, setIdentity, setRotation, setRotation, setRotation, setRow, setTranslation |
Methods inherited from class maspack.matrix.MatrixObject |
determinant, epsilonEquals, equals, equals, frobeniusNorm, get, getColumn, getRow, infinityNorm, isFixedSize, oneNorm, set, set, setColumn, setRow, setSize, toString |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
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 final Vector3d p
Constructor Detail |
public RigidTransform3d()
public RigidTransform3d(Vector3d p, RotationMatrix3d R)
p
- translation vectorR
- rotation matrixpublic RigidTransform3d(RigidTransform3d X)
X
- transform to copypublic RigidTransform3d(Vector3d p, AxisAngle axisAng)
p
- translation vectoraxisAng
- axis-angle describing the rotationMethod Detail |
public void mul(RigidTransform3d X)
X
- transformation to multiply bypublic void mul(RigidTransform3d X1, RigidTransform3d X2)
X1
- first transformationX2
- second transformationpublic void mulInverse(RigidTransform3d X)
X
- right-hand transformationpublic void mulInverseRight(RigidTransform3d X1, RigidTransform3d X2)
X1
- left-hand transformationX2
- right-hand transformationpublic void mulInverseLeft(RigidTransform3d X1, RigidTransform3d X2)
X1
- left-hand transformationX2
- right-hand transformationpublic void mulInverseBoth(RigidTransform3d X1, RigidTransform3d 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 AffineTransform3dObject
vr
- result vectorv1
- vector to multiply
public boolean invert()
invert
in class AffineTransform3dObject
public boolean invert(RigidTransform3d X)
X
- transform to invert
public java.lang.String toString()
toString
in class MatrixObject
public java.lang.String toString(java.lang.String numberFmtStr)
toString
in class MatrixObject
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 scan(java.io.StreamTokenizer stok) 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 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
[ 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).
Note:This method disables numeric parsing in the StreamTokenizer. This is because the method does its own numeric parsing, in order to handle exponents.
scan
in class MatrixObject
stok
- StreamTokenizer from which to read the transformation
java.io.IOException
- if an I/O error occured or if the transformation
description is not consistent with one of the above formats.public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |