18 #ifndef GLUS_MATRIX_H_
19 #define GLUS_MATRIX_H_
162 for (column = 0; column < 4; column++)
164 for (row = 0; row < 4; row++)
166 temp[column * 4 + row] = 0.0f;
168 for (i = 0; i < 4; i++)
170 temp[column * 4 + row] += matrix0[i * 4 + row] * matrix1[column * 4 + i];
175 for (i = 0; i < 16; i++)
196 for (column = 0; column < 3; column++)
198 for (row = 0; row < 3; row++)
200 temp[column * 3 + row] = 0.0f;
202 for (i = 0; i < 3; i++)
204 temp[column * 3 + row] += matrix0[i * 3 + row] * matrix1[column * 3 + i];
209 for (i = 0; i < 9; i++)
230 for (column = 0; column < 2; column++)
232 for (row = 0; row < 2; row++)
234 temp[column * 2 + row] = 0.0f;
236 for (i = 0; i < 2; i++)
238 temp[column * 2 + row] += matrix0[i * 2 + row] * matrix1[column * 2 + i];
243 for (i = 0; i < 4; i++)
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3MultiplyVector3f(GLUSfloat result[3], const GLUSfloat matrix[9], const GLUSfloat vector[3])
Multiplies a 3x3 matrix with a 3D Vector.
Definition: glus_matrix.c:1253
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3RotateRzf(GLUSfloat matrix[9], const GLUSfloat angle)
Creates a 3x3 matrix for rotation around the z axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:990
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Addf(GLUSfloat matrix[16], const GLUSfloat matrix0[16], const GLUSfloat matrix1[16])
Adds two 4x4 matrices: matrix0 + matrix1.
Definition: glus_matrix.c:357
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4MultiplyPlanef(GLUSfloat result[4], const GLUSfloat matrix[16], const GLUSfloat plane[4])
Multiplies a 4x4 matrix with a plane.
Definition: glus_matrix.c:1354
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Copyf(GLUSfloat matrix[4], const GLUSfloat source[4])
Copies a 3x3 matrix.
Definition: glus_matrix.c:253
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4GetTranslatef(GLUSfloat translates[3], const GLUSfloat matrix[16])
Extracts the translates from a 4x4 matrix.
Definition: glus_matrix.c:1499
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Initf(GLUSfloat matrix[4], const GLUSfloat column0[2], const GLUSfloat column1[2])
Initializes the given 2x2 matrix with the provided column vectors.
Definition: glus_matrix.c:178
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3RotateRxf(GLUSfloat matrix[9], const GLUSfloat angle)
Creates a 3x3 matrix for rotation around the x axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:918
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3GetAnglef(GLUSfloat *angle, const GLUSfloat matrix[9])
Extracts the angle from a 3x3 matrix, which is used in 2D.
Definition: glus_matrix.c:1451
GLUSAPI GLUSfloat GLUSAPIENTRY glusMatrix2x2Determinantf(const GLUSfloat matrix[4])
Calculates the determinant of a 2x2 matrix.
Definition: glus_matrix.c:463
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Subtractf(GLUSfloat matrix[9], const GLUSfloat matrix0[9], const GLUSfloat matrix1[9])
Subtracts two 3x3 matrices: matrix0 - matrix1.
Definition: glus_matrix.c:397
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Translatef(GLUSfloat matrix[16], const GLUSfloat x, const GLUSfloat y, const GLUSfloat z)
Creates a 4x4 translation matrix and multiplies it with the provided one: matrix = matrix * translate...
Definition: glus_matrix.c:789
int GLUSint
Definition: glus_typedef.h:27
GLUSINLINE GLUSvoid GLUSAPIENTRY glusMatrix3x3Multiplyf(GLUSfloat matrix[9], const GLUSfloat matrix0[9], const GLUSfloat matrix1[9])
Multiplies two 3x3 matrices: matrix0 * matrix1.
Definition: glus_matrix.h:188
GLUSINLINE GLUSvoid GLUSAPIENTRY glusMatrix4x4Multiplyf(GLUSfloat matrix[16], const GLUSfloat matrix0[16], const GLUSfloat matrix1[16])
Multiplies two 4x4 matrices: matrix0 * matrix1.
Definition: glus_matrix.h:154
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Rotatef(GLUSfloat matrix[4], const GLUSfloat angle)
Creates a 2x2 matrix for a rotation around in 2D and multiplies it with the given one: matrix = matri...
Definition: glus_matrix.c:882
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Initf(GLUSfloat matrix[16], const GLUSfloat column0[4], const GLUSfloat column1[4], const GLUSfloat column2[4], const GLUSfloat column3[4])
Initializes the given 4x4 matrix with the provided column vectors.
Definition: glus_matrix.c:140
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3CreateMatrix4x4f(GLUSfloat matrix[16], const GLUSfloat source[9])
Creates a 4x4 matrix out of a 3x3 matrix.
Definition: glus_matrix.c:296
float GLUSfloat
Definition: glus_typedef.h:37
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4ExtractMatrix3x3f(GLUSfloat matrix[9], const GLUSfloat source[16])
Extracts a 3x3 matrix out of a 4x4 matrix.
Definition: glus_matrix.c:263
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4RotateRzRyRxf(GLUSfloat matrix[16], const GLUSfloat anglez, const GLUSfloat angley, const GLUSfloat anglex)
Creates a 4x4 matrix for rotation using Euler angles and multiplies it with the given one: matrix = m...
Definition: glus_matrix.c:1039
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4RotateRzf(GLUSfloat matrix[16], const GLUSfloat angle)
Creates a 4x4 matrix for rotation around the z axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:972
void GLUSvoid
Definition: glus_typedef.h:51
GLUSAPI GLUSfloat GLUSAPIENTRY glusMatrix4x4Determinantf(const GLUSfloat matrix[16])
Calculates the determinant of a 4x4 matrix.
Definition: glus_matrix.c:417
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Scalef(GLUSfloat matrix[4], const GLUSfloat x, const GLUSfloat y)
Creates a 2x2 matrix for scaling and multiplies it with the given one: matrix = matrix * scaleMatrix...
Definition: glus_matrix.c:1158
Definition: glus_typedef.h:42
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Identityf(GLUSfloat matrix[16])
Sets the given 4x4 matrix to an identity matrix.
Definition: glus_matrix.c:93
GLUSAPI GLUSfloat GLUSAPIENTRY glusMatrix3x3Determinantf(const GLUSfloat matrix[9])
Calculates the determinant of a 3x3 matrix.
Definition: glus_matrix.c:458
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Shearf(GLUSfloat matrix[9], const GLUSfloat shxy, const GLUSfloat shxz, const GLUSfloat shyx, const GLUSfloat shyz, const GLUSfloat shzx, const GLUSfloat shzy)
Creates a 3x3 matrix for shearing and multiplies it with the given one: matrix = matrix * shearMatrix...
Definition: glus_matrix.c:1188
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4MultiplyVector2f(GLUSfloat result[2], const GLUSfloat matrix[16], const GLUSfloat vector[2])
Multiplies a 4x4 matrix with a 2D Vector.
Definition: glus_matrix.c:1236
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4ExtractMatrix2x2f(GLUSfloat matrix[4], const GLUSfloat source[16])
Extracts a 2x2 matrix out of a 4x4 matrix.
Definition: glus_matrix.c:278
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3MultiplyVector2f(GLUSfloat result[2], const GLUSfloat matrix[9], const GLUSfloat vector[2])
Multiplies a 3x3 matrix with a 2D Vector.
Definition: glus_matrix.c:1270
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Identityf(GLUSfloat matrix[9])
Sets the given 3x3 matrix to an identity matrix.
Definition: glus_matrix.c:116
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3GetEulerRzRxRyf(GLUSfloat angles[3], const GLUSfloat matrix[9])
Extracts the Euler angles from a 3x3 matrix, which was created by a Rz * Rx * Ry transformation.
Definition: glus_matrix.c:1411
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4GetEulerRzRyRxf(GLUSfloat angles[3], const GLUSfloat matrix[16])
Extracts the Euler angles from a 4x4 matrix, which was created by a Rz * Ry * Rz transformation.
Definition: glus_matrix.c:1391
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4RotateRzRxRyf(GLUSfloat matrix[16], const GLUSfloat anglez, const GLUSfloat anglex, const GLUSfloat angley)
Creates a 4x4 matrix for rotation using Euler angles and multiplies it with the given one: matrix = m...
Definition: glus_matrix.c:1008
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Rotatef(GLUSfloat matrix[9], const GLUSfloat angle, const GLUSfloat x, const GLUSfloat y, const GLUSfloat z)
Creates a 3x3 matrix for rotation around a given axis and multiplies it with the given one: matrix = ...
Definition: glus_matrix.c:848
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2GetScalef(GLUSfloat scales[2], const GLUSfloat matrix[4])
Extracts the scales from a 2x2 matrix.
Definition: glus_matrix.c:1489
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2InverseRigidBodyf(GLUSfloat matrix[4])
Calculates the inverse of a 2x2 matrix by assuming it is a rigid body matrix.
Definition: glus_matrix.c:717
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Scalef(GLUSfloat matrix[9], const GLUSfloat x, const GLUSfloat y, const GLUSfloat z)
Creates a 3x3 matrix for scaling and multiplies it with the given one: matrix = matrix * scaleMatrix...
Definition: glus_matrix.c:1145
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3GetTranslatef(GLUSfloat translates[2], const GLUSfloat matrix[9])
Extracts the translates from a 3x3 matrix, which is used for 2D.
Definition: glus_matrix.c:1506
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2MultiplyVector2f(GLUSfloat result[2], const GLUSfloat matrix[4], const GLUSfloat vector[2])
Multiplies a 2x2 matrix with a 2D Vector.
Definition: glus_matrix.c:1287
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Scalef(GLUSfloat matrix[16], const GLUSfloat x, const GLUSfloat y, const GLUSfloat z)
Creates a 4x4 matrix for scaling and multiplies it with the given one: matrix = matrix * scaleMatrix...
Definition: glus_matrix.c:1132
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3MultiplyPoint3f(GLUSfloat result[3], const GLUSfloat matrix[9], const GLUSfloat point[3])
Multiplies a 3x3 matrix with a 2D Point, given as homogeneous coordinates.
Definition: glus_matrix.c:1329
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4RotateRxf(GLUSfloat matrix[16], const GLUSfloat angle)
Creates a 4x4 matrix for rotation around the x axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:900
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Transposef(GLUSfloat matrix[16])
Transposes a 4x4 matrix.
Definition: glus_matrix.c:735
GLUSAPI GLUSboolean GLUSAPIENTRY glusMatrix3x3Inversef(GLUSfloat matrix[9])
Calculates the inverse of a 3x3 matrix using the determinant and adjunct of a matrix.
Definition: glus_matrix.c:573
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2CreateMatrix4x4f(GLUSfloat matrix[16], const GLUSfloat source[4])
Creates a 4x4 matrix out of a 2x2 matrix.
Definition: glus_matrix.c:319
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3RotateRzRyRxf(GLUSfloat matrix[9], const GLUSfloat anglez, const GLUSfloat angley, const GLUSfloat anglex)
Creates a 3x3 matrix for rotation using Euler angles and multiplies it with the given one: matrix = m...
Definition: glus_matrix.c:1101
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3RotateRyf(GLUSfloat matrix[9], const GLUSfloat angle)
Creates a 3x3 matrix for rotation around the y axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:954
#define GLUSAPI
Definition: glus_function.h:38
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Shearf(GLUSfloat matrix[16], const GLUSfloat shxy, const GLUSfloat shxz, const GLUSfloat shyx, const GLUSfloat shyz, const GLUSfloat shzx, const GLUSfloat shzy)
Creates a 4x4 matrix for shearing and multiplies it with the given one: matrix = matrix * shearMatrix...
Definition: glus_matrix.c:1170
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Initf(GLUSfloat matrix[9], const GLUSfloat column0[3], const GLUSfloat column1[3], const GLUSfloat column2[3])
Initializes the given 3x3 matrix with the provided column vectors.
Definition: glus_matrix.c:163
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Copyf(GLUSfloat matrix[16], const GLUSfloat source[16], const GLUSboolean rotationOnly)
Copies a 4x4 matrix.
Definition: glus_matrix.c:187
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Subtractf(GLUSfloat matrix[4], const GLUSfloat matrix0[4], const GLUSfloat matrix1[4])
Subtracts two 2x2 matrices: matrix0 - matrix1.
Definition: glus_matrix.c:407
#define GLUSINLINE
Definition: glus_function.h:24
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3ExtractMatrix2x2f(GLUSfloat matrix[4], const GLUSfloat source[9])
Extracts a 2x2 matrix out of a 3x3 matrix.
Definition: glus_matrix.c:287
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Copyf(GLUSfloat matrix[9], const GLUSfloat source[9], const GLUSboolean rotationOnly)
Copies a 3x3 matrix.
Definition: glus_matrix.c:221
unsigned char GLUSboolean
Definition: glus_typedef.h:21
GLUSAPI GLUSboolean GLUSAPIENTRY glusMatrix2x2Inversef(GLUSfloat matrix[4])
Calculates the inverse of a 2x2 matrix using the determinant and adjunct of a matrix.
Definition: glus_matrix.c:622
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Transposef(GLUSfloat matrix[9])
Transposes a 3x3 matrix.
Definition: glus_matrix.c:753
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4GetEulerRzRxRyf(GLUSfloat angles[3], const GLUSfloat matrix[16])
Extracts the Euler angles from a 4x4 matrix, which was created by a Rz * Rx * Ry transformation.
Definition: glus_matrix.c:1371
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3GetEulerRzRyRxf(GLUSfloat angles[3], const GLUSfloat matrix[9])
Extracts the Euler angles from a 3x3 matrix, which was created by a Rz * Ry * Rx transformation.
Definition: glus_matrix.c:1431
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Subtractf(GLUSfloat matrix[16], const GLUSfloat matrix0[16], const GLUSfloat matrix1[16])
Subtracts two 4x4 matrices: matrix0 - matrix1.
Definition: glus_matrix.c:387
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Transposef(GLUSfloat matrix[4])
Transposes a 2x2 matrix.
Definition: glus_matrix.c:771
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3RotateRzRxRyf(GLUSfloat matrix[9], const GLUSfloat anglez, const GLUSfloat anglex, const GLUSfloat angley)
Creates a 3x3 matrix for rotation using Euler angles and multiplies it with the given one: matrix = m...
Definition: glus_matrix.c:1070
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4GetScalef(GLUSfloat scales[3], const GLUSfloat matrix[16])
Extracts the scales from a 4x4 matrix.
Definition: glus_matrix.c:1469
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4MultiplyVector3f(GLUSfloat result[3], const GLUSfloat matrix[16], const GLUSfloat vector[3])
Multiplies a 4x4 matrix with a 3D Vector.
Definition: glus_matrix.c:1219
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Addf(GLUSfloat matrix[9], const GLUSfloat matrix0[9], const GLUSfloat matrix1[9])
Adds two 3x3 matrices: matrix0 + matrix1.
Definition: glus_matrix.c:367
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4RotateRyf(GLUSfloat matrix[16], const GLUSfloat angle)
Creates a 4x4 matrix for rotation around the y axis and multiplies it with the given one: matrix = ma...
Definition: glus_matrix.c:936
GLUSAPI GLUSboolean GLUSAPIENTRY glusMatrix4x4Inversef(GLUSfloat matrix[16])
Calculates the inverse of a 4x4 matrix using Gaussian Elimination.
Definition: glus_matrix.c:468
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2CreateMatrix3x3f(GLUSfloat matrix[9], const GLUSfloat source[4])
Creates a 3x3 matrix out of a 2x2 matrix.
Definition: glus_matrix.c:342
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Addf(GLUSfloat matrix[4], const GLUSfloat matrix0[4], const GLUSfloat matrix1[4])
Adds two 2x2 matrices: matrix0 + matrix1.
Definition: glus_matrix.c:377
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4MultiplyPoint4f(GLUSfloat result[4], const GLUSfloat matrix[16], const GLUSfloat point[4])
Multiplies a 4x4 matrix with a 3D Point, given as homogeneous coordinates.
Definition: glus_matrix.c:1304
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Shearf(GLUSfloat matrix[4], const GLUSfloat shx, const GLUSfloat shy)
Creates a 2x2 matrix for shearing and multiplies it with the given one: matrix = matrix * shearMatrix...
Definition: glus_matrix.c:1206
#define GLUSAPIENTRY
Definition: glus_function.h:31
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3InverseRigidBodyf(GLUSfloat matrix[9], const GLUSboolean is2D)
Calculates the inverse of a 3x3 matrix by assuming it is a rigid body matrix.
Definition: glus_matrix.c:671
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4InverseRigidBodyf(GLUSfloat matrix[16])
Calculates the inverse of a 4x4 matrix by assuming it is a rigid body matrix.
Definition: glus_matrix.c:645
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2GetAnglef(GLUSfloat *angle, const GLUSfloat matrix[4])
Extracts the angle from a 2x2 matrix.
Definition: glus_matrix.c:1460
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3GetScalef(GLUSfloat scales[3], const GLUSfloat matrix[9])
Extracts the scales from a 3x3 matrix.
Definition: glus_matrix.c:1479
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix4x4Rotatef(GLUSfloat matrix[16], const GLUSfloat angle, const GLUSfloat x, const GLUSfloat y, const GLUSfloat z)
Creates a 4x4 matrix for rotation around a given axis and multiplies it with the given one: matrix = ...
Definition: glus_matrix.c:814
GLUSAPI GLUSboolean GLUSAPIENTRY glusMatrixNxNMultiplyVectorNc(GLUScomplex *result, const GLUScomplex *matrix, const GLUScomplex *vector, const GLUSint n)
Multiplies a NxN matrix with a Vector with N elements.
Definition: glus_matrix.c:1514
GLUSINLINE GLUSvoid GLUSAPIENTRY glusMatrix2x2Multiplyf(GLUSfloat matrix[4], const GLUSfloat matrix0[4], const GLUSfloat matrix1[4])
Multiplies two 2x2 matrices: matrix0 * matrix1.
Definition: glus_matrix.h:222
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix3x3Translatef(GLUSfloat matrix[9], const GLUSfloat x, const GLUSfloat y)
Creates a 3x3 translation matrix and multiplies it with the provided one: matrix = matrix * translate...
Definition: glus_matrix.c:802
GLUSAPI GLUSvoid GLUSAPIENTRY glusMatrix2x2Identityf(GLUSfloat matrix[4])
Sets the given 2x2 matrix to an identity matrix.
Definition: glus_matrix.c:131