jautil.geometry
Class TRTransform

java.lang.Object
  extended by jautil.geometry.TRTransform

public class TRTransform
extends java.lang.Object

An TRTransform represents a homogeneous 3D transform which is composed of translations and rotations only.

This is a reworking of class SGMatrix with restrictions: we allow transforms composed from translations and rotations (only) -- that is, with no scaling.

Hence each homogeneous transform is represented by a matrix with the following features: - The bottom row is [0 0 0 1].
- Its determinant is 1.
- The upper-left 3 x 3 submatrix represents a rotation (whose determinant is also 1).
- The upper-right 3 x 1 column vector represents a translation.

We represent the transform by a 3 x 4 matrix (that is, the values in the 4th row are left implicit). In addition we allow a quaternion to be associated with the transform, corresponding to its rotation component. The presence of this quaternion allows products to be computed more efficiently.


Constructor Summary
TRTransform()
          Default constructor, giving the identity transform.
TRTransform(float[] marray)
          Constructs this transform using the given transformation array (that is, using the array itself, not a copy); in this case there is NO associated rotation quaternion.
TRTransform(Quaternion qrot)
          Constructs a transformation from the given rotation quaternion qrot (which is copied) and a zero translation.
 
Method Summary
 TRTransform getInverse()
          Returns a new transformation representing the inverse of this one; note that the new transform does NOT have a rotation quaternion.
 float[] mat()
          Returns the RT array for this transform.
 Quaternion quat()
          Returns the rotation quaternion for this transform.
 void rotateVector(Vector3f vec)
          Applies the rotation part of this transform to the given vector vec, updating the vector itself with the result.
 void rotateVector(Vector3f vec, float[] vecout)
          Applies the rotation part of this transform to the given vector vec, giving the result in vecout.
 void set(float[] rot, float[] trans)
          Resets this transformation from the given rotation and translation arrays (rot and trans).
 void set(float X, float Y, float Z, float angledeg)
          Sets this transform to represent a rotation of angledeg degrees around the axis vector (X,Y,Z), which MUST have unit length, with a zero translation.
 void set(Quaternion qrot)
          Resets this transformation from the given rotation qrot and a zero transformation.
 void setComposition(TRTransform xpre, float[] rot, float[] trans)
          Resets this transformation as the composition of the given transform with that represented by the given rotation and translation arrays.
 void setComposition(TRTransform xpre, Quaternion qrot)
          Resets this transformation as the composition of the given transform with the given rotation (and a zero translation).
 java.lang.String toString()
           
 void transformPoint(Vector3f pt)
          Applies this transform to the given point, pt.
 void transformPoint(Vector3f pt, float[] ptout)
          Applies this transform to the given point pt, giving the result in ptout.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TRTransform

public TRTransform()
Default constructor, giving the identity transform.


TRTransform

public TRTransform(float[] marray)
Constructs this transform using the given transformation array (that is, using the array itself, not a copy); in this case there is NO associated rotation quaternion.


TRTransform

public TRTransform(Quaternion qrot)
Constructs a transformation from the given rotation quaternion qrot (which is copied) and a zero translation. [## CURRENTLY UNUSED ##]

Method Detail

mat

public float[] mat()
Returns the RT array for this transform.


quat

public Quaternion quat()
Returns the rotation quaternion for this transform.


set

public void set(Quaternion qrot)
Resets this transformation from the given rotation qrot and a zero transformation.


set

public void set(float[] rot,
                float[] trans)
Resets this transformation from the given rotation and translation arrays (rot and trans).


setComposition

public void setComposition(TRTransform xpre,
                           float[] rot,
                           float[] trans)
Resets this transformation as the composition of the given transform with that represented by the given rotation and translation arrays.


setComposition

public void setComposition(TRTransform xpre,
                           Quaternion qrot)
Resets this transformation as the composition of the given transform with the given rotation (and a zero translation).


transformPoint

public void transformPoint(Vector3f pt)
Applies this transform to the given point, pt.


transformPoint

public void transformPoint(Vector3f pt,
                           float[] ptout)
Applies this transform to the given point pt, giving the result in ptout.


rotateVector

public void rotateVector(Vector3f vec,
                         float[] vecout)
Applies the rotation part of this transform to the given vector vec, giving the result in vecout.


rotateVector

public void rotateVector(Vector3f vec)
Applies the rotation part of this transform to the given vector vec, updating the vector itself with the result.


getInverse

public TRTransform getInverse()
Returns a new transformation representing the inverse of this one; note that the new transform does NOT have a rotation quaternion.


set

public void set(float X,
                float Y,
                float Z,
                float angledeg)
Sets this transform to represent a rotation of angledeg degrees around the axis vector (X,Y,Z), which MUST have unit length, with a zero translation. [## CURRENTLY UNUSED ##]


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object