gumbo.graphic.math
Class Matrix4

java.lang.Object
  |
  +--gumbo.graphic.math.Matrix4
All Implemented Interfaces:
Graphic, java.io.Serializable

public class Matrix4
extends java.lang.Object
implements java.io.Serializable, Graphic

A 3D spatial transform specifying an arbitrary homogenous transform, which is defined by a 4x4 matrix with double precision.

Version:
$Revision: 1.8 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Field Summary
static Matrix4 IDENTITY
          Identity matrix.
static Matrix4 ZERO
          Identity matrix.
 
Constructor Summary
Matrix4()
           
 
Method Summary
static void clearArray(double[] val)
          Sets a length 4 array to all zeros.
static void clearArray(double[][] val)
          Sets length 4x4 array to all zeros.
 boolean equals(java.lang.Object obj)
           
 double[][] get(double[][] retVal)
          Master whole state accessor.
 Matrix4 get(Matrix4 retVal)
           
 java.lang.Object getGraphic()
          Default implementation: Returns this (non-native implementation).
 Matrix4 getMatrix4()
          Gets a singleton immutable view of this object with the same identity (hashCode(), equals()) as this object.
 Matrix4 inverse(Matrix4 retVal)
          Inverts this matrix.
 Matrix4 set(double[][] matrix)
          Master whole state mutator.
 Matrix4 set(Matrix4 matrix)
          Sets this matrix to the value of another matrix.
 Matrix4 setIdentity()
          Sets this matrix to the identity matrix.
 Matrix4 setScale(Tuple3 tuple)
          Sets the whole matrix to scale by the specified amount.
 Matrix4 setTranslation(Tuple3 tuple)
          Sets the whole matrix to translate by the specified amount.
 Matrix4 setZero()
          Sets this matrix to all zeros.
 java.lang.String toString()
           
 Matrix4 transform(Matrix4 matrix, Matrix4 retVal)
          Transforms a matrix by pre-multiplying it by this matrix.
 Point3 transform(Point3 point, Point3 retVal)
          Transforms a point by pre-multiplying it by this matrix.
 Vector3 transform(Vector3 vector, Vector3 retVal)
          Transforms a vector by pre-multiplying it by this matrix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Matrix4 ZERO
Identity matrix. Immutable.


IDENTITY

public static final Matrix4 IDENTITY
Identity matrix. Immutable.

Constructor Detail

Matrix4

public Matrix4()
Method Detail

set

public Matrix4 set(double[][] matrix)
Master whole state mutator.


set

public Matrix4 set(Matrix4 matrix)
Sets this matrix to the value of another matrix.


setZero

public Matrix4 setZero()
Sets this matrix to all zeros.


setIdentity

public Matrix4 setIdentity()
Sets this matrix to the identity matrix.


setTranslation

public Matrix4 setTranslation(Tuple3 tuple)
Sets the whole matrix to translate by the specified amount. If the tuple represents a point, the matrix will transform a point at (0,0,0) that point.


setScale

public Matrix4 setScale(Tuple3 tuple)
Sets the whole matrix to scale by the specified amount. If the tuple is a point, the matrix will transform a point at (1,1,1) to that point.


transform

public Point3 transform(Point3 point,
                        Point3 retVal)
Transforms a point by pre-multiplying it by this matrix. Assumes the fourth dimension of the point is one.

Parameters:
point - Value of the input point. Never null.
retVal - Return value object. The transformed point. Can be the same as point. Never null.

transform

public Vector3 transform(Vector3 vector,
                         Vector3 retVal)
Transforms a vector by pre-multiplying it by this matrix. Assumes the fourth dimension of the vector is zero (invariant to translation).

Parameters:
vector - Value of the input vector. Never null.
retVal - Return value object. The transformed vector. Can be the same as vector. Never null.

transform

public Matrix4 transform(Matrix4 matrix,
                         Matrix4 retVal)
Transforms a matrix by pre-multiplying it by this matrix.

Parameters:
matrix - Value of the input matrix. Never null.
retVal - Return value object. The transformed matrix. Can be the same as matrix or this matrix. Never null.

inverse

public Matrix4 inverse(Matrix4 retVal)
Inverts this matrix.

Parameters:
retVal - Return value object. The inverted matrix. Can be the same as this matrix. Never null.

get

public double[][] get(double[][] retVal)
Master whole state accessor.


getMatrix4

public Matrix4 getMatrix4()
Gets a singleton immutable view of this object with the same identity (hashCode(), equals()) as this object.

Returns:
The view. Never null.

get

public Matrix4 get(Matrix4 retVal)

getGraphic

public java.lang.Object getGraphic()
Default implementation: Returns this (non-native implementation).

Specified by:
getGraphic in interface Graphic
Returns:
The target graphic object. Possibly this object (self-proxy, direct implementation), but never null.

toString

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

clearArray

public static void clearArray(double[][] val)
Sets length 4x4 array to all zeros.


clearArray

public static void clearArray(double[] val)
Sets a length 4 array to all zeros.