|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.math.Matrix4
public class Matrix4
Matrix4 is a 4x4 matrix class intended for graphical tranformation
operations, however, it isn't designed in the typical fashion of most
graphical Matrix classes I've seen. It's immutable, just like the rest of
the classes in this package. I may change that in the future; I'm not sure,
because making it mutable would make the API faster, but prone to errors such
as accidentally overwriting a Matrix4 at the wrong time (I usually prefer
ease of use, since modern machines are so darn fast and Java's garbage
collector is much better than it used to be).
API Stability: Beta.
Field Summary | |
---|---|
static Matrix4 |
IDENTITY
The indetity Matrix4 is usually your starting point for building a transformation Matrix4. |
Constructor Summary | |
---|---|
Matrix4(float[] values)
Constructs a Matrix4 using an array of floats. |
|
Matrix4(Quaternion r1,
Quaternion r2,
Quaternion r3,
Quaternion r4)
Constructs a Matrix4 from four Quaternions. |
Method Summary | |
---|---|
Matrix4 |
add(Matrix4 m)
|
Matrix4 |
applyPerspective(float d)
Applies a perspective transformation and returns the result. |
boolean |
equals(java.lang.Object obj)
|
float |
get(int row,
int col)
Returns a given element of this Matrix. |
Matrix4 |
multiply(float v)
Multiplies this Matrix4 by v. |
Matrix4 |
multiply(Matrix4 m)
Multiplies m (the multiplicand) by this (the multiplier). |
static Matrix4 |
perspectiveMatrix(float d)
Constructs a perspective transformation Matrix. |
Matrix4 |
rotate(Quaternion q)
Applies a rotation transformation and returns the result. |
Matrix4 |
rotate(Vector v)
Applies a rotation transformation and returns the result. |
Matrix4 |
rotateX(float t)
Applies a rotation transformation and returns the result. |
Matrix4 |
rotateY(float t)
Applies a rotation transformation and returns the result. |
Matrix4 |
rotateZ(float t)
Applies a rotation transformation and returns the result. |
static Matrix4 |
rotationMatrix(float x,
float y,
float z)
Constructs a rotation Matrix4. |
static Matrix4 |
rotationMatrix(Quaternion q)
Constructs a rotation Matrix4 for q. |
static Matrix4 |
rotationMatrix(Vector v)
Constructs a rotation Matrix4 for v. |
Matrix4 |
scale(float s)
Applies a scale transformation and returns the result. |
Matrix4 |
scale(float x,
float y,
float z)
Applies a scale transformation and returns the result. |
Matrix4 |
scale(Vector v)
Applies a scale transformation and returns the result. |
static Matrix4 |
scalingMatrix(float s)
Constructs a scaling Matrix. |
static Matrix4 |
scalingMatrix(float vx,
float vy,
float vz)
Constructs a scaling Matrix. |
static Matrix4 |
scalingMatrix(Vector v)
Constructs a scaling Matrix. |
Matrix4 |
subtract(Matrix4 m)
|
float[] |
toFloatArray()
Converts this Matrix4 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 the parameters as though they were a Vector and returns the result. |
float[] |
transform(float xv,
float yv,
float zv,
float wv)
Transforms vx, vy, vz, and vw as though they were a Quaternion and returns the result. |
Quaternion |
transform(Quaternion v)
Transforms v and returns the result. |
Quaternion[] |
transform(Quaternion[] v)
Transforms an array of Quaternions and returns the result. |
Vector |
transform(Vector v)
Transforms v and returns the result. |
Vector[] |
transform(Vector[] v)
Transforms an array of Vectors and returns the result. |
Matrix4 |
translate(Vector v)
Applies a translation transformation and returns the result. |
static Matrix4 |
translationMatrix(float x,
float y,
float z)
Constructs a translation Matrix4. |
static Matrix4 |
translationMatrix(Vector v)
Constructs a translation Matrix. |
Matrix4 |
transpose()
Returns a transposed version of this Matrix. |
static Matrix4 |
xRotationMatrix(float t)
Constructs a rotation Matrix4 for rotating around the X axis. |
static Matrix4 |
yRotationMatrix(float t)
Constructs a rotation Matrix4 for rotating around the Y axis. |
static Matrix4 |
zRotationMatrix(float t)
Constructs a rotation Matrix4 for rotating around the Z axis. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Matrix4 IDENTITY
Constructor Detail |
---|
public Matrix4(Quaternion r1, Quaternion r2, Quaternion r3, Quaternion r4)
r1
- the first row.r2
- the first row.r3
- the first row.r4
- the first row.public Matrix4(float[] values)
values
- the floats to use, in column order.Method Detail |
---|
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public float get(int row, int col)
row
- the row to access.col
- the column to access.
public Matrix4 transpose()
public void transform(float[][] va)
va
- the vertex array.public void transform(float[] v)
v
- the float array.public float[] transform(float xv, float yv, float zv)
xv
- the X component.yv
- the Y component.zv
- the Z component.
public float[] transform(float xv, float yv, float zv, float wv)
xv
- the X component.yv
- the Y component.zv
- the Z component.wv
- the W component.
public Vector[] transform(Vector[] v)
v
- the arracy of Vectors to transform.
public Vector transform(Vector v)
v
- the Vector to transform.
public Quaternion[] transform(Quaternion[] v)
v
- the arracy of Quaternions to transform.
public Quaternion transform(Quaternion v)
v
- the Quaternion to transform.
public Matrix4 add(Matrix4 m)
public Matrix4 subtract(Matrix4 m)
public Matrix4 multiply(float v)
v
- the float to multiply by.
public Matrix4 multiply(Matrix4 m)
m
- the multiplicand.
public Matrix4 translate(Vector v)
v
- the Vector holding values for translation along the three axes.
public Matrix4 scale(Vector v)
v
- the Vector containing scaling factors for the three axes.
public Matrix4 scale(float s)
s
- the scaling factor for all three axes.
public Matrix4 scale(float x, float y, float z)
x
- the scaling factor along the X axis.y
- the scaling factor along the Y axis.z
- the scaling factor along the Z axis.
public Matrix4 rotateX(float t)
t
- the angle of rotation used to rotate around the X axis.
public Matrix4 rotateY(float t)
t
- the angle of rotation used to rotate around the Y axis.
public Matrix4 rotateZ(float t)
t
- the angle of rotation used to rotate around the Z axis.
public Matrix4 rotate(Vector v)
v
- the Vector representing the rotation.
public Matrix4 rotate(Quaternion q)
q
- the Quaternion representing the rotation.
public Matrix4 applyPerspective(float d)
d
- the distance from the viewpoint to the viewpane.
public float[] toFloatArray()
public java.lang.String toString()
toString
in class java.lang.Object
public static Matrix4 translationMatrix(Vector v)
v
- the Vector to translate by.
public static Matrix4 translationMatrix(float x, float y, float z)
x
- the x translation.y
- the y translation.z
- the z translation.
public static Matrix4 scalingMatrix(float s)
s
- the scaling factor all three axes.
public static Matrix4 scalingMatrix(Vector v)
v
- the scaling Vector with factors for the three axes.
public static Matrix4 scalingMatrix(float vx, float vy, float vz)
vx
- the scaling factor along the X axis.vy
- the scaling factor along the Y axis.vz
- the scaling factor along the Z axis.
public static Matrix4 xRotationMatrix(float t)
t
- (short for theta) the angle of rotation.
public static Matrix4 yRotationMatrix(float t)
t
- (short for theta) the angle of rotation.
public static Matrix4 zRotationMatrix(float t)
t
- (short for theta) the angle of rotation.
public static Matrix4 perspectiveMatrix(float d)
d
- the distance from the viewpoint and the viewing plane.
public static Matrix4 rotationMatrix(Vector v)
v
- the Vector describing a 3D rotation.
public static Matrix4 rotationMatrix(float x, float y, float z)
x
- the x rotation.y
- the y rotation.z
- the z rotation.
public static Matrix4 rotationMatrix(Quaternion q)
q
- the Quaternion being used to represent a 3D rotation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |