26#define bj_real_t float
28#ifndef BJ_COMPILER_DOXYGEN
29# define real_sqrt bj_sqrtf
30# define real_acos bj_acosf
31# define BJ_INLINE static inline
98 res[0] = a; res[1] = b;
122 res[0] = lhs[0] + rhs[0];
123 res[1] = lhs[1] + rhs[1];
134 res[0] = lhs[0] - rhs[0];
135 res[1] = lhs[1] - rhs[1];
158 res[0] = v[0] * s[0];
159 res[1] = v[1] * s[1];
170 return a[0] * b[0] + a[1] * b[1];
180 return real_sqrt(v[0] * v[0] + v[1] * v[1]);
190 bj_real_t inv_len = 1.0f / real_sqrt(v[0] * v[0] + v[1] * v[1]);
191 res[0] = v[0] * inv_len;
192 res[1] = v[1] * inv_len;
203 res[0] = a[0] < b[0] ? a[0] : b[0];
204 res[1] = a[1] < b[1] ? a[1] : b[1];
215 res[0] = a[0] > b[0] ? a[0] : b[0];
216 res[1] = a[1] > b[1] ? a[1] : b[1];
240 res[0] = a; res[1] = b; res[2] = c;
266 res[0] = lhs[0] + rhs[0];
267 res[1] = lhs[1] + rhs[1];
268 res[2] = lhs[2] + rhs[2];
279 res[0] = lhs[0] - rhs[0];
280 res[1] = lhs[1] - rhs[1];
281 res[2] = lhs[2] - rhs[2];
305 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
315 return real_sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
325 bj_real_t inv_len = 1.0f / real_sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
326 res[0] = v[0] * inv_len;
327 res[1] = v[1] * inv_len;
328 res[2] = v[2] * inv_len;
339 res[0] = a[0] < b[0] ? a[0] : b[0];
340 res[1] = a[1] < b[1] ? a[1] : b[1];
341 res[2] = a[2] < b[2] ? a[2] : b[2];
352 res[0] = a[0] > b[0] ? a[0] : b[0];
353 res[1] = a[1] > b[1] ? a[1] : b[1];
354 res[2] = a[2] > b[2] ? a[2] : b[2];
378 res[0] = l[1] * r[2] - l[2] * r[1];
379 res[1] = l[2] * r[0] - l[0] * r[2];
380 res[2] = l[0] * r[1] - l[1] * r[0];
396 for (
int i = 0; i < 3; ++i) {
397 res[i] = v[i] - p * n[i];
413 res[0] = a; res[1] = b; res[2] = c; res[3] = d;
439 res[0] = lhs[0] + rhs[0];
440 res[1] = lhs[1] + rhs[1];
441 res[2] = lhs[2] + rhs[2];
442 res[3] = lhs[3] + rhs[3];
453 res[0] = lhs[0] - rhs[0];
454 res[1] = lhs[1] - rhs[1];
455 res[2] = lhs[2] - rhs[2];
456 res[3] = lhs[3] - rhs[3];
481 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
491 return real_sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + v[3] * v[3]);
501 bj_real_t inv_len = 1.0f / real_sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + v[3] * v[3]);
502 res[0] = v[0] * inv_len;
503 res[1] = v[1] * inv_len;
504 res[2] = v[2] * inv_len;
505 res[3] = v[3] * inv_len;
516 res[0] = a[0] < b[0] ? a[0] : b[0];
517 res[1] = a[1] < b[1] ? a[1] : b[1];
518 res[2] = a[2] < b[2] ? a[2] : b[2];
519 res[3] = a[3] < b[3] ? a[3] : b[3];
530 res[0] = a[0] > b[0] ? a[0] : b[0];
531 res[1] = a[1] > b[1] ? a[1] : b[1];
532 res[2] = a[2] > b[2] ? a[2] : b[2];
533 res[3] = a[3] > b[3] ? a[3] : b[3];
561 res[0] = l[1] * r[2] - l[2] * r[1];
562 res[1] = l[2] * r[0] - l[0] * r[2];
563 res[2] = l[0] * r[1] - l[1] * r[0];
580 for (
int i = 0; i < 4; ++i) {
581 res[i] = v[i] - p * n[i];
594 for (
int i = 0; i < 4; ++i) {
595 for (
int j = 0; j < 4; ++j) {
596 mat[i][j] = i == j ? 1.f : 0.f;
611 for (
int i = 0; i < 4; ++i) {
627 for (
int k = 0; k < 4; ++k) {
643 for (
int k = 0; k < 4; ++k) {
659 for (
int j = 0; j < 4; ++j) {
660 for (
int i = 0; i < 4; ++i) {
661 res[i][j] = mat[j][i];
677 for (
int i = 0; i < 4; ++i) {
693 for (
int i = 0; i < 4; ++i) {
709 for (
int i = 0; i < 4; ++i) {
746 for (
int c = 0; c < 4; ++c) {
747 for (
int r = 0; r < 4; ++r) {
749 for (
int k = 0; k < 4; ++k)
750 temp[c][r] += lhs[k][r] * rhs[c][k];
767 for (
int j = 0; j < 4; ++j) {
769 for (
int i = 0; i < 4; ++i) {
770 res[j] += mat[i][j] * v[i];
808 for (
int i = 0; i < 4; ++i) {
826 for (
int i = 0; i < 4; ++i) {
827 for (
int j = 0; j < 4; ++j) {
828 res[i][j] = i < 3 && j < 3 ? a[i] * b[j] : 0.f;
858 { 0, u[2], -u[1], 0},
860 { u[1], -u[0], 0, 0},
896 {1.f, 0.f, 0.f, 0.f},
920 { 0.f, 1.f, 0.f, 0.f},
922 { 0.f, 0.f, 0.f, 1.f}
944 { 0.f, 0.f, 1.f, 0.f},
945 { 0.f, 0.f, 0.f, 1.f}
987 bj_vec3 a_ = { a[0], a[1], z_a };
988 bj_vec3 b_ = { b[0], b[1], z_b };
1009 s[0] = mat[0][0] * mat[1][1] - mat[1][0] * mat[0][1];
1010 s[1] = mat[0][0] * mat[1][2] - mat[1][0] * mat[0][2];
1011 s[2] = mat[0][0] * mat[1][3] - mat[1][0] * mat[0][3];
1012 s[3] = mat[0][1] * mat[1][2] - mat[1][1] * mat[0][2];
1013 s[4] = mat[0][1] * mat[1][3] - mat[1][1] * mat[0][3];
1014 s[5] = mat[0][2] * mat[1][3] - mat[1][2] * mat[0][3];
1016 c[0] = mat[2][0] * mat[3][1] - mat[3][0] * mat[2][1];
1017 c[1] = mat[2][0] * mat[3][2] - mat[3][0] * mat[2][2];
1018 c[2] = mat[2][0] * mat[3][3] - mat[3][0] * mat[2][3];
1019 c[3] = mat[2][1] * mat[3][2] - mat[3][1] * mat[2][2];
1020 c[4] = mat[2][1] * mat[3][3] - mat[3][1] * mat[2][3];
1021 c[5] = mat[2][2] * mat[3][3] - mat[3][2] * mat[2][3];
1023 bj_real_t idet = 1.0f / (s[0] * c[5] - s[1] * c[4] + s[2] * c[3] + s[3] * c[2] - s[4] * c[1] + s[5] * c[0]);
1025 res[0][0] = (mat[1][1] * c[5] - mat[1][2] * c[4] + mat[1][3] * c[3]) * idet;
1026 res[0][1] = (-mat[0][1] * c[5] + mat[0][2] * c[4] - mat[0][3] * c[3]) * idet;
1027 res[0][2] = (mat[3][1] * s[5] - mat[3][2] * s[4] + mat[3][3] * s[3]) * idet;
1028 res[0][3] = (-mat[2][1] * s[5] + mat[2][2] * s[4] - mat[2][3] * s[3]) * idet;
1030 res[1][0] = (-mat[1][0] * c[5] + mat[1][2] * c[2] - mat[1][3] * c[1]) * idet;
1031 res[1][1] = (mat[0][0] * c[5] - mat[0][2] * c[2] + mat[0][3] * c[1]) * idet;
1032 res[1][2] = (-mat[3][0] * s[5] + mat[3][2] * s[2] - mat[3][3] * s[1]) * idet;
1033 res[1][3] = (mat[2][0] * s[5] - mat[2][2] * s[2] + mat[2][3] * s[1]) * idet;
1035 res[2][0] = (mat[1][0] * c[4] - mat[1][1] * c[2] + mat[1][3] * c[0]) * idet;
1036 res[2][1] = (-mat[0][0] * c[4] + mat[0][1] * c[2] - mat[0][3] * c[0]) * idet;
1037 res[2][2] = (mat[3][0] * s[4] - mat[3][1] * s[2] + mat[3][3] * s[0]) * idet;
1038 res[2][3] = (-mat[2][0] * s[4] + mat[2][1] * s[2] - mat[2][3] * s[0]) * idet;
1040 res[3][0] = (-mat[1][0] * c[3] + mat[1][1] * c[1] - mat[1][2] * c[0]) * idet;
1041 res[3][1] = (mat[0][0] * c[3] - mat[0][1] * c[1] + mat[0][2] * c[0]) * idet;
1042 res[3][2] = (-mat[3][0] * s[3] + mat[3][1] * s[1] - mat[3][2] * s[0]) * idet;
1043 res[3][3] = (mat[2][0] * s[3] - mat[2][1] * s[1] + mat[2][2] * s[0]) * idet;
1092 fmat[0][0] = 2.f * n / (r - l);
1093 fmat[0][1] = fmat[0][2] = fmat[0][3] = 0.f;
1094 fmat[1][1] = 2.f * n / (t - b);
1095 fmat[1][0] = fmat[1][2] = fmat[1][3] = 0.f;
1096 fmat[2][0] = (r + l) / (r - l);
1097 fmat[2][1] = (t + b) / (t - b);
1098 fmat[2][2] = -(f + n) / (f - n);
1100 fmat[3][2] = -2.f * (f * n) / (f - n);
1101 fmat[3][0] = fmat[3][1] = fmat[3][3] = 0.f;
1119 omat[0][0] = 2.f / (r - l);
1120 omat[0][1] = omat[0][2] = omat[0][3] = 0.f;
1121 omat[1][1] = 2.f / (t - b);
1122 omat[1][0] = omat[1][2] = omat[1][3] = 0.f;
1123 omat[2][2] = -2.f / (f - n);
1124 omat[2][0] = omat[2][1] = omat[2][3] = 0.f;
1125 omat[3][0] = -(r + l) / (r - l);
1126 omat[3][1] = -(t + b) / (t - b);
1127 omat[3][2] = -(f + n) / (f - n);
1144 const bj_real_t a = 1.f / bj_tanf(y_fov / 2.f);
1145 pmat[0][0] = a / aspect;
1155 pmat[2][2] = -((f + n) / (f - n));
1159 pmat[3][2] = -((2.f * f * n) / (f - n));
1212#define bj_quat_add bj_vec4_add
1216#define bj_quat_sub bj_vec4_sub
1220#define bj_quat_norm bj_vec4_normalize
1224#define bj_quat_scale bj_vec4_scale
1228#define bj_quat_dot bj_vec4_dot
1239 q[0] = q[1] = q[2] = 0.f;
1279 for (
int i = 0; i < 3; ++i) {
1316 bj_vec3 q_xyz = { q[0], q[1], q[2] };
1317 bj_vec3 u = { q[0], q[1], q[2] };
1347 res[0][0] = a2 + b2 - c2 - d2;
1348 res[0][1] = 2.f * (b * c + a * d);
1349 res[0][2] = 2.f * (b * d - a * c);
1352 res[1][0] = 2 * (b * c - a * d);
1353 res[1][1] = a2 - b2 + c2 - d2;
1354 res[1][2] = 2.f * (c * d + a * b);
1357 res[2][0] = 2.f * (b * d + a * c);
1358 res[2][1] = 2.f * (c * d - a * b);
1359 res[2][2] = a2 - b2 - c2 + d2;
1362 res[3][0] = res[3][1] = res[3][2] = 0.f;
1381 R[3][0] = R[3][1] = R[3][2] = 0.f;
1400 int perm[] = { 0, 1, 2, 0, 1 };
1403 for (i = 0; i < 3; i++) {
1415 r = real_sqrt(1.f + M[i][i] - M[j][j] - M[k][k]);
1428 q[j] = (M[i][j] + M[j][i]) * inv;
1429 q[k] = (M[k][i] + M[i][k]) * inv;
1430 q[3] = (M[k][j] - M[j][k]) * inv;
BJ_INLINE void bj_mat4_lookat(bj_mat4 m, const bj_vec3 eye, const bj_vec3 center, const bj_vec3 up)
Generates a look-at matrix.
Definition linmath.h:1175
BJ_INLINE bj_real_t bj_vec4_len(const bj_vec4 v)
Computes the length of the vec4.
Definition linmath.h:490
BJ_INLINE void bj_vec2_min(bj_vec2 res, const bj_vec2 a, const bj_vec2 b)
Computes the component-wise minimum of two 2D vectors.
Definition linmath.h:202
BJ_INLINE bj_real_t bj_vec2_len(const bj_vec2 v)
Computes the length of the vec2.
Definition linmath.h:179
bj_real_t bj_vec4[4]
Defines a 4D vector type.
Definition linmath.h:65
BJ_INLINE void bj_vec2_copy(bj_vec2 res, const bj_vec2 src)
Copies the contents of one 2D vector to another.
Definition linmath.h:225
BJ_INLINE void bj_mat4_col(bj_vec4 res, const bj_mat4 mat, int c)
Retrieves a specific column from a 4x4 matrix.
Definition linmath.h:641
BJ_INLINE void bj_mat4_frustum(bj_mat4 fmat, bj_real_t l, bj_real_t r, bj_real_t b, bj_real_t t, bj_real_t n, bj_real_t f)
Generates a perspective projection matrix for a frustum.
Definition linmath.h:1091
BJ_INLINE void bj_mat4_perspective(bj_mat4 pmat, bj_real_t y_fov, bj_real_t aspect, bj_real_t n, bj_real_t f)
Generates a perspective projection matrix based on field of view.
Definition linmath.h:1143
BJ_INLINE void bj_vec3_add(bj_vec3 res, const bj_vec3 lhs, const bj_vec3 rhs)
Set res to the result of lhs+rhs.
Definition linmath.h:265
BJ_INLINE bj_real_t bj_vec2_dot(const bj_vec2 a, const bj_vec2 b)
Computes the dot product of a abnd b
Definition linmath.h:169
BJ_INLINE void bj_vec4_apply(bj_vec4 res, const bj_vec4 a, bj_real_t(*f)(bj_real_t))
Invoke the given function to each scalar of the bj_vec4.
Definition linmath.h:424
BJ_INLINE void bj_mat4_rotate_from_quat(bj_mat4 R, const bj_mat4 M, const bj_quat q)
Applies a quaternion rotation to each column of a matrix.
Definition linmath.h:1376
BJ_INLINE void bj_mat4_rotate_arcball(bj_mat4 R, const bj_mat4 M, bj_vec2 const _a, bj_vec2 const _b, bj_real_t s)
Rotates a matrix based on arcball-style rotation from two 2D vectors.
Definition linmath.h:965
BJ_INLINE void bj_vec4_min(bj_vec4 res, const bj_vec4 a, const bj_vec4 b)
Computes the component-wise minimum of two 4D vectors.
Definition linmath.h:515
BJ_INLINE void bj_mat4_sub(bj_mat4 res, const bj_mat4 lhs, const bj_mat4 rhs)
Subtracts one 4x4 matrix from another.
Definition linmath.h:691
BJ_INLINE void bj_vec2_scale_each(bj_vec2 res, const bj_vec2 v, const bj_vec2 s)
Multiply each scalar of v by the respecting scalar in s.
Definition linmath.h:157
BJ_INLINE void bj_quat_from_mat4(bj_quat q, const bj_mat4 M)
Converts a 4x4 rotation matrix to a quaternion.
Definition linmath.h:1396
BJ_INLINE void bj_mat4_mul_outer(bj_mat4 res, const bj_vec3 a, const bj_vec3 b)
Computes the outer product of two 3D vectors and stores the result in a 4x4 matrix.
Definition linmath.h:824
BJ_INLINE void bj_vec2_sub(bj_vec2 res, const bj_vec2 lhs, const bj_vec2 rhs)
Set res to the result of lhs-rhs.
Definition linmath.h:133
BJ_INLINE void bj_ma4_rotate_y(bj_mat4 res, const bj_mat4 mat, bj_real_t angle)
Rotates a 4x4 matrix around the Y axis by a given angle.
Definition linmath.h:914
BJ_INLINE void bj_vec4_reflect(bj_vec4 res, const bj_vec4 v, const bj_vec4 n)
Reflects a 4D vector around a given normal.
Definition linmath.h:577
BJ_INLINE void bj_mat4_mul_vec4(bj_vec4 res, const bj_mat4 mat, const bj_vec4 v)
Multiplies a 4x4 matrix by a 4D vector.
Definition linmath.h:765
BJ_INLINE void bj_vec3_apply(bj_vec3 res, const bj_vec3 a, bj_real_t(*f)(bj_real_t))
Invoke the given function to each scalar of the bj_vec3.
Definition linmath.h:251
BJ_INLINE void bj_mat4_add(bj_mat4 res, const bj_mat4 lhs, const bj_mat4 rhs)
Adds two 4x4 matrices.
Definition linmath.h:675
#define bj_real_t
Alias for float type.
Definition linmath.h:26
bj_real_t bj_quat[4]
Defines a quaternion type.
Definition linmath.h:87
BJ_INLINE bj_real_t bj_vec4_dot(const bj_vec4 a, const bj_vec4 b)
Computes the dot product of a abnd b
Definition linmath.h:480
BJ_INLINE void bj_mat4_transpose(bj_mat4 res, const bj_mat4 mat)
Transposes a 4x4 matrix.
Definition linmath.h:657
BJ_INLINE void bj_vec4_add(bj_vec4 res, const bj_vec4 lhs, const bj_vec4 rhs)
Set res to the result of lhs+rhs.
Definition linmath.h:438
BJ_INLINE void bj_quat_identity(bj_quat q)
Sets a quaternion to the identity quaternion.
Definition linmath.h:1237
BJ_INLINE void bj_vec3_sub(bj_vec3 res, const bj_vec3 lhs, const bj_vec3 rhs)
Set res to the result of lhs-rhs.
Definition linmath.h:278
BJ_INLINE void bj_vec2_max(bj_vec2 res, const bj_vec2 a, const bj_vec2 b)
Computes the component-wise maximum of two 2D vectors.
Definition linmath.h:214
BJ_INLINE void bj_ma4_rotate_z(bj_mat4 res, const bj_mat4 mat, bj_real_t angle)
Rotates a 4x4 matrix around the Z-axis by a given angle.
Definition linmath.h:937
BJ_INLINE void bj_vec4_max(bj_vec4 res, const bj_vec4 a, const bj_vec4 b)
Computes the component-wise maximum of two 4D vectors.
Definition linmath.h:529
BJ_INLINE void bj_vec4_set(bj_vec2 res, bj_real_t a, bj_real_t b, bj_real_t c, bj_real_t d)
Directly set the scalar values of a bj_vec4 object.
Definition linmath.h:412
BJ_INLINE void bj_vec3_min(bj_vec3 res, const bj_vec3 a, const bj_vec3 b)
Computes the component-wise minimum of two 3D vectors.
Definition linmath.h:338
BJ_INLINE void bj_mat4_from_quat(bj_mat4 res, const bj_quat q)
Converts a quaternion to a 4x4 rotation matrix.
Definition linmath.h:1337
BJ_INLINE void bj_mat4_scale_xyz(bj_mat4 res, const bj_mat4 mat, bj_real_t x, bj_real_t y, bj_real_t z)
Scales the X, Y, and Z components of a 4x4 matrix.
Definition linmath.h:726
bj_vec4 bj_mat4[4]
Defines a 4x4 matrix type.
Definition linmath.h:76
BJ_INLINE void bj_mat4_ortho(bj_mat4 omat, bj_real_t l, bj_real_t r, bj_real_t b, bj_real_t t, bj_real_t n, bj_real_t f)
Generates an orthographic projection matrix.
Definition linmath.h:1118
BJ_INLINE void bj_quat_mul(bj_quat res, const bj_quat p, const bj_quat q)
Multiplies two quaternions.
Definition linmath.h:1253
BJ_INLINE void bj_mat4_translation_inplace(bj_mat4 M, bj_real_t x, bj_real_t y, bj_real_t z)
Applies a translation transformation to a 4x4 matrix in-place.
Definition linmath.h:804
BJ_INLINE void bj_mat4_rotate(bj_mat4 res, const bj_mat4 mat, bj_real_t x, bj_real_t y, bj_real_t z, bj_real_t angle)
Rotates a 4x4 matrix by a given axis and angle.
Definition linmath.h:846
BJ_INLINE void bj_vec4_sub(bj_vec4 res, const bj_vec4 lhs, const bj_vec4 rhs)
Set res to the result of lhs-rhs.
Definition linmath.h:452
BJ_INLINE void bj_vec2_set(bj_vec2 res, bj_real_t a, bj_real_t b)
Directly set the scalar values of a bj_vec2 object.
Definition linmath.h:97
BJ_INLINE void bj_vec3_reflect(bj_vec3 res, const bj_vec3 v, const bj_vec3 n)
Reflects a 3D vector around a given normal.
Definition linmath.h:393
BJ_INLINE void bj_vec2_scale(bj_vec2 res, const bj_vec2 v, bj_real_t s)
Set res to the result of multiplying v by s.
Definition linmath.h:145
BJ_INLINE void bj_vec3_cross(bj_vec3 res, const bj_vec3 l, const bj_vec3 r)
Computes the 3D cross product of two 3D vectors.
Definition linmath.h:376
BJ_INLINE void bj_quat_rotation(bj_quat res, bj_real_t angle, const bj_vec3 axis)
Creates a rotation quaternion based on an angle and axis.
Definition linmath.h:1295
BJ_INLINE void bj_mat4_row(bj_vec4 res, const bj_mat4 mat, int r)
Retrieves a specific row from a 4x4 matrix.
Definition linmath.h:625
BJ_INLINE bj_real_t bj_vec3_len(const bj_vec3 v)
Computes the length of the vec3.
Definition linmath.h:314
BJ_INLINE bj_real_t bj_vec3_dot(const bj_vec3 a, const bj_vec3 b)
Computes the dot product of a abnd b
Definition linmath.h:304
BJ_INLINE void bj_mat4_identity(bj_mat4 mat)
Initializes a 4x4 matrix to the identity matrix.
Definition linmath.h:592
BJ_INLINE void bj_vec2_add(bj_vec2 res, const bj_vec2 lhs, const bj_vec2 rhs)
Set res to the result of lhs+rhs.
Definition linmath.h:121
BJ_INLINE void bj_vec2_apply(bj_vec2 res, const bj_vec2 a, bj_real_t(*f)(bj_real_t))
Invoke the given function to each scalar of the bj_vec2.
Definition linmath.h:109
BJ_INLINE void bj_vec3_set(bj_vec2 res, bj_real_t a, bj_real_t b, bj_real_t c)
Directly set the scalar values of a bj_vec3 object.
Definition linmath.h:239
BJ_INLINE void bj_vec3_scale(bj_vec3 res, const bj_vec3 v, bj_real_t s)
Set res to the result of multiplying v by s.
Definition linmath.h:291
BJ_INLINE void bj_vec3_copy(bj_vec3 res, const bj_vec3 src)
Copies the contents of one 3D vector to another.
Definition linmath.h:363
BJ_INLINE void bj_vec2_normalize(bj_vec2 res, const bj_vec2 v)
Normalizes the provided vec2.
Definition linmath.h:189
BJ_INLINE void bj_vec3_normalize(bj_vec3 res, const bj_vec3 v)
Normalizes the provided vec3.
Definition linmath.h:324
BJ_INLINE void bj_ma4_rotate_x(bj_mat4 res, const bj_mat4 mat, bj_real_t angle)
Rotates a 4x4 matrix around the X axis by a given angle.
Definition linmath.h:891
BJ_INLINE void bj_vec4_cross(bj_vec4 res, const bj_vec4 l, const bj_vec4 r)
Computes the 3D cross product of two 4D vectors, assuming w = 1.0.
Definition linmath.h:559
BJ_INLINE void bj_vec3_max(bj_vec3 res, const bj_vec3 a, const bj_vec3 b)
Computes the component-wise maximum of two 3D vectors.
Definition linmath.h:351
BJ_INLINE void bj_quat_conjugate(bj_quat res, const bj_quat q)
Computes the conjugate of a quaternion.
Definition linmath.h:1277
BJ_INLINE void bj_mat4_inverse(bj_mat4 res, const bj_mat4 mat)
Inverts a 4x4 matrix.
Definition linmath.h:1006
BJ_INLINE void bj_vec4_scale(bj_vec4 res, const bj_vec4 v, bj_real_t s)
Set res to the result of multiplying v by s.
Definition linmath.h:466
BJ_INLINE void bj_mat4_copy(bj_mat4 to, const bj_mat4 from)
Copies a 4x4 matrix from one to another.
Definition linmath.h:609
BJ_INLINE void bj_mat4_scale(bj_mat4 res, const bj_mat4 lhs, bj_real_t k)
Scales a 4x4 matrix by a scalar.
Definition linmath.h:707
BJ_INLINE void bj_vec4_normalize(bj_vec4 res, const bj_vec4 v)
Normalizes the provided vec4.
Definition linmath.h:500
BJ_INLINE void bj_vec4_copy(bj_vec4 res, const bj_vec4 src)
Copies the contents of one 4D vector to another.
Definition linmath.h:542
BJ_INLINE void bj_mat4_orthonormalize(bj_mat4 res, const bj_mat4 mat)
Orthonormalizes the rows of a 4x4 matrix.
Definition linmath.h:1055
BJ_INLINE void bj_mat4_translation(bj_mat4 res, bj_real_t x, bj_real_t y, bj_real_t z)
Creates a 4x4 translation matrix.
Definition linmath.h:785
bj_real_t bj_vec3[3]
Defines a 3D vector type.
Definition linmath.h:54
BJ_INLINE void bj_mat4_mul(bj_mat4 res, const bj_mat4 lhs, const bj_mat4 rhs)
Multiplies two 4x4 matrices.
Definition linmath.h:743
bj_real_t bj_vec2[2]
Defines a 2D vector type.
Definition linmath.h:43
BJ_INLINE void bj_quat_mul_vec3(bj_vec3 res, const bj_quat q, const bj_vec3 v)
Applies a quaternion rotation to a 3D vector.
Definition linmath.h:1314