net.jinx.math
Class Matrix3

java.lang.Object
  extended by net.jinx.math.Matrix3

public class Matrix3
extends java.lang.Object

Matrix3 is a 3x3 matrix class, suitable for graphics and physics operations.

API Stability: Beta.


Field Summary
static Matrix3 IDENTITY
          The indetity Matrix3 is usually your starting point for building a transformation Matrix3
 
Constructor Summary
Matrix3(float[] values)
          Constructs a Matrix3 using an array of floats.
Matrix3(Vector r1, Vector r2, Vector r3)
          Constructs a Matrix3 from four Quaternions.
 
Method Summary
 Matrix3 add(Matrix3 m)
           
 boolean equals(java.lang.Object obj)
           
 float get(int row, int col)
          Returns a given element of this Matrix3 The indices are not zero based, like an array.
 Matrix3 multiply(float v)
          Multiplies this Matrix3 by v.
 Matrix3 multiply(Matrix3 m)
          Multiplies m (the multiplicand) by this (the multiplier).
 Matrix3 rotate(Quaternion q)
          Applies a rotation transformation and returns the result.
 Matrix3 rotate(Vector v)
          Applies a rotation transformation and returns the result.
 Matrix3 rotateX(float t)
          Applies a rotation transformation and returns the result.
 Matrix3 rotateY(float t)
          Applies a rotation transformation and returns the result.
 Matrix3 rotateZ(float t)
          Applies a rotation transformation and returns the result.
static Matrix3 rotationMatrix(Quaternion q)
          Constructs a rotation Matrix3 for q.
static Matrix3 rotationMatrix(Vector v)
          Constructs a rotation Matrix3 for v.
 Matrix3 scale(float s)
          Applies a scale transformation and returns the result.
 Matrix3 scale(float x, float y, float z)
          Applies a scale transformation and returns the result.
 Matrix3 scale(Vector v)
          Applies a scale transformation and returns the result.
static Matrix3 scalingMatrix(float s)
          Constructs a scaling Matrix3
static Matrix3 scalingMatrix(float vx, float vy, float vz)
          Constructs a scaling Matrix3
static Matrix3 scalingMatrix(Vector v)
          Constructs a scaling Matrix3
 Matrix3 subtract(Matrix3 m)
           
 float[] toFloatArray()
          Converts this Matrix3 to a column ordered float array.
 java.lang.String toString()
           
 void transform(float[] v)
          Transforms v as though it were either a Vector or a Quaternion (depending on length), modifying the array with the result.
 void transform(float[][] va)
          Transforms a vertex array.
 float[] transform(float xv, float yv, float zv)
          Transforms vx, vy, vz, and vw as though they were a Vector and returns the result.
 Vector transform(Vector v)
          Transforms v and returns the result.
 Matrix3 transpose()
          Returns a transposed version of this Matrix3
static Matrix3 xRotationMatrix(float t)
          Constructs a rotation Matrix3 for rotating around the X axis.
static Matrix3 yRotationMatrix(float t)
          Constructs a rotation Matrix3 for rotating around the Y axis.
static Matrix3 zRotationMatrix(float t)
          Constructs a rotation Matrix3 for rotating around the Z axis.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTITY

public static final Matrix3 IDENTITY
The indetity Matrix3 is usually your starting point for building a transformation Matrix3

Constructor Detail

Matrix3

public Matrix3(Vector r1,
               Vector r2,
               Vector r3)
Constructs a Matrix3 from four Quaternions.

Parameters:
r1 - the first row.
r2 - the first row.
r3 - the first row.

Matrix3

public Matrix3(float[] values)
Constructs a Matrix3 using an array of floats.

Parameters:
values - the floats to use., in column order.
Method Detail

equals

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

get

public float get(int row,
                 int col)
Returns a given element of this Matrix3 The indices are not zero based, like an array. They're one based, because that is the natural, mathematical way to look at it (at least according to the references I've read).

Parameters:
row - the row to access.
col - the column to access.
Returns:
the value of the accessed element.

transpose

public Matrix3 transpose()
Returns a transposed version of this Matrix3

Returns:
the resulting Matrix3

transform

public void transform(float[][] va)
Transforms a vertex array. See the net.jinx.video.model.VertexUtil class in the modeler's API docs for more information.

Parameters:
va - the vertex array.

transform

public void transform(float[] v)
Transforms v as though it were either a Vector or a Quaternion (depending on length), modifying the array with the result.

Parameters:
v - the float array.

transform

public float[] transform(float xv,
                         float yv,
                         float zv)
Transforms vx, vy, vz, and vw as though they were a Vector and returns the result.

