5 typedef struct matrix4x4_s
11 typedef struct matrix3x4_s
17 // functions for manipulating 4x4 matrices
20 void Matrix4x4_Copy (matrix4x4_t *out, matrix4x4_t *in);
21 // copy only the rotation portion of a matrix4x4
22 void Matrix4x4_CopyRotateOnly (matrix4x4_t *out, matrix4x4_t *in);
23 // copy only the translate portion of a matrix4x4
24 void Matrix4x4_CopyTranslateOnly (matrix4x4_t *out, matrix4x4_t *in);
25 // make a matrix4x4 from a matrix3x4
26 void Matrix4x4_FromMatrix3x4 (matrix4x4_t *out, matrix3x4_t *in);
27 // multiply two matrix4x4 together, combining their transformations
28 // (warning: order matters - Concat(a, b, c) != Concat(a, c, b))
29 void Matrix4x4_Concat (matrix4x4_t *out, const matrix4x4_t *in1, const matrix4x4_t *in2);
30 // swaps the rows and columns of the matrix4x4 and attempts to undo uniform
31 // scaling (Scale, not Scale3), resulting in a matrix that will do the opposite
32 // (warning: this only inverts rotation, uniform scaling and translation,
33 // do not use with shearing, Scale3, or other complex matrices)
34 void Matrix4x4_Transpose (matrix4x4_t *out, const matrix4x4_t *in1);
36 // creates an identity matrix
37 // (a matrix which does nothing)
38 void Matrix4x4_CreateIdentity (matrix4x4_t *out);
39 // creates a translate matrix
41 void Matrix4x4_CreateTranslate (matrix4x4_t *out, float x, float y, float z);
42 // creates a rotate matrix
44 void Matrix4x4_CreateRotate (matrix4x4_t *out, float angle, float x, float y, float z);
45 // creates a scaling matrix
46 // (expands or contracts vectors)
47 // (warning: this is not reversed by Transpose)
48 void Matrix4x4_CreateScale (matrix4x4_t *out, float x);
49 // creates a squishing matrix
50 // (expands or contracts vectors differently in different axis)
51 // (warning: this is not reversed by Transpose)
52 // (warning: do not apply this kind of matrix to direction vectors)
53 void Matrix4x4_CreateScale3 (matrix4x4_t *out, float x, float y, float z);
55 // converts a matrix4x4 to a set of 3D vectors for the 3 axial directions, and the translate
56 void Matrix4x4_ToVectors(const matrix4x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]);
57 // creates a matrix4x4 from a set of 3D vectors for axial directions, and translate
58 void Matrix4x4_FromVectors(matrix4x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]);
60 // transforms a 3D vector through a matrix4x4
61 void Matrix4x4_Transform (const matrix4x4_t *in, const float v[3], float out[3]);
62 // transforms a 4D vector through a matrix4x4
63 // (warning: if you don't know why you would need this, you don't need it)
64 // (warning: the 4th component of the vector should be 1.0)
65 void Matrix4x4_Transform4 (const matrix4x4_t *in, const float v[4], float out[4]);
66 // reverse transforms a 3D vector through a matrix4x4, at least for *simple*
67 // cases (rotation and translation *ONLY*), this attempts to undo the results
69 void Matrix4x4_SimpleUntransform (const matrix4x4_t *in, const float v[3], float out[3]);
71 // ease of use functions
72 // immediately applies a Translate to the matrix
73 void Matrix4x4_ConcatTranslate (matrix4x4_t *out, float x, float y, float z);
74 // immediately applies a Rotate to the matrix
75 void Matrix4x4_ConcatRotate (matrix4x4_t *out, float angle, float x, float y, float z);
76 // immediately applies a Scale to the matrix
77 void Matrix4x4_ConcatScale (matrix4x4_t *out, float x);
78 // immediately applies a Scale3 to the matrix
79 void Matrix4x4_ConcatScale3 (matrix4x4_t *out, float x, float y, float z);
83 // functions for manipulating 3x4 matrices
86 void Matrix3x4_Copy (matrix3x4_t *out, matrix3x4_t *in);
87 // copy only the rotation portion of a matrix3x4
88 void Matrix3x4_CopyRotateOnly (matrix3x4_t *out, matrix3x4_t *in);
89 // copy only the translate portion of a matrix3x4
90 void Matrix3x4_CopyTranslateOnly (matrix3x4_t *out, matrix3x4_t *in);
91 // make a matrix3x4 from a matrix4x4
92 void Matrix3x4_FromMatrix4x4 (matrix3x4_t *out, matrix4x4_t *in);
93 // multiply two matrix3x4 together, combining their transformations
94 // (warning: order matters - Concat(a, b, c) != Concat(a, c, b))
95 void Matrix3x4_Concat (matrix3x4_t *out, const matrix3x4_t *in1, const matrix3x4_t *in2);
96 // swaps the rows and columns of the rotation portion of the matrix, and
97 // attempts to undo uniform scaling (Scale, not Scale3), resulting in a
98 // matrix that will do the opposite
99 // (warning: this only inverts rotation and uniform scaling, do not use with
100 // translation, shearing, Scale3 or other complex matrices)
101 void Matrix3x4_Transpose3x3 (matrix3x4_t *out, const matrix3x4_t *in1);
103 // creates an identity matrix
104 // (a matrix which does nothing)
105 void Matrix3x4_CreateIdentity (matrix3x4_t *out);
106 // creates a translate matrix
108 void Matrix3x4_CreateTranslate (matrix3x4_t *out, float x, float y, float z);
109 // creates a rotate matrix
111 void Matrix3x4_CreateRotate (matrix3x4_t *out, float angle, float x, float y, float z);
112 // creates a scaling matrix
113 // (expands or contracts vectors)
114 // (warning: this is not reversed by Transpose)
115 void Matrix3x4_CreateScale (matrix3x4_t *out, float x);
116 // creates a squishing matrix
117 // (expands or contracts vectors differently in different axis)
118 // (warning: this is not reversed by Transpose)
119 // (warning: do not apply this kind of matrix to direction vectors)
120 void Matrix3x4_CreateScale3 (matrix3x4_t *out, float x, float y, float z);
122 // converts a matrix3x4 to a set of 3D vectors for the 3 axial directions, and the translate
123 void Matrix3x4_ToVectors(const matrix3x4_t *in, float vx[3], float vy[3], float vz[3], float t[3]);
124 // creates a matrix3x4 from a set of 3D vectors for axial directions, and translate
125 void Matrix3x4_FromVectors(matrix3x4_t *out, const float vx[3], const float vy[3], const float vz[3], const float t[3]);
127 // transforms a 3D vector through a matrix3x4
128 void Matrix3x4_Transform (const matrix3x4_t *in, const float v[3], float out[3]);
129 // reverse transforms a 3D vector through a matrix3x4, at least for *simple*
130 // cases (rotation and translation *ONLY*), this attempts to undo the results
132 void Matrix3x4_SimpleUntransform (const matrix3x4_t *in, const float v[3], float out[3]);
134 // ease of use functions
135 // immediately applies a Translate to the matrix
136 void Matrix3x4_ConcatTranslate (matrix3x4_t *out, float x, float y, float z);
137 // immediately applies a Rotate to the matrix
138 void Matrix3x4_ConcatRotate (matrix3x4_t *out, float angle, float x, float y, float z);
139 // immediately applies a Scale to the matrix
140 void Matrix3x4_ConcatScale (matrix3x4_t *out, float x);
141 // immediately applies a Scale3 to the matrix
142 void Matrix3x4_ConcatScale3 (matrix3x4_t *out, float x, float y, float z);