NASA World Wind

gov.nasa.worldwind.geom
Class Matrix4

java.lang.Object
  extended by gov.nasa.worldwind.geom.Matrix4
All Implemented Interfaces:
Matrix

public class Matrix4
extends Object
implements Matrix


Constructor Summary
Matrix4()
          Creates a new Matrix4 as the identity matrix.
Matrix4(double[] entries)
          Creates a new Matrix4 from an array of double precision floating point values.
Matrix4(float[] entries)
          Creates a new Matrix4 from an array of single precision floating point values.
 
Method Summary
 Matrix add(Matrix m)
          Adds this another matrix to this one.
 double determinant()
          Obtains the determinant of this Matrix.
 boolean equals(Object o)
           
 double[] getEntries()
          Retrieves the entries comprising this Matrix.
 Matrix getInverse()
          Obtain the inverse of this Matrix.
 Matrix getTranspose()
          Obtains the transpose of this Matrix.
 int hashCode()
           
 boolean isOrthonormal()
          Obtains whether or not this Matrix is orthonormal.
 Matrix multiply(Matrix m)
          Performs a cross multiplication with another Matrix.
 Matrix rotate(Angle rotation, double axisX, double axisY, double axisZ)
          Rotate this matrix by some angle around an arbitrary axis.
 Matrix rotateX(Angle rotation)
          Rotate this Matrix around the x-axis.
 Matrix rotateY(Angle rotation)
          Rotate this Matrix around the y-axis.
 Matrix rotateZ(Angle rotation)
          Rotate this Matrix around the z-axis.
 Matrix setToIdentity()
          Sets this Matrix to the identity matrix.
 String toString()
           
 Point transform(Point p)
          Applies this Matrix to a Point.
 Matrix translate(double x, double y, double z)
          Translates this Matrix in three dimensional space.
 Matrix translate(Point p)
          Translates this Matrix in three dimansional space.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix4

public Matrix4()
Creates a new Matrix4 as the identity matrix.


Matrix4

public Matrix4(double[] entries)
Creates a new Matrix4 from an array of double precision floating point values. The caller must provide at least sixteen values, and any values beyond the sixteenth are ignored. Values are assigned in the following order: (1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2), (3, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4).

Parameters:
entries - the values, must contain at least 16 values and may not be null
Throws:
IllegalArgumentException - if entries is too short or null

Matrix4

public Matrix4(float[] entries)
Creates a new Matrix4 from an array of single precision floating point values. The caller must provide at least sixteen values, and any values beyond the sixteenth are ignored. Values are assigned in the following order: (1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2), (3, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4).

Parameters:
entries - the values, must contain at least 16 values and may not be null
Throws:
IllegalArgumentException - if entries is too short or null
Method Detail

add

public final Matrix add(Matrix m)
Adds this another matrix to this one.

Specified by:
add in interface Matrix
Parameters:
m - the Matrix to add to this one
Returns:
this Matrix, with the m added to it
Throws:
IllegalArgumentException - if m is null

determinant

public final double determinant()
Obtains the determinant of this Matrix.

Specified by:
determinant in interface Matrix
Returns:
the determinant

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getEntries

public final double[] getEntries()
Retrieves the entries comprising this Matrix. The returned array is always 16 entries long. Values are place in as in the aray as follows: (1, 1), (2, 1), (3, 1), (4, 1), (1, 2), (2, 2), (3, 2), (4, 2), (3, 3), (2, 3), (3, 3), (4, 3), (1, 4), (2, 4), (3, 4), (4, 4).

Specified by:
getEntries in interface Matrix
Returns:
an array, of length 16, containing this Matrices' entries.

getInverse

public final Matrix getInverse()
Obtain the inverse of this Matrix.

Specified by:
getInverse in interface Matrix
Returns:
the inverse of this Matrix.

getTranspose

public final Matrix getTranspose()
Obtains the transpose of this Matrix. Does not alter the state of this Matrix.

Specified by:
getTranspose in interface Matrix
Returns:
the transpoase of this Matrix

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isOrthonormal

public final boolean isOrthonormal()
Obtains whether or not this Matrix is orthonormal. Orthonormal matrices possess unique properties that can make algorithms more efficient.

Specified by:
isOrthonormal in interface Matrix
Returns:
true if this is orthonormal, false otherwise

multiply

public final Matrix multiply(Matrix m)
Performs a cross multiplication with another Matrix. Alters the state of this Matrix.

Specified by:
multiply in interface Matrix
Parameters:
m - another Matrix
Returns:
this, postmultiplied by m
Throws:
IllegalArgumentException - if m is null

rotate

public final Matrix rotate(Angle rotation,
                           double axisX,
                           double axisY,
                           double axisZ)
Rotate this matrix by some angle around an arbitrary axis. A positive Angle indicates an anti-clockwise direction. This method affects the internal state of this matrix.

Specified by:
rotate in interface Matrix
Parameters:
rotation - the distance to rotate this matrix
axisX - the x component of the axis of rotation
axisY - the y component of the axis of rotation
axisZ - the z component of the axis of rotation
Returns:
this Matrix, with the rotation applied
Throws:
IllegalArgumentException - if rotation is null

rotateX

public final Matrix rotateX(Angle rotation)
Rotate this Matrix around the x-axis. A positive Angle indicates an anti-clockwise direction. Changes the internal state of this Matrix.

Specified by:
rotateX in interface Matrix
Parameters:
rotation - the distance to rotate
Returns:
this Matrix, rotated around the x-axis by rotation distance
Throws:
IllegalArgumentException - if rotation is null

rotateY

public final Matrix rotateY(Angle rotation)
Rotate this Matrix around the y-axis. A positive Angle indicates an anti-clockwise direction. Changes the internal state of this Matrix.

Specified by:
rotateY in interface Matrix
Parameters:
rotation - the distance to rotate
Returns:
this Matrix, rotated around the y-axis by rotation distance
Throws:
IllegalArgumentException - if rotation is null

rotateZ

public final Matrix rotateZ(Angle rotation)
Rotate this Matrix around the z-axis. A positive Angle indicates an anti-clockwise direction. Changes the internal state of this Matrix.

Specified by:
rotateZ in interface Matrix
Parameters:
rotation - the distance to rotate
Returns:
this Matrix, rotated around the z-axis by rotation distance
Throws:
IllegalArgumentException - if rotation is null

setToIdentity

public final Matrix setToIdentity()
Sets this Matrix to the identity matrix. This method causes internal changes to the Matrix it operates on.

Specified by:
setToIdentity in interface Matrix
Returns:
this, set to the identity

toString

public String toString()
Overrides:
toString in class Object

transform

public final Point transform(Point p)
Applies this Matrix to a Point.

Specified by:
transform in interface Matrix
Parameters:
p - the Point to transform
Returns:
p, trasformed by the current state of this Matrix
Throws:
IllegalArgumentException - if p is null

translate

public Matrix translate(double x,
                        double y,
                        double z)
Translates this Matrix in three dimensional space. Changes the internal state of this Matrix.

Specified by:
translate in interface Matrix
Parameters:
x - the distance to translate along the x-axis
y - the distance to translate along the y-axis
z - the distance to translate along the z-axis
Returns:
this matrix, translated by (x, y, z)

translate

public final Matrix translate(Point p)
Translates this Matrix in three dimansional space. Changes the internal state of this Matrix. The x, y and z co-ordinates are used to translate along the x, y and z axes respectively.

Specified by:
translate in interface Matrix
Parameters:
p - the x, y and z distances to translate as a Point
Returns:
this Matrix, translated by the distances defined in p
Throws:
IllegalArgumentException - if p is null

NASA World Wind