28 namespace AstcTextures
33 1.0f, 0.0f, 0.0f, 0.0f,
34 0.0f, 1.0f, 0.0f, 0.0f,
35 0.0f, 0.0f, 1.0f, 0.0f,
36 0.0f, 0.0f, 0.0f, 1.0f
42 memcpy(
elements, array, 16 *
sizeof(
float));
62 LOGE(
"Matrix only has 16 elements, tried to access element %d", element);
97 result.
elements[10] = -2.0f / (zFar - zNear);
98 result.
elements[14] = -(zFar + zNear) / (zFar - zNear);
108 FOV = 1.0f / tan(FOV * 0.5
f);
112 result.
elements[10] = -(zFar + zNear) / (zFar - zNear);
114 result.
elements[14] = (-2.0f * zFar * zNear) / (zFar - zNear);
124 float angle_converted_to_radians =
M_PI * angle / 180.0f;
126 result.
elements[5] = cosf(angle_converted_to_radians);
127 result.
elements[9] = -sinf(angle_converted_to_radians);
128 result.
elements[6] = sinf(angle_converted_to_radians);
129 result.
elements[10] = cosf(angle_converted_to_radians);
138 float angle_converted_to_radians =
M_PI * angle / 180.0f;
140 result.
elements[0] = cosf(angle_converted_to_radians);
141 result.
elements[8] = sinf(angle_converted_to_radians);
142 result.
elements[2] = -sinf(angle_converted_to_radians);
143 result.
elements[10] = cosf(angle_converted_to_radians);
152 float angle_converted_to_radians =
M_PI * angle / 180.0f;
154 result.
elements[0] = cosf(angle_converted_to_radians);
155 result.
elements[4] = -sinf(angle_converted_to_radians);
156 result.
elements[1] = sinf(angle_converted_to_radians);
157 result.
elements[5] = cosf(angle_converted_to_radians);
167 for(
int row = 0; row < 4; row++)
169 for(
int column = 0; column < 4; column ++)
171 float accumulator = 0.0f;
173 for(
int allElements = 0; allElements < 4; allElements ++)
175 accumulator += left->
elements[allElements * 4 + row] * right->
elements[column * 4 + allElements];
178 result.
elements[column * 4 + row] = accumulator;
const float identityArray[16]
static Matrix identityMatrix
The identity matrix.
static Matrix createRotationY(float angle)
Create and return a rotation matrix around the y-axis matrix.
Functions for manipulating matrices.
static Matrix matrixOrthographic(float left, float right, float bottom, float top, float zNear, float zFar)
Create and return an orthographic projection matrix.
float & operator[](unsigned element)
Array operator for accessing the elements of the matrix.
static const float identityArray[]
A 4x4 identity Matrix;.
#define M_PI
The value of pi.
Matrix operator*(Matrix right)
Multiply operator to post multiply a matrix by another.
static Matrix createRotationX(float angle)
Create and return a rotation matrix around the x-axis matrix.
static Matrix multiply(Matrix *left, Matrix *right)
Multiply 2 matrices to return a third.
float * getAsArray(void)
Get the matrix elements as a column major order array.
Matrix & operator=(const Matrix &another)
Overloading assingment operater to do deep copy of the Matrix elements.
static Matrix createRotationZ(float angle)
Create and return a rotation matrix around the z-axis matrix.
static Matrix matrixPerspective(float FOV, float ratio, float zNear, float zFar)
Create and return a perspective projection matrix.
Matrix(void)
Default constructor.
float elements[16]
A 16 element floating point array used to represent a 4x4 matrix.