public class GTransform extends java.lang.Object implements javolution.lang.ValueType, java.lang.Cloneable, javolution.xml.XMLSerializable
GeomPoint
objects.
Modified by: Joseph A. Huwaldt
Modifier and Type | Field and Description |
---|---|
static GTransform |
IDENTITY
The identity matrix containing ones along the diagonal.
|
static GTransform |
ZERO
A matrix containing all zero elements.
|
Modifier and Type | Method and Description |
---|---|
GTransform |
applyRotation(Matrix<Float64> m1)
Return a new transformation matrix that is identical to this one, but with the
rotational components replaced with those in the specified direction cosine matrix.
|
GTransform |
applyRotationScale(Matrix<Float64> m1)
Return a new transformation matrix with the upper-left 3x3 portion of this matrix
(rotation and scaling) replaced by the specified values.
|
GTransform |
applyScale(double scale)
Return a new transformation matrix that is identical to this one, but with the
specified uniform scale factor applied.
|
GTransform |
applyScale(Float64Vector scale)
Return a new transformation matrix that is identical to this one, but with the
specified set of three scale factors applied in each axis (X,Y,Z).
|
GTransform |
applyTranslation(Float64Vector trans)
Return a new transformation matrix that is identical to this one, but with the
translation components replaced by the specified values.
|
GTransform |
applyTranslation(Vector<Length> trans)
Return a new transformation matrix that is identical to this one, but with the
translation components replaced by the specified values.
|
java.lang.Object |
clone()
Returns a copy of this GTransform instance
allocated by the calling thread
(possibly on the stack). |
GTransform |
copy()
Returns a copy of this matrix allocated by the calling thread (possibly on the
stack).
|
Float64 |
determinant()
Returns the determinant of this matrix.
|
boolean |
equals(java.lang.Object obj)
Compares this GTransform against the specified object for strict equality (same
values).
|
Float64 |
get(int i,
int j)
Returns a single element from this matrix.
|
Float64Vector |
getColumn(int j)
Returns the column identified by the specified index in this matrix.
|
Float64Vector |
getDiagonal()
Returns the diagonal vector.
|
Float64Matrix |
getFloat64Matrix()
Return the transformation matrix that represents this GTransform object as a
Float64Matrix.
|
double[][] |
getMatrix()
Return the transformation matrix that represents this GTranfrom object as a 2D Java
matrix.
|
int |
getNumberOfColumns()
Returns the number of columns for this matrix.
|
int |
getNumberOfRows()
Returns the number of rows for this matrix.
|
DCMatrix |
getRotation()
Returns a direction cosine matrix containing the rotational portion of this
transformation matrix.
|
Matrix<Float64> |
getRotationScale()
Returns the upper 3x3 values of this matrix (which contains combined rotation and
scale information) and places them into the output matrix.
|
Float64Vector |
getRow(int i)
Returns the row identified by the specified index in this matrix.
|
double |
getScale()
Returns the uniform scale factor for this matrix.
|
Float64Vector |
getScaleVector()
Returns a 3 element vector containing the scale factors in each dimension X, Y & Z.
|
Vector<Length> |
getTranslation()
Returns the translational components of this transformation matrix.
|
double |
getValue(int i,
int j)
Returns a single element from this matrix as a
double . |
int |
hashCode()
Returns the hash code for this GTransform object.
|
GTransform |
inverse()
Returns the inverse of this matrix.
|
static void |
main(java.lang.String[] args)
Tests the methods in this class.
|
static GTransform |
newRotationX(Parameter<Angle> angle)
Return a transformation matrix representing a counter-clockwise or right-handed
rotation about the X axis (when looking down the X-axis).
|
static GTransform |
newRotationY(Parameter<Angle> angle)
Return a transformation matrix representing a counter-clockwise or right-handed
rotation about the Y axis (when looking down the Y-axis).
|
static GTransform |
newRotationZ(Parameter<Angle> angle)
Return a transformation matrix representing a counter-clockwise or right-handed
rotation about the Z axis (when looking down the Z-axis).
|
static GTransform |
newScale(double scale)
Returns a transformation matrix representing a scale matrix with a uniform scale
factor applied to each dimension.
|
static GTransform |
newTranslation(double transX,
double transY,
double transZ)
Returns a transformation matrix representing a translation matrix.
|
static GTransform |
newTranslation(Float64Vector trans)
Returns a transformation matrix representing a translation matrix.
|
static GTransform |
newTranslation(GeomVector<Length> vector)
Returns a transformation matrix representing a translation matrix.
|
static GTransform |
newTranslation(Parameter<Length> transX,
Parameter<Length> transY,
Parameter<Length> transZ)
Returns a transformation matrix representing a translation matrix.
|
GTransform |
times(GTransform that)
Returns the product of this matrix with the one specified.
|
java.lang.String |
toString()
Returns a string representation of this matrix.
|
javolution.text.Text |
toText()
Returns the text representation of this matrix.
|
Point |
transform(GeomPoint p)
Transform the input point by multiplying it times this general transformation
matrix.
|
GTransform |
transpose()
Returns the transpose of this matrix.
|
static GTransform |
valueOf(double diagX,
double diagY,
double diagZ,
double diagW)
Returns a transformation matrix holding the specified diagonal vector with zeros
placed in all the other elements.
|
static GTransform |
valueOf(Float64Vector row0,
Float64Vector row1,
Float64Vector row2,
Float64Vector row3)
Returns a transformation matrix holding the specified row vectors.
|
static GTransform |
valueOf(GeomVector srcAxis,
GeomVector destAxis)
Returns a
GTransform instance representing the transformation from one axis
direction directly to another. |
static GTransform |
valueOf(java.util.List<Float64Vector> rows)
Returns a transformation matrix holding the row vectors from the specified list.
|
static GTransform |
valueOf(Matrix<Float64> matrix)
Returns a
GTransform instance containing a copy of the specified matrix of
Float64 values. |
static GTransform |
valueOf(Matrix<Float64> dcm,
double scale,
Vector<Length> trans)
Returns a
GTransform instance containing the specified direction cosine
rotation matrix, uniform scale factor, and translation vector. |
static GTransform |
valueOf(Rotation rotation)
Returns a
GTransform instance containing a copy of the specified rotation
transformation. |
static GTransform |
valueOf(Rotation rotation,
double scale,
Vector<Length> trans)
Returns a
GTransform instance containing the specified rotation
transformation, uniform scale factor, and translation vector. |
Float64Vector |
vectorization()
Returns the vectorization of this matrix.
|
public static final GTransform ZERO
public static final GTransform IDENTITY
public static GTransform valueOf(Float64Vector row0, Float64Vector row1, Float64Vector row2, Float64Vector row3)
row0
- the 1st row vector. May not be null.row1
- the 2nd row vector. May not be null.row2
- the 3rd row vector. May not be null.row3
- the 4th row vector. May not be null.DimensionException
- if the any of the rows do not have a dimension of 4.public static GTransform valueOf(java.util.List<Float64Vector> rows)
rows
- The list of 4 row vectors. May not be null.DimensionException
- if the rows do not have a dimension of 4.public static GTransform valueOf(double diagX, double diagY, double diagZ, double diagW)
diagX
- the 1st element of the diagonal vector for the matrix.diagY
- the 2nd element of the diagonal vector for the matrix.diagZ
- the 3rd element of the diagonal vector for the matrix.diagW
- the 4th element of the diagonal vector for the matrix.public static GTransform valueOf(Matrix<Float64> matrix)
GTransform
instance containing a copy of the specified matrix of
Float64 values. The matrix must have dimensions of either 3x3 for a combined scale
and direction cosine matrix or 4x4 for a general transformation matrix. If a 3x3
matrix is input, then the upper-left 3x3 portion of the output matrix will be set
to those values and the other elements will be set as if it were an identity matrix
(i.e., affine matrix with no translational component). If a 4x4 matrix is input,
then the 4th column (the translation) must be in units of meters!matrix
- the matrix of Float64 values to convert (must have dimension of 3x3
or 4x4). May not be null.public static GTransform valueOf(Matrix<Float64> dcm, double scale, Vector<Length> trans)
GTransform
instance containing the specified direction cosine
rotation matrix, uniform scale factor, and translation vector.dcm
- The direction cosine matrix to convert (must have dimension of 3x3).
May not be null.scale
- The uniform scale factor to apply to each axis.trans
- The amount to translate in each axis X, Y & Z.public static GTransform valueOf(Rotation rotation)
GTransform
instance containing a copy of the specified rotation
transformation. The upper-left 3x3 portion of the output matrix will be set to DCM
values from the rotation and the other elements will be set as if it were an
identity matrix (i.e., affine matrix with no translational component).rotation
- the Rotation transformation to convert. May not be null.public static GTransform valueOf(Rotation rotation, double scale, Vector<Length> trans)
GTransform
instance containing the specified rotation
transformation, uniform scale factor, and translation vector.rotation
- The rotation transformation to convert. May not be null.scale
- The uniform scale factor to apply to each axis.trans
- The amount to translate in each axis X, Y & Z. May not be null.public static GTransform valueOf(GeomVector srcAxis, GeomVector destAxis)
GTransform
instance representing the transformation from one axis
direction directly to another. Input vectors must be 3D.srcAxis
- A vector representing the 1st or starting axis. May not be null.destAxis
- A vector representing the 2nd or ending axis. May not be null.public static GTransform newScale(double scale)
scale
- The scale factor to create a scale matrix for.public static GTransform newTranslation(double transX, double transY, double transZ)
transX
- The amount to translate, in meters, in the X axis direction.transY
- The amount to translate, in meters, in the Y axis direction.transZ
- The amount to translate, in meters, in the Z axis direction.DimensionException
- if the input vector does not have 3 elements.public static GTransform newTranslation(Parameter<Length> transX, Parameter<Length> transY, Parameter<Length> transZ)
transX
- The amount to translate in the X axis direction. May not be null.transY
- The amount to translate in the Y axis direction. May not be null.transZ
- The amount to translate in the Z axis direction. May not be null.DimensionException
- if the input vector does not have 3 elements.public static GTransform newTranslation(GeomVector<Length> vector)
vector
- The amount to translate in each axis X, Y & Z. May not be null.public static GTransform newTranslation(Float64Vector trans)
trans
- The amount to translate, in meters, in each axis X, Y & Z. May not be null.DimensionException
- if the input vector does not have 3 elements.public static GTransform newRotationX(Parameter<Angle> angle)
angle
- The angle to rotate about the X axis. May not be null.public static GTransform newRotationY(Parameter<Angle> angle)
angle
- The angle to rotate about the Y axis. May not be null.public static GTransform newRotationZ(Parameter<Angle> angle)
angle
- The angle to rotate about the Z axis. May not be null.public int getNumberOfRows()
public int getNumberOfColumns()
public Float64 get(int i, int j)
i
- the row index (range [0..3[).j
- the column index (range [0..3[).public double getValue(int i, int j)
double
.
This is a convenience method for: this.get(i,j).doubleValue()
i
- the row index (range [0..3[).j
- the column index (range [0..3[).public Float64Matrix getFloat64Matrix()
public double[][] getMatrix()
public Float64Vector getRow(int i)
i
- the row index (range [0..3[).public Float64Vector getColumn(int j)
j
- the column index (range [0..3[).public Float64Vector getDiagonal()
public Point transform(GeomPoint p)
p
- The point to be transformed. May not be null.this · p
DimensionException
- if p.getPhyDimension() != 3public GTransform times(GTransform that)
that
- the matrix multiplier. May not be null.this · that
public GTransform inverse()
determinant()
will be zero (or nearly zero).1 / this
determinant()
public Float64 determinant()
public GTransform transpose()
A'
public Float64Vector vectorization()
public GTransform copy()
copy
in interface javolution.lang.ValueType
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
allocated
by the calling thread
(possibly on the stack).clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Never thrown.public javolution.text.Text toText()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare with.true
if this transform is identical to that transform;
false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public double getScale()
public Float64Vector getScaleVector()
public DCMatrix getRotation()
public Matrix<Float64> getRotationScale()
public Vector<Length> getTranslation()
public GTransform applyScale(double scale)
scale
- The scale factor to apply to this transformation.public GTransform applyScale(Float64Vector scale)
scale
- The scale factor in each dimension (X, Y & Z) to apply to this
transformation. May not be null.DimensionException
- if the input list of scale factors does not have 3
elements.public GTransform applyRotation(Matrix<Float64> m1)
m1
- The direction cosine matrix to apply to this matrix. May not be null.DimensionException
- if matrix is not 3x3public GTransform applyRotationScale(Matrix<Float64> m1)
m1
- The 3x3 matrix that will be the new upper left portion. May not be null.DimensionException
- if m1 is not 3x3public GTransform applyTranslation(Vector<Length> trans)
trans
- The 3 element translation offsets in (X, Y & Z). May not be null.public GTransform applyTranslation(Float64Vector trans)
trans
- The 3 element translation offsets in meters (X, Y & Z). May not be null.DimensionException
- if input vector does not have exactly 3 elements.public static void main(java.lang.String[] args)
args
- Command-line arguments (not used).