28#ifndef INCLUDED_OOMATHS_h
29 #error Do not include OOMatrix.h directly; include OOMaths.h.
32typedef struct OOMatrix
101#if OOMATHS_OPENGL_INTEGRATION
103#define OOMatrixValuesForOpenGL(M) (&(M).m[0][0])
104#define GLMultOOMatrix(M) do { OOMatrix m_ = M; OOGL(glMultMatrixf(OOMatrixValuesForOpenGL(m_))); } while (0)
105#define GLLoadOOMatrix(M) do { OOMatrix m_ = M; OOGL(glLoadMatrixf(OOMatrixValuesForOpenGL(m_))); } while (0)
106#define GLMultTransposeOOMatrix(M) do { OOMatrix m_ = M; OOGL(glMultTransposeMatrixf(OOMatrixValuesForOpenGL(m_))); } while (0)
107#define GLLoadTransposeOOMatrix(M) do { OOMatrix m_ = M; OOGL(glLoadTransposeMatrixf(OOMatrixValuesForOpenGL(m_))); } while (0)
108#define GLUniformMatrix(location, M) do { OOGL(glUniformMatrix4fvARB(location, 1, NO, OOMatrixValuesForOpenGL(M))); } while (0)
116NSString *OOMatrixDescription(OOMatrix matrix);
167OOINLINE OOMatrix OOMatrixFromOrientationAndPosition(Quaternion orientation, Vector position)
170 return OOMatrixTranslate(m, position);
174OOINLINE OOMatrix OOMatrixFromBasisVectorsAndPosition(Vector i, Vector j, Vector k, Vector p)
176 return OOMatrixConstruct
186OOINLINE OOMatrix OOMatrixFromBasisVectors(Vector i, Vector j, Vector k)
188 return OOMatrixFromBasisVectorsAndPosition(i, j, k,
kZeroVector);
193OOMatrix OOMatrixForRotationX(
OOScalar angle)
200 return OOMatrixConstruct
210OOMatrix OOMatrixForRotationY(
OOScalar angle)
217 return OOMatrixConstruct
227OOMatrix OOMatrixForRotationZ(
OOScalar angle)
234 return OOMatrixConstruct
244 return OOMatrixConstruct
254OOINLINE OOMatrix OOMatrixForTranslation(Vector v)
256 return OOMatrixForTranslationComponents(v.x, v.y, v.z);
282 return OOMatrixConstruct
294 return OOMatrixForScale(s, s, s);
306 return OOMatrixScale(m, s, s, s);
334OOINLINE OOMatrix OOMatrixRotateQuaternion(OOMatrix m, Quaternion quat)
340OOINLINE bool OOMatrixIsIdentity(OOMatrix m)
346OOINLINE void OOMatrixGetBasisVectors(OOMatrix m, Vector *outRight, Vector *outUp, Vector *outForward)
348 assert(outRight != NULL && outUp != NULL && outForward != NULL);
350 *outRight = make_vector(m.m[0][0], m.m[1][0], m.m[2][0]);
351 *outUp = make_vector(m.m[0][1], m.m[1][1], m.m[2][1]);
352 *outForward = make_vector(m.m[0][2], m.m[1][2], m.m[2][2]);
355OOINLINE OOMatrix OOMatrixTranspose(OOMatrix m)
357 return OOMatrixConstruct
359 m.m[0][0], m.m[1][0], m.m[2][0], m.m[3][0],
360 m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1],
361 m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2],
362 m.m[0][3], m.m[1][3], m.m[2][3], m.m[3][3]
367#if OOMATHS_OPENGL_INTEGRATION
368OOINLINE OOMatrix OOMatrixLoadGLMatrix(GLenum matrixID)
371 glGetFloatv(matrixID, OOMatrixValuesForOpenGL(m));
#define ALWAYS_INLINE_FUNC
#define INLINE_CONST_FUNC
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m)
void OOMatrixColumnSwap(OOMatrix *M, int column1, int column2)
OOMatrix OOMatrixMultiply(OOMatrix a, OOMatrix b)
bool OOMatrixEqual(OOMatrix a, OOMatrix b)
OOMatrix OOMatrixForBillboard(HPVector bbPos, HPVector eyePos)
OOMatrix OOMatrixLeftTransform(OOMatrix A, OOMatrix B)
void GLUniformMatrix3(int location, OOMatrix M)
void OOMatrixColumnOperation(OOMatrix *M, int column1, OOScalar factor1, int column2, OOScalar factor2)
void OOMatrixColumnScale(OOMatrix *M, int column, OOScalar factor)
OOMatrix OOMatrixRightTransform(OOMatrix A, OOMatrix B)
OOMatrix OOMatrixForRotation(Vector axis, OOScalar angle)
OOMatrix OOMatrixOrthogonalize(OOMatrix m)
OOMatrix OOMatrixInverseWithDeterminant(OOMatrix M, OOScalar *d)
void OOMatrixRowSwap(OOMatrix *M, int row1, int row2)
const OOMatrix kIdentityMatrix
void OOMatrixRowScale(OOMatrix *M, int row, OOScalar factor)
Vector OOVectorMultiplyMatrix(Vector v, OOMatrix m)
const OOMatrix kZeroMatrix
OOMatrix OOMatrixInverse(OOMatrix M)
void OOMatrixRowOperation(OOMatrix *M, int row1, OOScalar factor1, int row2, OOScalar factor2)
OOMatrix OOMatrixForQuaternionRotation(Quaternion orientation)