Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## threeD.raytracer.util
Class TransformMatrix

    java.lang.Object
      threeD.raytracer.util.TransformMatrix

Direct Known Subclasses:
  TransformMatrixUI

public class TransformMatrix
extends java.lang.Object

A TransformMatrix object represents a 4 X 4 matrix used for transforming vectors. A TransformMatrix object stores 16 double values for the matrix data and provides methods for transforming varius types of vectors. The TransformMatrix class also provides some static methods that generate certain useful matracies.

Field Summary
`static double[][]` | `identity` The data for the identity matrix.
`static int` | `TRANSFORM_AS_LOCATION`
`static int` | `TRANSFORM_AS_NORMAL`
`static int` | `TRANSFORM_AS_OFFSET`

Constructor Summary
`TransformMatrix()` Constructs a TransformMatrix object that by default contains the data for a 4 X 4 identity matrix.
`TransformMatrix(double[][] matrix)` Constructs a TransformMatrix object with the specified matrix data.

Method Summary
`TransformMatrix` | `adjoint()` Computes the adjoint of the matrix represented by this TransformMatrix object and returns the result as a TransformMatrix object.
`void` | `calculateInverse()` Calculates the inverse of the matrix represented by this TransformMatrix object and stores it for later use.
`static TransformMatrix` | `createRotateXMatrix(double angle)` Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the x axis.
`static TransformMatrix` | `createRotateYMatrix(double angle)` Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the y axis.
`static TransformMatrix` | `createRotateZMatrix(double angle)` Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the z axis.
`static TransformMatrix` | `createScaleMatrix(double sx, double sy, double sz)` Generates a TransformMatrix object that can be used to scale vectors using the specified scaling coefficients.
`static TransformMatrix` | `createTranslationMatrix(double tx, double ty, double tz)` Generates a TransformMatrix object that can be used to translate vectors using the specified translation coordinates.
`double` | `determinant()` Computes the determinant of the matrix represented by this TransformMatrix object and returns the result as a double value.
`TransformMatrix` | `getInverse()` Returns the inverse of the matrix represented by this TransformMatrix object as a TransformMatrix object.
`double[][]` | `getMatrix()` Returns the 16 values stored by this TransformMatrix as a 4 X 4 double array.
`TransformMatrix` | `multiply(double value)` Multiplys the matrix represented by this TransformMatrix object with the specified double value and returns the result as a TransformMatrix object.
`TransformMatrix` | `multiply(TransformMatrix matrix)` Multiplys the matrix represented by this TransformMatrix object with the matrix represented by the specified TransformMatrix object and returns the result as a TransformMatrix object.
`void` | `setMatrix(double[][] matrix)` Sets the 16 values stored by this TransformMatrix to those specified.
`java.lang.String` | `toString()` Returns a String representation of the data stored by this TransformMatrix object.
`TransformMatrix` | `toUpperTriangle()` Converts the matrix represented by this TransformMatrix object to an upper triangle matrix and returns the result as a TransformMatrix object.
`void` | `transform(Vector vector, int type)`
`Vector` | `transformAsLocation(Vector vector)` Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes a location on 3d space.
`Vector` | `transformAsNormal(Vector vector)` Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes a surface normal in 3d space.
`Vector` | `transformAsOffset(Vector vector)` Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes an offset in 3d space.
`TransformMatrix` | `transpose()` Computes the transpose of the matrix represented by this TransformMatrix object and returns the result as a TransformMatrix object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### TRANSFORM_AS_LOCATION

    public static final int TRANSFORM_AS_LOCATION

See Also:
  Constant Field Values

### TRANSFORM_AS_OFFSET

    public static final int TRANSFORM_AS_OFFSET

See Also:
  Constant Field Values

### TRANSFORM_AS_NORMAL

    public static final int TRANSFORM_AS_NORMAL

See Also:
  Constant Field Values

### identity

    public static final double[][] identity

  The data for the identity matrix.

Constructor Detail

### TransformMatrix

    public TransformMatrix()

  Constructs a TransformMatrix object that by default contains the data for a 4 X 4 identity matrix.

### TransformMatrix

    public TransformMatrix(double[][] matrix)

  Constructs a TransformMatrix object with the specified matrix data. Any extra array entries are removed and missing array entries are replaced with 0.0.

Method Detail

### setMatrix

    public void setMatrix(double[][] matrix)

  Sets the 16 values stored by this TransformMatrix to those specified. Any extra array entries are removed and missing array entries are replaced with 0.0.

### getMatrix

    public double[][] getMatrix()

  Returns the 16 values stored by this TransformMatrix as a 4 X 4 double array.

### multiply

    public TransformMatrix multiply(double value)

  Multiplys the matrix represented by this TransformMatrix object with the specified double value and returns the result as a TransformMatrix object.

### multiply

    public TransformMatrix multiply(TransformMatrix matrix)

  Multiplys the matrix represented by this TransformMatrix object with the matrix represented by the specified TransformMatrix object and returns the result as a TransformMatrix object.

### transform

    public void transform(Vector vector,
                          int type)

### transformAsLocation

    public Vector transformAsLocation(Vector vector)

  Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes a location on 3d space.

### transformAsOffset

    public Vector transformAsOffset(Vector vector)

  Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes an offset in 3d space.

### transformAsNormal

    public Vector transformAsNormal(Vector vector)

  Computes and returns the result of the vector multiplication of the matrix represented by this TransformMatrix object and the vector represented by the specified Vector object assuming that the specified vector describes a surface normal in 3d space.

### calculateInverse

    public void calculateInverse()

  Calculates the inverse of the matrix represented by this TransformMatrix object and stores it for later use.

### getInverse

    public TransformMatrix getInverse()

  Returns the inverse of the matrix represented by this TransformMatrix object as a TransformMatrix object. If this method, or the calulateInverse() method, has been called after the last matrix modification this method will return a stored inverse.

### determinant

    public double determinant()

  Computes the determinant of the matrix represented by this TransformMatrix object and returns the result as a double value.

### transpose

    public TransformMatrix transpose()

  Computes the transpose of the matrix represented by this TransformMatrix object and returns the result as a TransformMatrix object.

### adjoint

    public TransformMatrix adjoint()

  Computes the adjoint of the matrix represented by this TransformMatrix object and returns the result as a TransformMatrix object.

### toUpperTriangle

    public TransformMatrix toUpperTriangle()

  Converts the matrix represented by this TransformMatrix object to an upper triangle matrix and returns the result as a TransformMatrix object.

### toString

    public java.lang.String toString()

  Returns a String representation of the data stored by this TransformMatrix object.

### createTranslationMatrix

    public static TransformMatrix createTranslationMatrix(double tx,
                                                          double ty,
                                                          double tz)

  Generates a TransformMatrix object that can be used to translate vectors using the specified translation coordinates.

### createScaleMatrix

    public static TransformMatrix createScaleMatrix(double sx,
                                                    double sy,
                                                    double sz)

  Generates a TransformMatrix object that can be used to scale vectors using the specified scaling coefficients.

### createRotateXMatrix

    public static TransformMatrix createRotateXMatrix(double angle)

  Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the x axis. The angle measurement is in radians.

### createRotateYMatrix

    public static TransformMatrix createRotateYMatrix(double angle)

  Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the y axis. The angle measurement is in radians.

### createRotateZMatrix

    public static TransformMatrix createRotateZMatrix(double angle)

  Generates a TransformMatrix object that can be used to rotate vectors counterclockwise about the z axis. The angle measurement is in radians.

Overview | Package | Class | Use | Tree | Index | Help
| Rings Version 0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2003-05 Mike Murray