|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmaspack.matrix.MatrixObject
maspack.matrix.Matrix3dObject
maspack.matrix.RotationMatrix3d
A specialized 3 x 3 orthogonal matrix, with determinant 1, that described a three-dimensional rotation.
This is used to rotate a 3 dimensional vector from one coordinate frame into another. If v0 and v1 denote the vector in the orginal frame 0 and target frame 1, respectively, then the rotation is computed according to
v1 = R v0where R is the rotation matrix. The columns of R represent the directions of the axes of frame 0 with respect to frame 1.
If R01 is a rotation from frame 0 to frame 1, and R12 is a rotation from frame 1 to frame 2, then the rotation from frame 0 to frame 2 is given by the product
R02 = R12 R01In this way, a rotation can be created by multiplying a series of sub-rotations.
If R01 is a rotation from frame 0 to frame 1, then the inverse rotation R10 is a rotation from frame 1 to frame 0, and is given by the transpose of R.
| Field Summary | |
static int |
AXIS_ANGLE_STRING
Specifies a string representation of this rotation as a 4-tuple consisting of a rotation axis and the corresponding angle (in degrees). |
static int |
MATRIX_STRING
Specifies a string representation of this rotation as a 3 x 3 matrix. |
| Fields inherited from class maspack.matrix.Matrix3dObject |
m00, m01, m02, m10, m11, m12, m20, m21, m22 |
| Constructor Summary | |
RotationMatrix3d()
Creates a new rotation initialized to the identity. |
|
RotationMatrix3d(AxisAngle axisAng)
Creates a new rotation specified by a rotation about an axis. |
|
RotationMatrix3d(double ux,
double uy,
double uz,
double ang)
Creates a new rotation specified by a rotation about an axis. |
|
RotationMatrix3d(Quaternion quat)
Creates a new rotation specified by a quaternion. |
|
RotationMatrix3d(RotationMatrix3d R)
Creates a new rotation which is a copy of an existing one. |
|
| Method Summary | |
void |
getAxisAngle(AxisAngle axisAng)
Returns the axis-angle parameters corresponding to this rotation. |
double |
getAxisAngle(Vector3d axis)
Gets the rotation axis-angle representation for this rotation. |
void |
getEuler(double[] angs)
Gets the Euler angles corresponding to this rotation. |
void |
getRpy(double[] angs)
Gets the roll-pitch-yaw angles corresponding to this rotation. |
boolean |
invert()
Inverts this rotation in place. |
boolean |
invert(RotationMatrix3d R1)
Inverts rotation R1 and places the result in this rotation. |
static void |
main(java.lang.String[] args)
|
void |
mul(RotationMatrix3d R1)
Post-multiplies this rotation by another and places the result in this rotation. |
void |
mul(RotationMatrix3d R1,
RotationMatrix3d R2)
Multiplies rotation R1 by R2 and places the result in this rotation. |
void |
mulAxisAngle(AxisAngle axisAng)
Post-multiplies this rotation by an implicit second rotation expressed as an axis-angle, and places the result in this rotation. |
void |
mulAxisAngle(double ux,
double uy,
double uz,
double ang)
Post-multiplies this rotation by an implicit second rotation expressed as an axis-angle, and places the result in this rotation. |
void |
mulEuler(double phi,
double theta,
double psi)
Post-multiplies this rotation by an implicit second rotation described by Euler angles, and places the result in this rotation. |
void |
mulInverse(RotationMatrix3d R1)
Post-multiplies this rotation by the inverse of rotation R1 and places the result in this rotation. |
boolean |
mulInverse(Vector3d vr)
Multiplies the column vector vr by the inverse of this matrix and places the result back in vr. |
boolean |
mulInverse(Vector3d vr,
Vector3d v1)
Multiplies the column vector v1 by the inverse of this matrix and places the result in vr. |
void |
mulInverseBoth(RotationMatrix3d R1,
RotationMatrix3d R2)
Multiplies the inverse of rotation R1 by the inverse of rotation R2 and places the result in this rotation. |
void |
mulInverseLeft(RotationMatrix3d R1,
RotationMatrix3d R2)
Multiplies the inverse of rotation R1 by rotation R2 and places the result in this rotation. |
void |
mulInverseRight(RotationMatrix3d R1,
RotationMatrix3d R2)
Multiplies rotation R1 by the inverse of rotation R2 and places the result in this rotation. |
boolean |
mulInverseTranspose(Vector3d vr)
Multiplies vector vr by the inverse transpose of this matrix, in place. |
boolean |
mulInverseTranspose(Vector3d vr,
Vector3d v1)
Multiplies the column vector v1 by the inverse transpose of this matrix and places the result in vr. |
void |
mulRotX(double ang)
Post-multiplies this rotation by an implicit second rotation consisting of a rotation about the x axis, and places the result in this rotation. |
void |
mulRotY(double ang)
Post-multiplies this rotation by an implicit second rotation consisting of a rotation about the y axis, and places the result in this rotation. |
void |
mulRotZ(double ang)
Post-multiplies this rotation by an implicit second rotation consisting of a rotation about the z axis, and places the result in this rotation. |
void |
mulRpy(double roll,
double pitch,
double yaw)
Post-multiplies this rotation by an implicit second rotation expressed by roll-pitch-yaw angles, and places the result in this rotation. |
void |
negate()
Negates this rotation in place. |
void |
normalize()
Normalizes this rotation, so as to ensure that its its columns are orthonormal. |
void |
scan(java.io.StreamTokenizer stok)
Reads the contents of this rotation from a StreamTokenizer. |
void |
set(Quaternion q)
Sets this rotation to one represented by the quaternion q. |
void |
setAxisAngle(AxisAngle axisAng)
Sets this rotation to one produced by rotating about an axis. |
void |
setAxisAngle(double ux,
double uy,
double uz,
double ang)
Sets the rotation to one produced by rotating about an axis. |
void |
setEuler(double[] angs)
Sets this rotation to one produced by Euler angles. |
void |
setEuler(double phi,
double theta,
double psi)
Sets this rotation to one produced by Euler angles. |
void |
setRandom()
Sets this rotation to one produced by rotating about a random axis by a random angle. |
void |
setRandom(java.util.Random generator)
Sets this rotation to one produced by rotating about a random axis by a random angle, using a supplied random number generator. |
void |
setRotX(double ang)
Sets this rotation to one produced by rotating about the x axis. |
void |
setRotY(double ang)
Sets this rotation to one produced by rotating about the y axis. |
void |
setRotZ(double ang)
Sets this rotation to one produced by rotating about the z axis. |
void |
setRpy(double[] angs)
Sets this rotation to one produced by Euler angles. |
void |
setRpy(double roll,
double pitch,
double yaw)
Sets this rotation to one produced by roll-pitch-yaw angles. |
void |
setZDirection(Vector3d dirz)
Sets this rotation to one in which the z axis points in a specified direction. |
java.lang.String |
toString()
Returns a string representation of this transformation as a 3 x 3 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 3 x 3 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 |
transpose()
Transposes this rotation in place. |
void |
transpose(RotationMatrix3d R1)
Transposes rotation R1 and places the result in this rotation. |
| Methods inherited from class maspack.matrix.Matrix3dObject |
colSize, determinant, epsilonEquals, equals, frobeniusNorm, get, get, getColumn, getColumn, getRow, getRow, infinityNorm, mul, mul, mulTranspose, mulTranspose, oneNorm, rowSize, set, set, set, setColumn, setColumn, setIdentity, setRow, setRow |
| Methods inherited from class maspack.matrix.MatrixObject |
epsilonEquals, equals, equals, get, getColumn, getRow, isFixedSize, 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_STRING
| Constructor Detail |
public RotationMatrix3d()
public RotationMatrix3d(AxisAngle axisAng)
axisAng - gives the rotation axis and corresponding anglepublic RotationMatrix3d(Quaternion quat)
quat - quaternion specifying the rotation.
public RotationMatrix3d(double ux,
double uy,
double uz,
double ang)
ux - axis x coordinateuy - axis y coordinateuz - axis z coordinateang - angle of rotation about the axis (radians)public RotationMatrix3d(RotationMatrix3d R)
R - rotation to copy| Method Detail |
public void mul(RotationMatrix3d R1)
R1 - rotation to multiply by
public void mul(RotationMatrix3d R1,
RotationMatrix3d R2)
R1 - first rotationR2 - second rotationpublic void mulInverse(RotationMatrix3d R1)
R1 - right-hand rotation
public void mulInverseLeft(RotationMatrix3d R1,
RotationMatrix3d R2)
R1 - left-hand rotationR2 - right-hand rotation
public void mulInverseRight(RotationMatrix3d R1,
RotationMatrix3d R2)
R1 - left-hand rotationR2 - right-hand rotation
public void mulInverseBoth(RotationMatrix3d R1,
RotationMatrix3d R2)
R1 - left-hand rotationR2 - right-hand rotationpublic boolean invert()
invert in class Matrix3dObjectpublic boolean invert(RotationMatrix3d R1)
R1 - rotation to invertpublic void transpose()
transpose in class Matrix3dObjectpublic void transpose(RotationMatrix3d R1)
R1 - rotation to transposepublic void negate()
negate in class Matrix3dObject
public boolean mulInverse(Vector3d vr,
Vector3d v1)
mulInverse in class Matrix3dObjectvr - result vectorv1 - vector to multiply by
public boolean mulInverse(Vector3d vr)
mulInverse in class Matrix3dObjectvr - vector to multiply by (in place)
public boolean mulInverseTranspose(Vector3d vr,
Vector3d v1)
mulInverseTranspose in class Matrix3dObjectvr - result vectorv1 - vector to multiply by
public boolean mulInverseTranspose(Vector3d vr)
mulInverseTranspose in class Matrix3dObjectvr - vector to multiply
public void normalize()
public void set(Quaternion q)
q - quaternion representing the rotationpublic void setAxisAngle(AxisAngle axisAng)
axisAng - gives the rotation axis and corresponding angle
public void setAxisAngle(double ux,
double uy,
double uz,
double ang)
ux - axis x coordinateuy - axis y coordinateuz - axis z coordinateang - angle of rotation about the axis (radians)public void setRotX(double ang)
ang - angle of rotation (radians)public void mulRotX(double ang)
ang - angle (radians) for the second rotationpublic void setRotY(double ang)
ang - angle of rotation (radians)public void mulRotY(double ang)
ang - angle (radians) for the second rotationpublic void setRotZ(double ang)
ang - angle of rotation (radians)public void mulRotZ(double ang)
ang - angle (radians) for the second rotation
public 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 getAxisAngle(AxisAngle axisAng)
axisAng - axis-angle parameters
public void setRpy(double roll,
double pitch,
double yaw)
roll - first angle (radians)pitch - second angle (radians)yaw - third angle (radians)getRpy(double[])public void setRpy(double[] angs)
angs - contains the angles (roll, pitch,
and yaw, in that order) in radians.setRpy(double,double,double)
public void mulRpy(double roll,
double pitch,
double yaw)
roll - first angle (radians)pitch - second angle (radians)yaw - third angle (radians)public void getRpy(double[] angs)
angs - returns the angles (roll, pitch, and yaw,
in that order) in radians.setRpy(double,double,double)
public void setEuler(double phi,
double theta,
double psi)
phi - first Euler angle (radians)theta - second Euler angle (radians)psi - third Euler angle (radians)getEuler(double[])public void setEuler(double[] angs)
angs - contains the Euler angles (phi, theta,
and psi, in that order) in radians.setEuler(double,double,double)
public void mulEuler(double phi,
double theta,
double psi)
phi - first Euler angle (radians)theta - second Euler angle (radians)psi - third Euler angle (radians)setEuler(double,double,double)public void getEuler(double[] angs)
angs - returns the Euler angles (phi, theta, and psi,
in that order) in radians.setEuler(double,double,double)public void setZDirection(Vector3d dirz)
dirz - direction for the new z axispublic void setRandom()
public void setRandom(java.util.Random generator)
generator - random number generatorpublic double getAxisAngle(Vector3d axis)
axis - returns the rotation axis
public java.lang.String toString()
toString in class MatrixObjectpublic java.lang.String toString(java.lang.String numberFmtStr)
toString in class MatrixObjectnumberFmtStr - 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 or MATRIX_STRING
public java.lang.String toString(NumberFormat numberFmt,
int outputCode)
numberFmt - numeric formatoutputCode - desired representation, which should be either
AXIS_ANGLE_STRING or MATRIX_STRING
public void scan(java.io.StreamTokenizer stok)
throws java.io.IOException
The first format is a set of 4 numbers describing the rotation in axis-angle notation. The rotation axis is given first, followed by the rotation angle, in degrees. The axis does not need to be normalized. For example,
[ 0 1 0 90 ]defines a rotation of 90 degrees about the y axis.
The second format format is a set of 9 numbers describing the elements of the rotation matrix in row-major order. For example,
[ 0 -1 0 1 0 0 0 0 1 ]defines a rotation of 90 degrees about the z axis.
The third format consists of a series of simple rotations, which are the multiplied together to form a final rotation. The following simple rotations may be specified:
rotX ang
rotY ang
rotZ ang
[ rotX 45 rotZ 90 ]describes a rotation which is the product of a rotation of 45 degrees about the y axis and rotation of 90 degrees about the z axis.
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 MatrixObjectstok - StreamTokenizer from which to read the rotation
java.io.IOException - if an I/O error occured or if the rotation
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 | |||||||||