Parameters:
xv - the X component.
yv - the Y component.
zv - the Z component.
Returns:
the resulting float array.

transform

public Vector transform(Vector v)
Transforms v and returns the result.

Parameters:
v - the Vector to transform.
Returns:
the resulting Vector.

add

public Matrix3 add(Matrix3 m)

subtract

public Matrix3 subtract(Matrix3 m)

multiply

public Matrix3 multiply(float v)
Multiplies this Matrix3 by v.

Parameters:
v - the float to multiply by.
Returns:
the resulting Matrix3.

multiply

public Matrix3 multiply(Matrix3 m)
Multiplies m (the multiplicand) by this (the multiplier). The order of operations for this is important! Reversing the order will not work the same! In addition, Java will not take care of the ordering for you. You must be very careful to order your operations the way they need to occur!

Parameters:
m - the multiplicand.
Returns:
the resulting Matrix3

scale

public Matrix3 scale(Vector v)
Applies a scale transformation and returns the result.

Parameters:
v - the Vector containing scaling factors for the three axes.
Returns:
the resulting Matrix3 This one isn't modified.

scale

public Matrix3 scale(float s)
Applies a scale transformation and returns the result.

Parameters:
s - the scaling factor for all three axes.
Returns:
the resulting Matrix3 This one isn't modified.

scale

public Matrix3 scale(float x,
                     float y,
                     float z)
Applies a scale transformation and returns the result.

Parameters:
x - the scaling factor along the X axis.
y - the scaling factor along the Y axis.
z - the scaling factor along the Z axis.
Returns:
the resulting Matrix3 This one isn't modified.

rotateX

public Matrix3 rotateX(float t)
Applies a rotation transformation and returns the result.

Parameters:
t - the angle of rotation used to rotate around the X axis.
Returns:
the resulting Matrix3 This one isn't modified.

rotateY

public Matrix3 rotateY(float t)
Applies a rotation transformation and returns the result.

Parameters:
t - the angle of rotation used to rotate around the Y axis.
Returns:
the resulting Matrix3 This one isn't modified.

rotateZ

public Matrix3 rotateZ(float t)
Applies a rotation transformation and returns the result.

Parameters:
t - the angle of rotation used to rotate around the Z axis.
Returns:
the resulting Matrix3 This one isn't modified.

rotate

public Matrix3 rotate(Vector v)
Applies a rotation transformation and returns the result.

Parameters:
v - the Vector representing the rotation.
Returns:
the resulting Matrix3 This one isn't modified.

rotate

public Matrix3 rotate(Quaternion q)
Applies a rotation transformation and returns the result.

Parameters:
q - the Quaternion representing the rotation.
Returns:
the resulting Matrix3 This one isn't modified.

toFloatArray

public float[] toFloatArray()
Converts this Matrix3 to a column ordered float array.

Returns:
the array.

toString

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

scalingMatrix

public static Matrix3 scalingMatrix(float s)
Constructs a scaling Matrix3

Parameters:
s - the scaling factor all three axes.
Returns:
the Matrix3

scalingMatrix

public static Matrix3 scalingMatrix(Vector v)
Constructs a scaling Matrix3

Parameters:
v - the scaling Vector with factors for the three axes.
Returns:
the Matrix3

scalingMatrix

public static Matrix3 scalingMatrix(float vx,
                                    float vy,
                                    float vz)
Constructs a scaling Matrix3

Parameters:
vx - the scaling factor along the X axis.
vy - the scaling factor along the Y axis.
vz - the scaling factor along the Z axis.
Returns:
the Matrix3

xRotationMatrix

public static Matrix3 xRotationMatrix(float t)
Constructs a rotation Matrix3 for rotating around the X axis.

Parameters:
t - (short for theta) the angle of rotation.
Returns:
the Matrix3

yRotationMatrix

public static Matrix3 yRotationMatrix(float t)
Constructs a rotation Matrix3 for rotating around the Y axis.

Parameters:
t - (short for theta) the angle of rotation.
Returns:
the Matrix3

zRotationMatrix

public static Matrix3 zRotationMatrix(float t)
Constructs a rotation Matrix3 for rotating around the Z axis.

Parameters:
t - (short for theta) the angle of rotation.
Returns:
the Matrix3

rotationMatrix

public static Matrix3 rotationMatrix(Vector v)
Constructs a rotation Matrix3 for v. Each component of v describes how much to rotate azround it's axis.

Parameters:
v - the Vector describing a 3D rotation.
Returns:
the Matrix3

rotationMatrix

public static Matrix3 rotationMatrix(Quaternion q)
Constructs a rotation Matrix3 for q.

Parameters:
q - the Quaternion being used to represent a 3D rotation.
Returns:
the Matrix3