Browse Source

More natural mat4_make().

main
3gg 4 months ago
parent
commit
adfda56b97
  1. 37
      include/math/mat4.h

37
include/math/mat4.h

@ -13,28 +13,35 @@ typedef struct mat4 {
} mat4;
/// Construct a matrix from 16 values.
static inline mat4 mat4_make(R m00, R m10, R m20, R m30, R m01, R m11, R m21,
R m31, R m02, R m12, R m22, R m32, R m03, R m13,
R m23, R m33) {
///
/// The values are given row by row:
///
/// [ m00 m01 m02 m03 ]
/// [ m10 m11 m12 m13 ]
/// [ m20 m21 m22 m23 ]
/// [ m30 m31 m32 m33 ]
static inline mat4 mat4_make(R m00, R m01, R m02, R m03, R m10, R m11, R m12,
R m13, R m20, R m21, R m22, R m23, R m30, R m31,
R m32, R m33) {
mat4 m;
m.val[0][0] = m00;
m.val[0][1] = m01;
m.val[0][2] = m02;
m.val[0][3] = m03;
m.val[0][1] = m10;
m.val[0][2] = m20;
m.val[0][3] = m30;
m.val[1][0] = m10;
m.val[1][0] = m01;
m.val[1][1] = m11;
m.val[1][2] = m12;
m.val[1][3] = m13;
m.val[1][2] = m21;
m.val[1][3] = m31;
m.val[2][0] = m20;
m.val[2][1] = m21;
m.val[2][0] = m02;
m.val[2][1] = m12;
m.val[2][2] = m22;
m.val[2][3] = m23;
m.val[2][3] = m32;
m.val[3][0] = m30;
m.val[3][1] = m31;
m.val[3][2] = m32;
m.val[3][0] = m03;
m.val[3][1] = m13;
m.val[3][2] = m23;
m.val[3][3] = m33;
return m;
}

Loading…
Cancel
Save