28 #include <android/log.h>
35 1.0f, 0.0f, 0.0f, 0.0f,
36 0.0f, 1.0f, 0.0f, 0.0f,
37 0.0f, 0.0f, 1.0f, 0.0f,
38 0.0f, 0.0f, 0.0f, 1.0f,
45 memcpy(
elements, array, 16 *
sizeof(
float));
70 memcpy(this->
elements, another.elements, 16 *
sizeof(
float));
86 result.elements[ 5] =
y;
87 result.elements[10] = z;
97 result.elements[13] =
y;
98 result.elements[14] = z;
107 FOV = 1.0f / tan(FOV * 0.5
f);
109 result.elements[ 0] = FOV / ratio;
110 result.elements[ 5] = FOV;
111 result.elements[10] = -(zFar + zNear) / (zFar - zNear);
112 result.elements[11] = -1.0f;
113 result.elements[14] = (-2.0f * zFar * zNear) / (zFar - zNear);
114 result.elements[15] = 0.0f;
124 for(
int row = 0; row < 4; row ++)
126 for(
int column = 0; column < 4; column ++)
128 float accumulator = 0.0f;
129 for(
int allElements = 0; allElements < 4; allElements ++)
131 accumulator += left->elements[allElements * 4 + row] * right->elements[column * 4 + allElements];
133 result.elements[column * 4 + row] = accumulator;
const float identityArray[16]
float & operator[](unsigned element)
Array operator for accessing the elements of the matrix.
Matrix operator*(Matrix right)
Multiply operator to post multiply a matrix by another.
static Matrix identityMatrix
The identity matrix.
Matrix(void)
Default constructor.
static const float identityArray[]
A 4x4 identity Matrix;.
static Matrix createTranslation(float x, float y, float z)
Create and return a translation matrix.
static Matrix createScaling(float x, float y, float z)
Create and return a scaling matrix.
static Matrix matrixPerspective(float FOV, float ratio, float zNear, float zFar)
Create and return a perspective projection matrix.
float * getAsArray(void)
Get the matrix elements as a column major order array.
GLint GLint GLint GLint GLint x
static Matrix multiply(Matrix *left, Matrix *right)
Multiply 2 matrices to return a third.
Matrix & operator=(const Matrix &another)
Overloading assingment operater to do deep copy of the Matrix elements.
float elements[16]
A 16 element floating point array used to represent a 4x4 matrix.