77#define BJ_M3(c,r) ((c)*3 + (r))
88#define BJ_M32(c,r) ((c)*2 + (r))
97#define BJ_M4(c,r) ((c)*4 + (r))
107#define BJ_M43(c,r) ((c)*3 + (r))
129 for (
int i = 0 ; i < 9 ; ++i) {
130 dst->m[i] = src->m[i];
178 for (
int i = 0 ; i<9 ; ++i) {
194 for (
int i = 0 ; i < 9 ; ++i) {
195 out->m[i] = A->m[i] + B->m[i];
210 for (
int i = 0 ; i < 9 ; ++i) {
211 out->m[i] = A->m[i] - B->m[i];
226 for (
int i = 0 ; i < 9 ; ++i) {
227 out->m[i] = A->m[i] * k;
247 for (
int c = 0; c < 3; ++c) {
294 return (
struct bj_vec2) { rx / w, ry / w };
296 return (
struct bj_vec2) { rx, ry };
311 M->m[
BJ_M3(2,0)] = tx;
312 M->m[
BJ_M3(2,1)] = ty;
332 for (
int r = 0 ; r < 3 ; ++r) {
336 out->
m[
BJ_M3(2,r)] = row.
z + row.
x * tx + row.
y * ty;
376 M->m[
BJ_M3(0,0)] = sx;
377 M->m[
BJ_M3(1,1)] = sy;
395 M->m[
BJ_M3(1,0)] = shy;
396 M->m[
BJ_M3(0,1)] = shx;
471 out->m[
BJ_M3(0,0)] = c00 * id; out->m[
BJ_M3(0,1)] = c01 * id; out->m[
BJ_M3(0,2)] = c02 * id;
472 out->m[
BJ_M3(1,0)] = c10 * id; out->m[
BJ_M3(1,1)] = c11 * id; out->m[
BJ_M3(1,2)] = c12 * id;
473 out->m[
BJ_M3(2,0)] = c20 * id; out->m[
BJ_M3(2,1)] = c21 * id; out->m[
BJ_M3(2,2)] = c22 * id;
504 out->m[
BJ_M3(0,0)] = c00 * id; out->m[
BJ_M3(0,1)] = c01 * id; out->m[
BJ_M3(0,2)] = c02 * id;
505 out->m[
BJ_M3(1,0)] = c10 * id; out->m[
BJ_M3(1,1)] = c11 * id; out->m[
BJ_M3(1,2)] = c12 * id;
506 out->m[
BJ_M3(2,0)] = c20 * id; out->m[
BJ_M3(2,1)] = c21 * id; out->m[
BJ_M3(2,2)] = c22 * id;
537 m[
BJ_M3(2,0)] = -(r+l)/(r-l);
538 m[
BJ_M3(2,1)] = (t+b)/(t-b);
670 out->m[
BJ_M32(0,0)] = a00*b00 + a01*b10;
671 out->m[
BJ_M32(0,1)] = a10*b00 + a11*b10;
672 out->m[
BJ_M32(1,0)] = a00*b01 + a01*b11;
673 out->m[
BJ_M32(1,1)] = a10*b01 + a11*b11;
674 out->m[
BJ_M32(2,0)] = a00*b02 + a01*b12 + a02;
675 out->m[
BJ_M32(2,1)] = a10*b02 + a11*b12 + a12;
804 for(
int i = 0 ; i < 16 ; ++i) {
805 dst->m[i] = src->m[i];
861 for(
int c = 0 ; c < 4; ++c) {
862 for(
int r0 = 0 ; r0 < 4; ++r0) {
866 for(
int i = 0 ; i < 16 ; ++i) {
883 for(
int i = 0 ; i < 16 ; ++i) {
884 out->m[i] = A->m[i] + B->m[i];
900 for(
int i = 0 ; i < 16 ; ++i) {
901 out->m[i] = A->m[i] - B->m[i];
917 for(
int i = 0;i<16;++i) {
918 out->m[i] = A->m[i] * k;
975 for (
int c = 0; c < 4; ++c) {
984 + a[
BJ_M4(3,0)] * b3;
988 + a[
BJ_M4(3,1)] * b3;
992 + a[
BJ_M4(3,2)] * b3;
996 + a[
BJ_M4(3,3)] * b3;
1041 M->m[
BJ_M4(3,0)] = x;
1042 M->m[
BJ_M4(3,1)] = y;
1043 M->m[
BJ_M4(3,2)] = z;
1065 for (
int r = 0 ; r < 4 ; ++r) {
1070 out->
m[
BJ_M4(3,r)] = row.
w + row.
x *
x + row.
y *
y + row.
z *
z;
1153 if (len <=
BJ_F(1e-4)) {
1159 const bj_real ux = axis.
x * inv, uy = axis.
y * inv, uz = axis.
z * inv;
1163 const bj_real r00 = c + t*ux*ux;
1164 const bj_real r01 = t*ux*uy - s*uz;
1165 const bj_real r02 = t*ux*uz + s*uy;
1167 const bj_real r10 = t*uy*ux + s*uz;
1168 const bj_real r11 = c + t*uy*uy;
1169 const bj_real r12 = t*uy*uz - s*ux;
1171 const bj_real r20 = t*uz*ux - s*uy;
1172 const bj_real r21 = t*uz*uy + s*ux;
1173 const bj_real r22 = c + t*uz*uz;
1189 for (
int r = 0; r < 4; ++r) {
1190 const bj_real M0 = m0[r], M1 = m1[r], M2 = m2[r];
1191 o0[r] = M0*r00 + M1*r10 + M2*r20;
1192 o1[r] = M0*r01 + M1*r11 + M2*r21;
1193 o2[r] = M0*r02 + M1*r12 + M2*r22;
1224 for (
int r = 0; r < 4; ++r) {
1225 const bj_real M1 = m1[r], M2 = m2[r];
1227 o1[r] = c*M1 + s*M2;
1228 o2[r] = -s*M1 + c*M2;
1258 for (
int r = 0; r < 4; ++r) {
1259 const bj_real M0 = m0[r], M2 = m2[r];
1260 o0[r] = c*M0 - s*M2;
1262 o2[r] = s*M0 + c*M2;
1292 for (
int r = 0; r < 4; ++r) {
1293 const bj_real M0 = m0[r], M1 = m1[r];
1294 o0[r] = c*M0 + s*M1;
1295 o1[r] = -s*M0 + c*M1;
1327 if (la <
BJ_F(1.0)) {
1332 if (lb <
BJ_F(1.0)) {
1337 const struct bj_vec3 A = { a.
x, a.
y, z_a };
1338 const struct bj_vec3 B = { b.
x, b.
y, z_b };
1382 const bj_real det = s[0]*c[5] - s[1]*c[4] + s[2]*c[3]
1383 + s[3]*c[2] - s[4]*c[1] + s[5]*c[0];
1447 (s[0]*c[5] - s[1]*c[4] + s[2]*c[3] + s[3]*c[2] - s[4]*c[1] + s[5]*c[0]);
1509 out->m[
BJ_M4(0,0)] =
x.x;
1510 out->m[
BJ_M4(0,1)] =
x.y;
1511 out->m[
BJ_M4(0,2)] =
x.z;
1512 out->m[
BJ_M4(1,0)] =
y.x;
1513 out->m[
BJ_M4(1,1)] =
y.y;
1514 out->m[
BJ_M4(1,2)] =
y.z;
1515 out->m[
BJ_M4(2,0)] =
z.x;
1516 out->m[
BJ_M4(2,1)] =
z.y;
1517 out->m[
BJ_M4(2,2)] =
z.z;
1554 m[
BJ_M4(2,0)] = (r+l)/(r-l);
1555 m[
BJ_M4(2,1)] = (t+b)/(t-b);
1556 m[
BJ_M4(2,2)] = f/(f-n);
1560 m[
BJ_M4(3,2)] = -(f*n)/(f-n);
1599 m[
BJ_M4(3,0)] = -(r+l)/(r-l);
1600 m[
BJ_M4(3,1)] = (t+b)/(t-b);
1601 m[
BJ_M4(3,2)] = -n/(f-n);
1625 m[
BJ_M4(0,0)] = a/aspect;
1633 m[
BJ_M4(2,2)] = f/(f-n);
1637 m[
BJ_M4(3,2)] = -(f*n)/(f-n);
1670 m[
BJ_M4(2,2)] = (zmax - zmin);
1674 m[
BJ_M4(3,2)] = zmin;
1874 out->m[
BJ_M43(0,0)] = a00 * b00 + a01 * b10 + a02 * b20;
1875 out->m[
BJ_M43(0,1)] = a10 * b00 + a11 * b10 + a12 * b20;
1876 out->m[
BJ_M43(0,2)] = a20 * b00 + a21 * b10 + a22 * b20;
1878 out->m[
BJ_M43(1,0)] = a00 * b01 + a01 * b11 + a02 * b21;
1879 out->m[
BJ_M43(1,1)] = a10 * b01 + a11 * b11 + a12 * b21;
1880 out->m[
BJ_M43(1,2)] = a20 * b01 + a21 * b11 + a22 * b21;
1882 out->m[
BJ_M43(2,0)] = a00 * b02 + a01 * b12 + a02 * b22;
1883 out->m[
BJ_M43(2,1)] = a10 * b02 + a11 * b12 + a12 * b22;
1884 out->m[
BJ_M43(2,2)] = a20 * b02 + a21 * b12 + a22 * b22;
1886 out->m[
BJ_M43(3,0)] = a00 * bt0 + a01 * bt1 + a02 * bt2 + a30;
1887 out->m[
BJ_M43(3,1)] = a10 * bt0 + a11 * bt1 + a12 * bt2 + a31;
1888 out->m[
BJ_M43(3,2)] = a20 * bt0 + a21 * bt1 + a22 * bt2 + a32;
1984#define bj_mat3x2_set_identity bj_mat32_set_identity
1986#define bj_mat3x2_set_translation bj_mat32_set_translation
1988#define bj_mat3x2_set_scaling_xy bj_mat32_set_scaling_xy
1990#define bj_mat3x2_set_rotation_z bj_mat32_set_rotation_z
1992#define bj_mat3x2_mul bj_mat32_mul
1994#define bj_mat3x2_transform_point bj_mat32_transform_point
1996#define bj_mat3x2_transform_dir bj_mat32_transform_dir
1998#define bj_mat3_from_mat3x2 bj_mat3_from_mat32
2000#define bj_mat3x2_from_mat3 bj_mat32_from_mat3
2003#define bj_mat4x3_set_identity bj_mat43_set_identity
2005#define bj_mat4x3_set_translation bj_mat43_set_translation
2007#define bj_mat4x3_set_scaling_xyz bj_mat43_set_scaling_xyz
2009#define bj_mat4x3_set_rotation_x bj_mat43_set_rotation_x
2011#define bj_mat4x3_set_rotation_y bj_mat43_set_rotation_y
2013#define bj_mat4x3_set_rotation_z bj_mat43_set_rotation_z
2015#define bj_mat4x3_mul bj_mat43_mul
2017#define bj_mat4x3_transform_point bj_mat43_transform_point
2019#define bj_mat4x3_transform_dir bj_mat43_transform_dir
2021#define bj_mat4_from_mat4x3 bj_mat4_from_mat43
2023#define bj_mat4x3_from_mat4 bj_mat43_from_mat4
General-purpose definitions for Banjo API.
uint32_t bj_bool
Boolean type used throughout the Banjo API.
#define BJ_INLINE
BJ_INLINE expands to an inline specifier appropriate for the toolchain.
#define BJ_RESTRICT
BJ_RESTRICT expands to the appropriate restrict qualifier per toolchain.
#define BJ_FALSE
Boolean false value (0).
#define BJ_TRUE
Boolean true value (1).
bj_real w
W component (scalar part for quaternions).
static bj_real bj_vec2_len(struct bj_vec2 v)
Euclidean length: sqrt(x^2 + y^2).
#define BJ_M43(c, r)
Index a 4×3 matrix element at column c, row r. 0 <= c < 4, 0 <= r < 3.
static void bj_mat4_orthonormalize(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A)
Orthonormalize the 3×3 linear part of a 4×4 matrix.
static void bj_mat3_transpose(struct bj_mat3 *out, const struct bj_mat3 *A)
Transpose a matrix.
static void bj_mat43_from_mat4(struct bj_mat43 *restrict M, const struct bj_mat4 *restrict A)
Demote a 4×4 matrix to 4×3 (drop projective terms).
static struct bj_vec3 bj_vec3_scale(struct bj_vec3 v, bj_real s)
Uniform scaling by a scalar: v * s.
static struct bj_vec3 bj_vec3_sub(struct bj_vec3 lhs, struct bj_vec3 rhs)
Component-wise subtraction: lhs - rhs.
static void bj_mat3_add(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A, const struct bj_mat3 *restrict B)
Component-wise addition: out = A + B.
static bj_bool bj_mat4_invert(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M)
Invert a 4×4 matrix (safe).
static void bj_mat43_set_scaling_xyz(struct bj_mat43 *restrict M, bj_real sx, bj_real sy, bj_real sz)
Build a 4×3 non-uniform XYZ scale.
static void bj_mat32_set_translation(struct bj_mat32 *restrict M, bj_real tx, bj_real ty)
Build a 3×2 translation matrix.
static void bj_mat3_mul_scalar(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A, bj_real k)
Scalar multiply: out = A * k.
static void bj_mat4_set_identity(struct bj_mat4 *restrict M)
Set a 4×4 matrix to identity.
static struct bj_vec3 bj_mat3_transform_vec3(const struct bj_mat3 *restrict M, struct bj_vec3 v)
Multiply a 3×3 matrix by a 3D vector: r = M * v.
static void bj_mat4_add(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A, const struct bj_mat4 *restrict B)
Component-wise addition: out = A + B.
static void bj_mat43_set_rotation_x(struct bj_mat43 *restrict M, bj_real angle_rad)
Build a 4×3 X-axis rotation.
static bj_real bj_vec2_dot(struct bj_vec2 a, struct bj_vec2 b)
Dot product: a.x*b.x + a.y*b.y.
static struct bj_vec2 bj_mat32_transform_dir(const struct bj_mat32 *restrict M, struct bj_vec2 v)
Transform a direction vector by a 3×2 affine matrix (ignoring translation).
static void bj_mat4_set_ortho(struct bj_mat4 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f)
Build a 3D orthographic projection into a 4×4 matrix.
static void bj_mat3_set_rotation_z(struct bj_mat3 *restrict M, bj_real angle_rad)
Build a Z-axis (i.e.
#define BJ_M32(c, r)
Index a 3×2 matrix element at column c, row r. 0 <= c < 3, 0 <= r < 2.
static void bj_mat4_from_mat43(struct bj_mat4 *restrict M, const struct bj_mat43 *restrict A)
Promote a 4×3 affine matrix to 4×4.
static struct bj_vec3 bj_mat3_col(const struct bj_mat3 *restrict M, int c)
Extract a matrix column as a vector.
static void bj_mat4_set_perspective(struct bj_mat4 *restrict M, bj_real y_fov_rad, bj_real aspect, bj_real n, bj_real f)
Build a 4×4 perspective projection from vertical FOV.
static void bj_mat4_mul(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A, const struct bj_mat4 *restrict B)
Matrix product: out = A * B.
static void bj_mat4_mul_scalar(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A, bj_real k)
Scalar multiply: out = A * k.
static void bj_mat4_sub(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A, const struct bj_mat4 *restrict B)
Component-wise subtraction: out = A - B.
static void bj_mat4_scale_axes(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict A, bj_real sx, bj_real sy, bj_real sz)
Scale basis vectors of a 4×4 matrix by per-axis factors.
static void bj_mat3_compose_translation(struct bj_mat3 *out, const struct bj_mat3 *M, bj_real tx, bj_real ty)
Right-multiply a 3×3 by a translation: out = M * T(tx, ty).
static void bj_mat4_invert_unsafe(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M)
Invert a 4×4 matrix (unsafe).
static void bj_mat3_set_viewport(struct bj_mat3 *restrict M, bj_real x, bj_real y, bj_real w, bj_real h)
Build a 2D viewport transform into a 3×3 matrix.
static struct bj_vec3 bj_mat43_transform_dir(const struct bj_mat43 *restrict M, struct bj_vec3 v)
Transform a direction vector (ignoring translation).
#define BJ_M3(c, r)
Index a 3×3 matrix element at column c, row r. 0 <= c,r < 3.
static void bj_mat4_rotate_arcball(struct bj_mat4 *restrict R, const struct bj_mat4 *restrict M, struct bj_vec2 a, struct bj_vec2 b, bj_real s)
Right-multiply by an arcball rotation between two screen points.
static void bj_mat3_set_ortho(struct bj_mat3 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t)
Build a 2D orthographic projection into a 3×3 matrix.
static void bj_mat4_copy(struct bj_mat4 *restrict dst, const struct bj_mat4 *restrict src)
Copy a matrix.
static bj_real bj_vec3_len(struct bj_vec3 v)
Euclidean length: sqrt(x^2 + y^2 + z^2).
static void bj_mat3_translate(struct bj_mat3 *restrict M, bj_real tx, bj_real ty)
Right-multiply by a translation, in place: M = M * T(tx, ty).
static void bj_mat4_rotate_z(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M, bj_real angle_rad)
Right-multiply a 4×4 by a Z-axis rotation: out = M * Rz(angle_rad).
static void bj_mat43_set_translation(struct bj_mat43 *restrict M, bj_real tx, bj_real ty, bj_real tz)
Build a 4×3 translation matrix.
static void bj_mat3_sub(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A, const struct bj_mat3 *restrict B)
Component-wise subtraction: out = A - B.
static void bj_mat4_rotate_x(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M, bj_real angle_rad)
Right-multiply a 4×4 by an X-axis rotation: out = M * Rx(angle_rad).
static void bj_mat43_set_rotation_z(struct bj_mat43 *restrict M, bj_real angle_rad)
Build a 4×3 Z-axis rotation.
#define bj_acos
Arc cosine.
static void bj_mat32_mul(struct bj_mat32 *restrict out, const struct bj_mat32 *restrict A, const struct bj_mat32 *restrict B)
Matrix product: out = A * B.
static void bj_mat32_set_identity(struct bj_mat32 *restrict M)
Set a 3×2 affine matrix to identity.
static struct bj_vec4 bj_mat4_row(const struct bj_mat4 *restrict M, int r)
Extract a matrix row as a vector.
static void bj_mat4_transpose(struct bj_mat4 *out, const struct bj_mat4 *A)
Transpose a matrix.
static struct bj_vec3 bj_mat43_transform_point(const struct bj_mat43 *restrict M, struct bj_vec3 p)
Transform a 3D point by a 4×3 affine matrix.
static struct bj_vec2 bj_mat32_transform_point(const struct bj_mat32 *restrict M, struct bj_vec2 p)
Transform a 2D point by a 3×2 affine matrix.
static bj_real bj_clamp(bj_real x, bj_real lo, bj_real hi)
Clamp x to the closed interval [lo, hi].
static void bj_mat3_copy(struct bj_mat3 *restrict dst, const struct bj_mat3 *restrict src)
Copy a matrix.
static void bj_mat4_set_translation(struct bj_mat4 *restrict M, bj_real x, bj_real y, bj_real z)
Build a 4×4 translation matrix.
static struct bj_vec4 bj_mat4_col(const struct bj_mat4 *restrict M, int c)
Extract a matrix column as a vector.
#define BJ_FZERO
Zero constant in bj_real.
static bj_real bj_vec3_dot(struct bj_vec3 a, struct bj_vec3 b)
Dot product: a.x*b.x + a.y*b.y + a.z*b.z.
static void bj_mat3_invert_unsafe(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A)
Invert a 3×3 matrix (unsafe, adjugate).
static void bj_mat43_set_identity(struct bj_mat43 *restrict M)
Set a 4×3 affine matrix to identity.
static struct bj_vec2 bj_vec2_normalize(struct bj_vec2 v)
Normalise to unit length (safe).
static void bj_mat3_set_scaling_xy(struct bj_mat3 *restrict M, bj_real sx, bj_real sy)
Build a non-uniform XY scale into a 3×3 matrix.
static void bj_mat4_rotate_axis_angle(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M, struct bj_vec3 axis, bj_real angle_rad)
Right-multiply a 4×4 by a rotation around an arbitrary axis.
static int bj_real_is_zero(bj_real x)
Absolute-zero test.
static void bj_mat43_mul(struct bj_mat43 *restrict out, const struct bj_mat43 *restrict A, const struct bj_mat43 *restrict B)
Matrix product: out = A * B.
static void bj_mat32_from_mat3(struct bj_mat32 *restrict M, const struct bj_mat3 *restrict A)
Demote a 3×3 matrix to 3×2 (drop projective terms).
static void bj_mat3_set_identity(struct bj_mat3 *restrict M)
Set a 3×3 matrix to identity.
static void bj_mat43_set_rotation_y(struct bj_mat43 *restrict M, bj_real angle_rad)
Build a 4×3 Y-axis rotation.
static struct bj_vec3 bj_vec3_cross(struct bj_vec3 l, struct bj_vec3 r)
3D cross product: l × r (right-hand rule).
static struct bj_vec4 bj_mat4_transform_vec4(const struct bj_mat4 *restrict M, struct bj_vec4 v)
Multiply a 4×4 matrix by a 4D vector: r = M * v.
static void bj_mat4_compose_translation(struct bj_mat4 *out, const struct bj_mat4 *M, bj_real x, bj_real y, bj_real z)
Right-multiply a 4×4 by a translation: out = M * T(x, y, z).
static void bj_mat32_set_scaling_xy(struct bj_mat32 *restrict M, bj_real sx, bj_real sy)
Build a 3×2 non-uniform XY scale.
static void bj_mat4_set_lookat(struct bj_mat4 *restrict M, struct bj_vec3 eye, struct bj_vec3 center, struct bj_vec3 up)
Build a left-handed look-at view matrix.
static bj_bool bj_mat3_invert(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A)
Invert a 3×3 matrix (safe, adjugate).
#define BJ_F(x)
Literal suffix helper for bj_real when float is selected.
static struct bj_vec3 bj_vec3_normalize(struct bj_vec3 v)
Normalise to unit length (safe).
static struct bj_vec3 bj_mat3_row(const struct bj_mat3 *restrict M, int r)
Extract a matrix row as a vector.
#define bj_sqrt
Square root.
float bj_real
Selected real type for float configuration.
static void bj_mat3_mul(struct bj_mat3 *restrict out, const struct bj_mat3 *restrict A, const struct bj_mat3 *restrict B)
Matrix product: out = A * B.
static void bj_mat4_set_outer_product(struct bj_mat4 *restrict out, struct bj_vec3 a, struct bj_vec3 b)
Build the outer product b * a^T as a 4×4 matrix.
static void bj_mat3_set_translation(struct bj_mat3 *restrict M, bj_real tx, bj_real ty)
Build a 3×3 translation matrix.
static void bj_mat3_set_shear_xy(struct bj_mat3 *restrict M, bj_real shx, bj_real shy)
Build an XY shear into a 3×3 matrix.
#define BJ_M4(c, r)
Index a 4×4 matrix element at column c, row r. 0 <= c,r < 4.
static void bj_mat32_set_rotation_z(struct bj_mat32 *restrict M, bj_real angle_rad)
Build a 3×2 Z-axis (2D) rotation.
static void bj_mat3_from_mat32(struct bj_mat3 *restrict M, const struct bj_mat32 *restrict A)
Promote a 3×2 affine matrix to 3×3.
static void bj_mat4_rotate_y(struct bj_mat4 *restrict out, const struct bj_mat4 *restrict M, bj_real angle_rad)
Right-multiply a 4×4 by a Y-axis rotation: out = M * Ry(angle_rad).
static void bj_mat4_translate(struct bj_mat4 *restrict M, bj_real x, bj_real y, bj_real z)
Right-multiply by a translation, in place: M = M * T(x, y, z).
static void bj_mat4_set_viewport(struct bj_mat4 *restrict M, bj_real x, bj_real y, bj_real w, bj_real h)
Build a 3D viewport transform into a 4×4 matrix.
static void bj_mat4_set_frustum(struct bj_mat4 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f)
Build a perspective frustum projection into a 4×4 matrix.
static bj_real bj_mat3_determinant(const struct bj_mat3 *restrict A)
Determinant of a 3×3 matrix.
static struct bj_vec2 bj_mat3_transform_point(const struct bj_mat3 *restrict M, struct bj_vec2 p)
Transform a 2D point by a 3×3 homogeneous transform.
3×2 column-major matrix (2D affine).
4×3 column-major matrix (3D affine).
2D vector of bj_real components.
3D vector of bj_real components.
4D vector of bj_real components.
C99 math shim with bj_real precision type and scalar utilities.
Fixed-size vector types (2D, 3D, 4D) and inline operations.