Package WildMagic.LibGraphics.SceneGraph
Class Transformation
- java.lang.Object
-
- WildMagic.LibGraphics.SceneGraph.Transformation
-
- All Implemented Interfaces:
java.io.Serializable
public class Transformation extends java.lang.Object implements java.io.Serializable
The transformation is Y = M*X+T, where M is a 3-by-3 matrix and T is a translation vector. In most cases, M = R, a rotation matrix, or M = R*S, where R is a rotation matrix and S is a diagonal matrix whose diagonal entries are positive scales. To support modeling packages that allow reflections and nonuniform scales, I now allow the general transformation Y = M*X+T. The vector X is transformed in the "forward" direction to Y. The "inverse" direction transforms Y to X, namely X = M^{-1}*(Y-T) in the general case. In the special case of M = R*S, the inverse direction is X = S^{-1}*R^t*(Y-T).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DISK_USED
Allow Stream directly read/write the data members and Spatial to access DISK_USED.private boolean
m_bIsIdentity
True if the Transformation is the identity matrix.private boolean
m_bIsRSMatrix
True if the Transformation is a rotation/scale matrix.private boolean
m_bIsUniformScale
True if Transformation is a uniform scale.private boolean
m_bUpdateInverse
True is the matrix inverse needs to be updated.private Matrix3f
m_kMatrix
Transformation matrix.private Matrix3f
m_kMatrixInverse
private Vector3f
m_kScale
Scale vector.private Vector3f
m_kTranslate
Translation vector.private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description Transformation()
The default constructor produces the identity transformation.Transformation(Transformation rkA)
Copy into this transformation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Plane3f
ApplyForward(Plane3f rkInput)
Transform the plane Dot(N0,X) = c0 to Dot(N1,Y) = c1 where both N0 and N1 must be unit-length normals.Vector3f
ApplyForward(Vector3f rkInput)
Compute Y = M*X+T where X is the input and Y is the output.void
ApplyForward(Vector3f rkInput, Vector3f kOutput)
Compute Y = M*X+T where X is the input and Y is the output.Vector3f
ApplyInverse(Vector3f rkInput)
Compute X = M^{-1}*(Y-T) where Y is the input and X is the output.void
ApplyInverse(Vector3f rkInput, Vector3f kOutput)
Compute X = M^{-1}*(Y-T) where Y is the input and X is the output.void
Copy(Transformation rkA)
Copy into this transformation.void
dispose()
Delete memory.void
GetHomogeneous(Matrix4f rkHMatrix)
Pack the transformation into a 4-by-4 matrix, stored so that it may be applied to 1-by-4 vectors on the left.Matrix3f
GetMatrix()
Get matrix reference.float
GetNorm()
For M = R*S, the largest value of S in absolute value is returned.Matrix3f
GetRotate()
Get the rotation matrix.Vector3f
GetScale()
Get the scale vector.Vector3f
GetTranslate()
Get the translation vector.float
GetUniformScale()
Get uniform scale factor.(package private) void
Inverse()
Set this to the inverse transformation.Vector3f
InvertVector(Vector3f rkInput)
Inverse-transform the input vector V0.boolean
IsIdentity()
Hints about the structure of the transformation.boolean
IsRSMatrix()
Hints about the structure of the transformation.boolean
IsUniformScale()
Hints about the structure of the transformation.void
MakeIdentity()
Set the transformation to the identity.void
MakeUnitScale()
Set the scales to 1.void
Product(Transformation rkA, Transformation rkB)
Compute this = A*B.void
SetIsIdentity(boolean bValue)
Set IsIdentity flag.void
SetIsRSMatrix(boolean bValue)
Set IsRSMatrix flag.void
SetIsUniformScale(boolean bValue)
Set IsUniformScale flag.void
SetMatrix(Matrix3f rkMatrix)
The Set* functions set the is-identity hint to false.void
SetMatrixCopy(Matrix3f rkMatrix)
The Set* functions set the is-identity hint to false.void
SetRotate(Matrix3f rkRotate)
The Set* functions set the is-identity hint to false.void
SetRotateCopy(Matrix3f rkRotate)
The Set* functions set the is-identity hint to false.void
SetScale(float fSx, float fSy, float fSz)
The Set* functions set the is-identity hint to false.void
SetScale(Vector3f rkScale)
The Set* functions set the is-identity hint to false.void
SetTranslate(float fTx, float fTy, float fTz)
Set the translation vector.void
SetTranslate(Vector3f rkTranslate)
Set the translation vector.void
SetUniformScale(float fScale)
Set uniform scale factor.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DISK_USED
public static int DISK_USED
Allow Stream directly read/write the data members and Spatial to access DISK_USED.
-
m_kMatrix
private Matrix3f m_kMatrix
Transformation matrix.
-
m_kMatrixInverse
private Matrix3f m_kMatrixInverse
-
m_kTranslate
private Vector3f m_kTranslate
Translation vector.
-
m_kScale
private Vector3f m_kScale
Scale vector.
-
m_bIsIdentity
private boolean m_bIsIdentity
True if the Transformation is the identity matrix.
-
m_bIsRSMatrix
private boolean m_bIsRSMatrix
True if the Transformation is a rotation/scale matrix.
-
m_bIsUniformScale
private boolean m_bIsUniformScale
True if Transformation is a uniform scale.
-
m_bUpdateInverse
private boolean m_bUpdateInverse
True is the matrix inverse needs to be updated.
-
-
Constructor Detail
-
Transformation
public Transformation()
The default constructor produces the identity transformation.
-
Transformation
public Transformation(Transformation rkA)
Copy into this transformation.- Parameters:
rkA
- Transformation to copy
-
-
Method Detail
-
Inverse
void Inverse()
Set this to the inverse transformation. Ifis the matrix-translation pair, the inverse is .
-
ApplyForward
public Plane3f ApplyForward(Plane3f rkInput)
Transform the plane Dot(N0,X) = c0 to Dot(N1,Y) = c1 where both N0 and N1 must be unit-length normals.- Parameters:
rkInput
- input plane.- Returns:
- output transformed plane.
-
ApplyForward
public Vector3f ApplyForward(Vector3f rkInput)
Compute Y = M*X+T where X is the input and Y is the output.- Parameters:
rkInput
- input vector X.- Returns:
- output vector Y.
-
ApplyForward
public void ApplyForward(Vector3f rkInput, Vector3f kOutput)
Compute Y = M*X+T where X is the input and Y is the output.- Parameters:
rkInput
- input vector X.
-
ApplyInverse
public Vector3f ApplyInverse(Vector3f rkInput)
Compute X = M^{-1}*(Y-T) where Y is the input and X is the output.- Parameters:
rkInput
- input vector Y.- Returns:
- output vector X.
-
ApplyInverse
public void ApplyInverse(Vector3f rkInput, Vector3f kOutput)
Compute X = M^{-1}*(Y-T) where Y is the input and X is the output.- Parameters:
rkInput
- input vector Y.
-
Copy
public void Copy(Transformation rkA)
Copy into this transformation.- Parameters:
rkA
- Transformation to copy
-
dispose
public void dispose()
Delete memory.
-
GetHomogeneous
public void GetHomogeneous(Matrix4f rkHMatrix)
Pack the transformation into a 4-by-4 matrix, stored so that it may be applied to 1-by-4 vectors on the left.- Parameters:
rkHMatrix
- matrix to pack the transformation into.
-
GetMatrix
public final Matrix3f GetMatrix()
Get matrix reference.- Returns:
- the matrix.
-
GetNorm
public float GetNorm()
For M = R*S, the largest value of S in absolute value is returned. For general M, the max-row-sum norm is returned (and is guaranteed to be larger or equal to the largest eigenvalue of S in absolute value).- Returns:
- Norm.
-
GetRotate
public Matrix3f GetRotate()
Get the rotation matrix.- Returns:
- the rotation matrix.
-
GetScale
public Vector3f GetScale()
Get the scale vector.- Returns:
- the scale vector..
-
GetTranslate
public final Vector3f GetTranslate()
Get the translation vector.- Returns:
- the translation vector.
-
GetUniformScale
public float GetUniformScale()
Get uniform scale factor.- Returns:
- uniform scale factor.
-
InvertVector
public Vector3f InvertVector(Vector3f rkInput)
Inverse-transform the input vector V0. The output vector is V1 = M^{-1}*V0.- Parameters:
rkInput
- input vector V0.- Returns:
- output vector V1 = M^{-1}*V0.
-
IsIdentity
public final boolean IsIdentity()
Hints about the structure of the transformation. In the common case of M = R*S, IsRSMatrix() returns true.- Returns:
- true if identity.
-
IsRSMatrix
public final boolean IsRSMatrix()
Hints about the structure of the transformation. In the common case of M = R*S, IsRSMatrix() returns true.- Returns:
- true if rotation scale matrix.
-
IsUniformScale
public final boolean IsUniformScale()
Hints about the structure of the transformation. In the common case of M = R*S, IsRSMatrix() returns true.- Returns:
- true if uniform scale matrix.
-
MakeIdentity
public void MakeIdentity()
Set the transformation to the identity.
-
MakeUnitScale
public void MakeUnitScale()
Set the scales to 1.
-
Product
public void Product(Transformation rkA, Transformation rkB)
Compute this = A*B.- Parameters:
rkA
- input A.rkB
- input B.
-
SetIsIdentity
public void SetIsIdentity(boolean bValue)
Set IsIdentity flag.- Parameters:
bValue
- identity value.
-
SetIsRSMatrix
public void SetIsRSMatrix(boolean bValue)
Set IsRSMatrix flag.- Parameters:
bValue
- rotation/scale matrix value.
-
SetIsUniformScale
public void SetIsUniformScale(boolean bValue)
Set IsUniformScale flag.- Parameters:
bValue
- uniform scale matrix value.
-
SetMatrix
public void SetMatrix(Matrix3f rkMatrix)
The Set* functions set the is-identity hint to false. The SetMatrix function sets the is-rsmatrix and is-uniform-scale hints to false.- Parameters:
rkRotate
- new matrix.
-
SetMatrixCopy
public void SetMatrixCopy(Matrix3f rkMatrix)
The Set* functions set the is-identity hint to false. The SetMatrix function sets the is-rsmatrix and is-uniform-scale hints to false.- Parameters:
rkRotate
- new matrix.
-
SetRotate
public void SetRotate(Matrix3f rkRotate)
The Set* functions set the is-identity hint to false. The SetRotate function sets the is-rsmatrix hint to true. If this hint is false, GetRotate fires an "assert" in debug mode.- Parameters:
rkRotate
- new matrix.
-
SetRotateCopy
public void SetRotateCopy(Matrix3f rkRotate)
The Set* functions set the is-identity hint to false. The SetRotate function sets the is-rsmatrix hint to true. If this hint is false, GetRotate fires an "assert" in debug mode.- Parameters:
rkRotate
- new matrix.
-
SetScale
public void SetScale(float fSx, float fSy, float fSz)
The Set* functions set the is-identity hint to false. The SetScale function sets the is-uniform-scale hint to false. The SetUniformScale function sets the is-uniform-scale hint to true. If this hint is false, GetUniformScale fires an "assert" in debug mode.- Parameters:
rkRotate
- new scale vector.
-
SetScale
public void SetScale(Vector3f rkScale)
The Set* functions set the is-identity hint to false. The SetScale function sets the is-uniform-scale hint to false. The SetUniformScale function sets the is-uniform-scale hint to true. If this hint is false, GetUniformScale fires an "assert" in debug mode.- Parameters:
rkRotate
- new scale vector.
-
SetTranslate
public void SetTranslate(float fTx, float fTy, float fTz)
Set the translation vector.- Parameters:
the
- new translation vector.
-
SetTranslate
public void SetTranslate(Vector3f rkTranslate)
Set the translation vector.- Parameters:
the
- new translation vector.
-
SetUniformScale
public void SetUniformScale(float fScale)
Set uniform scale factor.- Parameters:
fScale
- uniform scale factor.
-
-