27 namespace AstcTextures
32 1.0f, 0.0f, 0.0f, 0.0f,
33 0.0f, 1.0f, 0.0f, 0.0f,
34 0.0f, 0.0f, 1.0f, 0.0f,
35 0.0f, 0.0f, 0.0f, 1.0f
41 memcpy(
elements, array, 16 *
sizeof(
float));
61 LOGE(
"Matrix only has 16 elements, tried to access element %d", element);
79 memcpy(this->
elements, another.elements, 16 *
sizeof(
float));
91 result.elements[12] = -(right +
left) / (right - left);
93 result.elements[5] = 2.0f / (top -
bottom);
94 result.elements[13] = -(top +
bottom) / (top - bottom);
96 result.elements[10] = -2.0f / (zFar - zNear);
97 result.elements[14] = -(zFar + zNear) / (zFar - zNear);
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;
123 float angle_converted_to_radians =
M_PI * angle / 180.0f;
125 result.elements[5] = cosf(angle_converted_to_radians);
126 result.elements[9] = -sinf(angle_converted_to_radians);
127 result.elements[6] = sinf(angle_converted_to_radians);
128 result.elements[10] = cosf(angle_converted_to_radians);
137 float angle_converted_to_radians =
M_PI * angle / 180.0f;
139 result.elements[0] = cosf(angle_converted_to_radians);
140 result.elements[8] = sinf(angle_converted_to_radians);
141 result.elements[2] = -sinf(angle_converted_to_radians);
142 result.elements[10] = cosf(angle_converted_to_radians);
151 float angle_converted_to_radians =
M_PI * angle / 180.0f;
153 result.elements[0] = cosf(angle_converted_to_radians);
154 result.elements[4] = -sinf(angle_converted_to_radians);
155 result.elements[1] = sinf(angle_converted_to_radians);
156 result.elements[5] = cosf(angle_converted_to_radians);
166 for(
int row = 0; row < 4; row++)
168 for(
int column = 0; column < 4; column ++)
170 float accumulator = 0.0f;
172 for(
int allElements = 0; allElements < 4; allElements ++)
174 accumulator += left->elements[allElements * 4 + row] * right->elements[column * 4 + allElements];
177 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.
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.