vmm.core3D
Class GridTransformMatrix

java.lang.Object
  extended by vmm.core3D.GridTransformMatrix

public class GridTransformMatrix
extends java.lang.Object

Represents an affine transform on real 3-space as a matrix; meant for use with Grid3D to represent transformations applied to a basic grid to produce additional segments of a complete surface.


Constructor Summary
GridTransformMatrix()
          Constructs an identity matrix.
GridTransformMatrix(GridTransformMatrix m)
          Copy constructor.
 
Method Summary
 Vector3D apply(Vector3D vec)
          Applies the transform to a vector.
 Vector3D applyToNormal(Vector3D N)
          Apply the transformation to a surface normal.
 boolean equals(java.lang.Object o)
          Tests whether a given object is equal to this TransformMatrix.
 boolean getReverseSurfaceOrientation()
          Gets the value of the reverseSurfaceOrientation property.
 GridTransformMatrix leftMultiplyBy(GridTransformMatrix m)
          Multiplying this GridTransformationMatrix on the left by another matrix.
 GridTransformMatrix reverse()
          Reverses the value of the reverseSurfaceOrientation property.
 GridTransformMatrix rotateX(double degrees)
          Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.
 GridTransformMatrix rotateY(double degrees)
          Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.
 GridTransformMatrix rotateZ(double degrees)
          Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.
 GridTransformMatrix scale(double s)
          Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix.
 GridTransformMatrix scale(double sx, double sy, double sz)
          Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix.
static GridTransformMatrix SetGridTransformMatrix(double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3, double c0, double c1, double c2, double c3, boolean or)
          Explicit constructor, giving the entries in the transformation matrix.
 GridTransformMatrix setReverseSurfaceOrientation(boolean reverseSurfaceOrientation)
          Sets the value of the reverseSurfaceOrientation property.
 GridTransformMatrix setTranslation(double x, double y, double z)
          Replaces the translation part of the matrix with the vector (x,y,z).
 GridTransformMatrix setTranslation(Vector3D vt)
          Replaces the translation part of the matrix with a given Vector3D vt.
 GridTransformMatrix translate(double tx, double ty, double tz)
          Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix.
 GridTransformMatrix translate(Vector3D v)
          Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridTransformMatrix

public GridTransformMatrix()
Constructs an identity matrix.


GridTransformMatrix

public GridTransformMatrix(GridTransformMatrix m)
Copy constructor.

Parameters:
m - The TransformMatrix object to be copied. If m is null, an identity matrix is constructed.
Method Detail

SetGridTransformMatrix

public static GridTransformMatrix SetGridTransformMatrix(double a0,
                                                         double a1,
                                                         double a2,
                                                         double a3,
                                                         double b0,
                                                         double b1,
                                                         double b2,
                                                         double b3,
                                                         double c0,
                                                         double c1,
                                                         double c2,
                                                         double c3,
                                                         boolean or)
Explicit constructor, giving the entries in the transformation matrix.

Parameters:
or - tells whether the transformation should be orientation-reversing.

equals

public boolean equals(java.lang.Object o)
Tests whether a given object is equal to this TransformMatrix. If the object is null or is not a TransformMatrix, the return value is false. Otherwise, the return value is true if and only if the two transforms have the same matrices. ===> How about the orientation? <== HK

Overrides:
equals in class java.lang.Object

apply

public Vector3D apply(Vector3D vec)
Applies the transform to a vector. To apply the transform to (x,y,z), the column vector (x,y,z,1) is mulitplied on the left by a 4-by-4 matrix, producing a vector (a,b,c,1). The return value is the vector (a,b,c).

Parameters:
vec - The non-null vector that is to be transformed. This vector is not modified.
Returns:
A new Vector3D object containing the result of applying the transform to vec.

applyToNormal

public Vector3D applyToNormal(Vector3D N)
Apply the transformation to a surface normal. If the reverseSurfaceOrientation property is true, the resulting normal is multiplied by -1.

Parameters:
N - The non-null normal vector that is to be transformed. This vector is not modified.
Returns:
A new Vector3D object containing the result of applying the transform to N.

getReverseSurfaceOrientation

public boolean getReverseSurfaceOrientation()
Gets the value of the reverseSurfaceOrientation property.

See Also:
setReverseSurfaceOrientation(boolean)

setReverseSurfaceOrientation

public GridTransformMatrix setReverseSurfaceOrientation(boolean reverseSurfaceOrientation)
Sets the value of the reverseSurfaceOrientation property. The default value is false. This property affects the result of applying the transformation to a surface normal vector using the applyToNormal(Vector3D) method. If the value of this property is true, then the transformed vector is negated.


reverse

public GridTransformMatrix reverse()
Reverses the value of the reverseSurfaceOrientation property. Calling this method is equivalent to calling setReverseSurfaceOrientation( ! getReverseSurfaceOrientation )

Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

scale

public GridTransformMatrix scale(double s)
Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix. This TransformMatrix is modified in place.

Parameters:
s - The (uniform) scale factor.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

scale

public GridTransformMatrix scale(double sx,
                                 double sy,
                                 double sz)
Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix. This TransformMatrix is modified in place.

Parameters:
sx - The scaling in the x direction.
sy - The scaling in the y direction.
sz - The scaling in the z direction.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

translate

public GridTransformMatrix translate(double tx,
                                     double ty,
                                     double tz)
Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix. This TransformMatrix is modified in place.

Parameters:
tx - The translation in the x direction.
ty - The translation in the y direction.
tz - The translation in the z direction.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

translate

public GridTransformMatrix translate(Vector3D v)
Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix. This TransformMatrix is modified in place.

Parameters:
v - The translation vector. If v == null: return this.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

setTranslation

public GridTransformMatrix setTranslation(Vector3D vt)
Replaces the translation part of the matrix with a given Vector3D vt. This does not compose the transformation with a translation; it disacards the current translation and applies a new one. Calling this method is equivalent to calling translate(tr.minus(getTranslation())).

Parameters:
vt - The vector that becomes the new translation. A null vector is taken to be zero.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

setTranslation

public GridTransformMatrix setTranslation(double x,
                                          double y,
                                          double z)
Replaces the translation part of the matrix with the vector (x,y,z). This does not compose the transformation with a translation; it disacards the current translation and applies a new one.

Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

rotateZ

public GridTransformMatrix rotateZ(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the z-axis, through a specified number of degrees. This TransformMatrix is modified in place.

Parameters:
degrees - Measure, in degrees, of the angle of rotation about the z-axis.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

rotateX

public GridTransformMatrix rotateX(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the x-axis, through a specified number of degrees. This TransformMatrix is modified in place.

Parameters:
degrees - Measure, in degrees, of the angle of rotation about the x-axis.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

rotateY

public GridTransformMatrix rotateY(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the y-axis, through a specified number of degrees. This TransformMatrix is modified in place.

Parameters:
degrees - Measure, in degrees, of the angle of rotation about the y-axis.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.

leftMultiplyBy

public GridTransformMatrix leftMultiplyBy(GridTransformMatrix m)
Multiplying this GridTransformationMatrix on the left by another matrix. Note that the transformation is modified in place.

Parameters:
m - the matrix by which this matrix is to be multiplied on the left. If m is null, this matrix is not modified.
Returns:
A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.