28 1.0f, 0.0f, 0.0f, 0.0f,
29 0.0f, 1.0f, 0.0f, 0.0f,
30 0.0f, 0.0f, 1.0f, 0.0f,
31 0.0f, 0.0f, 0.0f, 1.0f,
39 memcpy(
elements, array, 16 *
sizeof(
float));
68 memcpy(this->
elements, another.elements, 16 *
sizeof(
float));
84 FOV = 1.0f / tan(FOV * 0.5
f);
86 result.elements[ 0] = FOV / ratio;
87 result.elements[ 5] = FOV;
88 result.elements[10] = -(zFar + zNear) / (zFar - zNear);
89 result.elements[11] = -1.0f;
90 result.elements[14] = (-2.0f * zFar * zNear) / (zFar - zNear);
91 result.elements[15] = 0.0f;
101 Vec3f cameraX, cameraY;
103 Vec3f cameraZ = {center.x - eye.x, center.y - eye.y, center.z - eye.z};
120 result[0] = cameraX.x;
121 result[1] = cameraY.x;
122 result[2] = -cameraZ.x;
124 result[4] = cameraX.y;
125 result[5] = cameraY.y;
126 result[6] = -cameraZ.y;
128 result[8] = cameraX.z;
129 result[9] = cameraY.z;
130 result[10] = -cameraZ.z;
144 for(
int row = 0; row < 4; row ++)
146 for(
int column = 0; column < 4; column ++)
148 float accumulator = 0.0f;
150 for(
int allElements = 0; allElements < 4; allElements ++)
152 accumulator += left->elements[allElements * 4 + row] * right->elements[column * 4 + allElements];
155 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.
static Vec3f cross(const Vec3f &vector1, const Vec3f &vector2)
Calculate cross product between two 3D floating point vectors.
Matrix(void)
Default constructor.
static const float identityArray[]
A 4x4 identity 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.
static Matrix matrixCameraLookAt(Vec3f eye, Vec3f center, Vec3f up)
Create and return a camera matrix.
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.