yage.core.math.matrix
Authors:
Eric Poggel, Matt Peterson
License:
LGPL v3
- struct
Matrix
;
- A 4x4 matrix class for 3D transformations.
Column major order is used, just like OpenGL. This is defined as a struct instead of a
class so it can be created and destroyed without any dynamic memory allocation.
The Euler operations may be unreliable and should be used cautiously.
See Also:
Wikipedia: Transformation
Matrix
The
Matrix
and Quaternion Faq
- float[16u]
v
;
- elements in array form.
The 16 values of the Matrix.
- float
v00
;
- The 16 values of the Matrix.
- float
v01
;
- The 16 values of the Matrix.
- float
v02
;
- The 16 values of the Matrix.
- float
v03
;
- first column
The 16 values of the Matrix.
- float
v10
;
- The 16 values of the Matrix.
- float
v11
;
- The 16 values of the Matrix.
- float
v12
;
- The 16 values of the Matrix.
- float
v13
;
- second column
The 16 values of the Matrix.
- float
v20
;
- The 16 values of the Matrix.
- float
v21
;
- The 16 values of the Matrix.
- float
v22
;
- The 16 values of the Matrix.
- float
v23
;
- third column
The 16 values of the Matrix.
- float
v30
;
- The 16 values of the Matrix.
- float
v31
;
- The 16 values of the Matrix.
- float
v32
;
- The 16 values of the Matrix.
- float
v33
;
- fourth column
The 16 values of the Matrix.
- static Matrix
IDENTITY
;
- static Matrix
opCall
();
- Create an identity Matrix.
- static Matrix
opCall
(float[] values);
- Create a Matrix from a float[16].
- static Matrix
opCall
(float left, float right, float bottom, float top, float near, float far);
- Create an Orthographic Matrix
- bool
almostEqual
(Matrix s, float fudge = 0.0001F);
- Is this Matrix equal to Matrix s, discarding relative error fudge.
- void
decompose
(out Matrix position, out Matrix rotation, out Matrix scale);
- Decompose this Matrix into a position, rotation, and scaling Matrix.
- float
determinant
();
- Return the
determinant
of the Matrix.
- Vec3f
getPosition
();
- Get the position component of the Matrix as a Vector.
- Vec3f
getScale
();
- Extract the scale Vector from the rotation component of the Matrix.
Scale components will always be positive.
- Matrix
inverse
();
- Return a copy of this Matrix that has been inverted.
Throws an exception if this Matrix has no inverse. This occurs when the determinant is zero.
- bool
isIdentity
();
- Is this an identity Matrix?
- bool
isUniformScale
();
- Returns true
if all components of the scale are the same.
This is much faster than calling toScale() and comparing elements.
TODO:
make this count almost uniform as uniform, to fix floating point errors.
- Matrix
move
(Vec3f vec);
- Return a copy of this Matrix with its position values incremented by vec.
- Matrix
moveRelative
(Vec3f direction);
- Return a copy of this Matrix with its position values incremented relative to its rotation.
Consider it to be moved in the direction that it's currently rotated.
- Matrix
negate
();
- Return a copy of this Matrix with all values negated.
- float
opIndex
(uint i);
- Get element i from the Matrix
- float
opIndexAssign
(float value, uint i);
- Assign a value to element i.
- Vec3f
opMul
(Vec3f vec);
- Multiply this matrix by the 3-component Vec3f; assumes the 4th Vec3f component is 1.
This is the equivalent of transforming the Vector by this Matrix.
- Matrix
opMul
(Matrix b);
- Multiply two matrices and return a third Matrix result.
- Matrix
opMulAssign
(Matrix b);
- Multiply this Matrix by another matrix and store the result in this Matrix.
- float*
ptr
();
- Matrix
rotate
(Vec3f axis);
Matrix
rotate
(Quatrn rotation);
Matrix
rotate
(Matrix b);
- Return a copy of this Matrix rotated by the rotation values of an axis-angle Vector, a Quaternion, or another Matrix.
For Matrix rotation, this is equivalent to a post-multiplication of only the rotation values.
- Matrix
rotatePreservingScale
(T)(T rot);
- In a Matrix, rotation and scale are intimately related.
This decomposes the matrix, applies the rotation only to the rotation component, and then recomposes it.
TODO:
This is the leading cause of Matrix drift when the scale isn't uniform!
In a Matrix, rotation and scale are intimately related.
This decomposes the matrix, applies the rotation only to the rotation component, and then recomposes it.
TODO:
This is the leading cause of Matrix drift when the scale isn't uniform!
ditto
- Matrix
rotateEuler
(Vec3f euler);
- Return a copy of this Matrix with its rotation values incremented by a Vec3f of Euler rotation angles,
relative to it's current rotation axis. First by x, then y, then z.
This function hasn't been verified to be correct in all circumstances.
- Matrix
rotateEulerAbsolute
(Vec3f euler);
- The same as above, but rotated around the absolute worldspace axis.
This function hasn't been verified to be correct in all circumstances.
- Matrix
scale
(Vec3f s);
- Return a copy of this Matrix scaled by s
- void
setPosition
(Vec3f position);
- void
setRotation
(Matrix rot);
void
setRotation
(Quatrn rot);
void
setRotation
(Vec3f axis);
- Set the rotation values of this Matrix from another Matrix, Quaternion, or axis-angle Vector.
- void
setRotationPreservingScale
(T)(T rot);
- Set the rotation while taking extra steps to preserve the Matrices scaling values.
- void
setRotationEuler
(Vec3f euler);
- Set the rotation values of the matrix from a vector containing euler angles.
- void
setScalePreservingRotation
(Vec3f scale);
- Set the scale component of the Matrix, taking extra steps to preserve any
rotation values already present in the scale part of the Matrix.
- Vec3f
toAxis
();
- Return an axis vector of the rotation values of this Matrix.
Note that the non-rotation values of the Matrix are lost.
- Quatrn
toQuatrn
();
- Return the rotation values of this Matrix as a Quatern.
Note that the non-rotation values of the Matrix are lost.
- Vec3f
toEuler
();
- Convert the rotation part of the Matrix to Euler angles.
This may be inaccurate and perhaps suffers from other faults.
- Matrix
transformAffine
(Matrix b);
- Multiply two matrices and return a third Matrix result, ignoring values that aren't needed
in affine transformations. This makes it almost half the operations of a Matrix multiplication.
- Matrix
transpose
();
- Return the
transpose
of the Matrix. This is equivalent to
converting a column-major Matrix to a row-major Matrix.
- char[]
toString
();
- Create a string representation of this Matrix for human reading.
|