|
Banjo API 0.0.1
C99 game development API
|

Topics | |
| Geometry 2D | |
Data Structures | |
| struct | bj_mat3x3 |
| struct | bj_mat3x2 |
| struct | bj_mat4x4 |
| struct | bj_mat4x3 |
| struct | bj_rect |
| struct | bj_vec2 |
| struct | bj_vec3 |
| struct | bj_vec4 |
Macros | |
| #define | BJ_M3(c, r) |
| #define | BJ_M32(c, r) |
| #define | BJ_M4(c, r) |
| #define | BJ_M43(c, r) |
| #define | BJ_VEC2_ZERO ((struct bj_vec2){BJ_FZERO, BJ_FZERO}) |
| #define | BJ_VEC3_ZERO ((struct bj_vec3){BJ_FZERO, BJ_FZERO, BJ_FZERO}) |
| #define | BJ_VEC4_ZERO ((struct bj_vec4){BJ_FZERO, BJ_FZERO, BJ_FZERO, BJ_FZERO}) |
Functions | |
| static void | bj_mat3_set_identity (struct bj_mat3x3 *restrict M) |
| static void | bj_mat3_copy (struct bj_mat3x3 *restrict dst, const struct bj_mat3x3 *restrict src) |
| static struct bj_vec3 | bj_mat3_row (const struct bj_mat3x3 *restrict M, int r) |
| static struct bj_vec3 | bj_mat3_col (const struct bj_mat3x3 *restrict M, int c) |
| static void | bj_mat3_transpose (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A) |
| static void | bj_mat3_add (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A, const struct bj_mat3x3 *restrict B) |
| static void | bj_mat3_sub (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A, const struct bj_mat3x3 *restrict B) |
| static void | bj_mat3_mul_scalar (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A, bj_real k) |
| static void | bj_mat3_mul (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A, const struct bj_mat3x3 *restrict B) |
| static struct bj_vec3 | bj_mat3_transform_vec3 (const struct bj_mat3x3 *restrict M, struct bj_vec3 v) |
| static struct bj_vec2 | bj_mat3_transform_point (const struct bj_mat3x3 *restrict M, struct bj_vec2 p) |
| static void | bj_mat3_set_translation (struct bj_mat3x3 *restrict M, bj_real tx, bj_real ty) |
| static void | bj_mat3_translate (struct bj_mat3x3 *restrict M, bj_real tx, bj_real ty) |
| static void | bj_mat3_set_scaling_xy (struct bj_mat3x3 *restrict M, bj_real sx, bj_real sy) |
| static void | bj_mat3_set_shear_xy (struct bj_mat3x3 *restrict M, bj_real shx, bj_real shy) |
| static void | bj_mat3_set_rotation_z (struct bj_mat3x3 *restrict M, bj_real angle) |
| static bj_real | bj_mat3_determinant (const struct bj_mat3x3 *restrict A) |
| static bj_bool | bj_mat3_invert (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A) |
| static void | bj_mat3_invert_unsafe (struct bj_mat3x3 *restrict out, const struct bj_mat3x3 *restrict A) |
| static void | bj_mat3_set_ortho (struct bj_mat3x3 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t) |
| static void | bj_mat3_set_viewport (struct bj_mat3x3 *restrict M, bj_real x, bj_real y, bj_real w, bj_real h) |
| static void | bj_mat3x2_set_identity (struct bj_mat3x2 *restrict M) |
| static void | bj_mat3x2_set_translation (struct bj_mat3x2 *restrict M, bj_real tx, bj_real ty) |
| static void | bj_mat3x2_set_scaling_xy (struct bj_mat3x2 *restrict M, bj_real sx, bj_real sy) |
| static void | bj_mat3x2_set_rotation_z (struct bj_mat3x2 *restrict M, bj_real angle) |
| static void | bj_mat3x2_mul (struct bj_mat3x2 *restrict out, const struct bj_mat3x2 *restrict A, const struct bj_mat3x2 *restrict B) |
| static struct bj_vec2 | bj_mat3x2_transform_point (const struct bj_mat3x2 *restrict M, struct bj_vec2 p) |
| static struct bj_vec2 | bj_mat3x2_transform_dir (const struct bj_mat3x2 *restrict M, struct bj_vec2 v) |
| static void | bj_mat3_from_mat3x2 (struct bj_mat3x3 *restrict M, const struct bj_mat3x2 *restrict A) |
| static void | bj_mat3x2_from_mat3 (struct bj_mat3x2 *restrict M, const struct bj_mat3x3 *restrict A) |
| static void | bj_mat4_set_identity (struct bj_mat4x4 *restrict M) |
| static void | bj_mat4_copy (struct bj_mat4x4 *restrict dst, const struct bj_mat4x4 *restrict src) |
| static struct bj_vec4 | bj_mat4_row (const struct bj_mat4x4 *restrict M, int r) |
| static struct bj_vec4 | bj_mat4_col (const struct bj_mat4x4 *restrict M, int c) |
| static void | bj_mat4_transpose (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A) |
| static void | bj_mat4_add (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A, const struct bj_mat4x4 *restrict B) |
| static void | bj_mat4_sub (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A, const struct bj_mat4x4 *restrict B) |
| static void | bj_mat4_mul_scalar (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A, bj_real k) |
| static void | bj_mat4_scale_axes (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A, bj_real sx, bj_real sy, bj_real sz) |
| static void | bj_mat4_mul (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A, const struct bj_mat4x4 *restrict B) |
| static struct bj_vec4 | bj_mat4_transform_vec4 (const struct bj_mat4x4 *restrict M, struct bj_vec4 v) |
| static void | bj_mat4_set_translation (struct bj_mat4x4 *restrict M, bj_real x, bj_real y, bj_real z) |
| static void | bj_mat4_translate (struct bj_mat4x4 *restrict M, bj_real x, bj_real y, bj_real z) |
| static void | bj_mat4_set_outer_product (struct bj_mat4x4 *restrict out, struct bj_vec3 a, struct bj_vec3 b) |
| static void | bj_mat4_rotate_axis_andle (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M, struct bj_vec3 axis, bj_real angle) |
| static void | bj_mat4_rotate_x (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M, bj_real a) |
| static void | bj_mat4_rotate_y (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M, bj_real a) |
| static void | bj_mat4_rotate_z (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M, bj_real a) |
| static void | bj_mat4_rotate_arcball (struct bj_mat4x4 *restrict R, const struct bj_mat4x4 *restrict M, struct bj_vec2 a, struct bj_vec2 b, bj_real s) |
| static bj_bool | bj_mat4_invert (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M) |
| static void | bj_mat4_invert_unsafe (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict M) |
| static void | bj_mat4_orthonormalize (struct bj_mat4x4 *restrict out, const struct bj_mat4x4 *restrict A) |
| static void | bj_mat4_set_frustum (struct bj_mat4x4 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f) |
| static void | bj_mat4_set_ortho (struct bj_mat4x4 *restrict M, bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f) |
| static void | bj_mat4_set_perspective (struct bj_mat4x4 *restrict M, bj_real y_fov, bj_real aspect, bj_real n, bj_real f) |
| static void | bj_mat4_set_viewport (struct bj_mat4x4 *restrict M, bj_real x, bj_real y, bj_real w, bj_real h) |
| static void | bj_mat4_set_lookat (struct bj_mat4x4 *restrict M, struct bj_vec3 eye, struct bj_vec3 center, struct bj_vec3 up) |
| static void | bj_mat4x3_set_identity (struct bj_mat4x3 *restrict M) |
| static void | bj_mat4x3_set_translation (struct bj_mat4x3 *restrict M, bj_real tx, bj_real ty, bj_real tz) |
| static void | bj_mat4x3_set_scaling_xyz (struct bj_mat4x3 *restrict M, bj_real sx, bj_real sy, bj_real sz) |
| static void | bj_mat4x3_set_rotation_x (struct bj_mat4x3 *restrict M, bj_real a) |
| static void | bj_mat4x3_set_rotation_y (struct bj_mat4x3 *restrict M, bj_real a) |
| static void | bj_mat4x3_set_rotation_z (struct bj_mat4x3 *restrict M, bj_real a) |
| static void | bj_mat4x3_mul (struct bj_mat4x3 *restrict out, const struct bj_mat4x3 *restrict A, const struct bj_mat4x3 *restrict B) |
| static struct bj_vec3 | bj_mat4x3_transform_point (const struct bj_mat4x3 *restrict M, struct bj_vec3 p) |
| static struct bj_vec3 | bj_mat4x3_transform_dir (const struct bj_mat4x3 *restrict M, struct bj_vec3 v) |
| static void | bj_mat4_from_mat4x3 (struct bj_mat4x4 *restrict M, const struct bj_mat4x3 *restrict A) |
| static void | bj_mat4x3_from_mat4 (struct bj_mat4x3 *restrict M, const struct bj_mat4x4 *restrict A) |
| static struct bj_vec4 | bj_quat_identity (void) |
| static bj_real | bj_quat_dot (struct bj_vec4 a, struct bj_vec4 b) |
| static bj_real | bj_quat_norm2 (struct bj_vec4 q) |
| static bj_real | bj_quat_norm (struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_normalize (struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_conjugate (struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_inverse (struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_mul (struct bj_vec4 p, struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_slerp (struct bj_vec4 a, struct bj_vec4 b, bj_real t) |
| static struct bj_vec4 | bj_quat_from_axis_angle (struct bj_vec3 axis, bj_real angle_rad) |
| static struct bj_vec3 | bj_quat_rotate_vec3 (struct bj_vec4 q, struct bj_vec3 v) |
| static struct bj_vec4 | bj_quat_rotate_vec4 (struct bj_vec4 q, struct bj_vec4 v) |
| static void | bj_quat_to_mat4 (struct bj_mat4x4 *restrict M, struct bj_vec4 q) |
| static struct bj_vec4 | bj_quat_from_mat4 (const struct bj_mat4x4 *restrict M) |
| bj_bool | bj_rect_intersection (const struct bj_rect *rect_a, const struct bj_rect *rect_b, struct bj_rect *result) |
| static struct bj_vec2 | bj_vec2_map (struct bj_vec2 a, bj_real(*f)(bj_real)) |
| static struct bj_vec2 | bj_vec2_add (struct bj_vec2 lhs, struct bj_vec2 rhs) |
| static struct bj_vec2 | bj_vec2_add_scaled (struct bj_vec2 lhs, struct bj_vec2 rhs, bj_real s) |
| static struct bj_vec2 | bj_vec2_sub (const struct bj_vec2 lhs, const struct bj_vec2 rhs) |
| static struct bj_vec2 | bj_vec2_scale (struct bj_vec2 v, bj_real s) |
| static struct bj_vec2 | bj_vec2_mul_comp (const struct bj_vec2 v, const struct bj_vec2 s) |
| static bj_real | bj_vec2_dot (struct bj_vec2 a, struct bj_vec2 b) |
| static bj_real | bj_vec2_perp_dot (struct bj_vec2 a, struct bj_vec2 b) |
| static bj_real | bj_vec2_len (struct bj_vec2 v) |
| static struct bj_vec2 | bj_vec2_scale_to_len (struct bj_vec2 v, bj_real L) |
| static bj_real | bj_vec2_distance_sq (struct bj_vec2 a, struct bj_vec2 b) |
| static bj_real | bj_vec2_distance (const struct bj_vec2 a, const struct bj_vec2 b) |
| static struct bj_vec2 | bj_vec2_normalize (struct bj_vec2 v) |
| static struct bj_vec2 | bj_vec2_normalize_unsafe (struct bj_vec2 v) |
| static struct bj_vec2 | bj_vec2_min (struct bj_vec2 a, struct bj_vec2 b) |
| static struct bj_vec2 | bj_vec2_max (struct bj_vec2 a, struct bj_vec2 b) |
| static struct bj_vec3 | bj_vec3_map (struct bj_vec3 a, bj_real(*f)(bj_real)) |
| static struct bj_vec3 | bj_vec3_add (struct bj_vec3 lhs, struct bj_vec3 rhs) |
| static struct bj_vec3 | bj_vec3_add_scaled (struct bj_vec3 lhs, struct bj_vec3 rhs, bj_real s) |
| static struct bj_vec3 | bj_vec3_sub (struct bj_vec3 lhs, struct bj_vec3 rhs) |
| static struct bj_vec3 | bj_vec3_scale (struct bj_vec3 v, bj_real s) |
| static bj_real | bj_vec3_dot (struct bj_vec3 a, struct bj_vec3 b) |
| static bj_real | bj_vec3_len (struct bj_vec3 v) |
| static struct bj_vec3 | bj_vec3_scale_to_len (struct bj_vec3 v, bj_real L) |
| static bj_real | bj_vec3_distance_sq (struct bj_vec3 a, struct bj_vec3 b) |
| static bj_real | bj_vec3_distance (struct bj_vec3 a, struct bj_vec3 b) |
| static struct bj_vec3 | bj_vec3_normalize (struct bj_vec3 v) |
| static struct bj_vec3 | bj_vec3_normalize_unsafe (struct bj_vec3 v) |
| static struct bj_vec3 | bj_vec3_min (struct bj_vec3 a, struct bj_vec3 b) |
| static struct bj_vec3 | bj_vec3_max (struct bj_vec3 a, struct bj_vec3 b) |
| static struct bj_vec3 | bj_vec3_cross (struct bj_vec3 l, struct bj_vec3 r) |
| static struct bj_vec3 | bj_vec3_reflect (struct bj_vec3 v, struct bj_vec3 n) |
| static struct bj_vec4 | bj_vec4_map (struct bj_vec4 a, bj_real(*f)(bj_real)) |
| static struct bj_vec4 | bj_vec4_add (struct bj_vec4 lhs, struct bj_vec4 rhs) |
| static struct bj_vec4 | bj_vec4_add_scaled (struct bj_vec4 lhs, struct bj_vec4 rhs, bj_real s) |
| static struct bj_vec4 | bj_vec4_sub (struct bj_vec4 lhs, struct bj_vec4 rhs) |
| static struct bj_vec4 | bj_vec4_scale (struct bj_vec4 v, bj_real s) |
| static bj_real | bj_vec4_dot (struct bj_vec4 a, struct bj_vec4 b) |
| static bj_real | bj_vec4_len (struct bj_vec4 v) |
| static struct bj_vec4 | bj_vec4_normalize (struct bj_vec4 v) |
| static struct bj_vec4 | bj_vec4_normalize_unsafe (struct bj_vec4 v) |
| static struct bj_vec4 | bj_vec4_min (struct bj_vec4 a, struct bj_vec4 b) |
| static struct bj_vec4 | bj_vec4_max (struct bj_vec4 a, struct bj_vec4 b) |
| static struct bj_vec4 | bj_vec4_cross_xyz (struct bj_vec4 l, struct bj_vec4 r) |
| static struct bj_vec4 | bj_vec4_reflect (struct bj_vec4 v, struct bj_vec4 n) |
Real type selection and helpers | |
| typedef float | bj_real |
| #define | BJ_F(x) |
| #define | BJ_EPSILON (FLT_EPSILON) |
| #define | BJ_FI(x) |
| #define | BJ_FZERO (BJ_F(0.0)) |
Scalar utilities | |
Generic scalar helpers. All arguments and results are bj_real. | |
| static bj_real | bj_clamp (bj_real x, bj_real lo, bj_real hi) |
| static bj_real | bj_step (bj_real edge, bj_real x) |
| static bj_real | bj_smoothstep (bj_real e0, bj_real e1, bj_real x) |
| static bj_real | bj_fract (bj_real x) |
| static bj_real | bj_mod (bj_real x, bj_real y) |
Absolute-epsilon comparisons | |
Comparisons using BJ_EPSILON as an absolute tolerance. | |
| static int | bj_real_eq (bj_real a, bj_real b) |
| static int | bj_real_neq (bj_real a, bj_real b) |
| static int | bj_real_lt (bj_real a, bj_real b) |
| static int | bj_real_gt (bj_real a, bj_real b) |
| static int | bj_real_lte (bj_real a, bj_real b) |
| static int | bj_real_gte (bj_real a, bj_real b) |
| static int | bj_real_cmp (bj_real a, bj_real b) |
Relative-epsilon comparisons | |
Comparisons using a scale-dependent tolerance. | |
| static bj_real | bj_real_relative_scale (bj_real a, bj_real b) |
| static int | bj_real_eq_rel (bj_real a, bj_real b) |
| static int | bj_real_neq_rel (bj_real a, bj_real b) |
| static int | bj_real_lt_rel (bj_real a, bj_real b) |
| static int | bj_real_gt_rel (bj_real a, bj_real b) |
| static int | bj_real_lte_rel (bj_real a, bj_real b) |
| static int | bj_real_gte_rel (bj_real a, bj_real b) |
| static int | bj_real_cmp_rel (bj_real a, bj_real b) |
Zero tests and helpers | |
Utilities for zero checks and safe normalization. | |
| static int | bj_real_is_zero (bj_real x) |
| static int | bj_real_is_zero_scaled (bj_real x, bj_real scale) |
| static bj_real | bj_real_snap_zero (bj_real x) |
| static bj_real | bj_real_snorm_safe (bj_real x, bj_real len) |
Circle constants | |
| #define | BJ_PI_F (3.14159265358979323846f) |
| #define | BJ_TAU_F (6.28318530717958647692f) |
| #define | BJ_PI_D (3.14159265358979323846264338327950288) |
| #define | BJ_TAU_D (6.28318530717958647692528676655900576) |
| #define | BJ_PI_L (3.141592653589793238462643383279502884L) |
| #define | BJ_TAU_L (6.283185307179586476925286766559005768L) |
| #define | BJ_PI (BJ_F(3.141592653589793238462643383279502884)) |
| #define | BJ_TAU (BJ_F(6.283185307179586476925286766559005768)) |
Typed wrappers (float) | |
Thin aliases to <math.h> float functions. | |
| #define | bj_absf fabsf |
| #define | bj_acosf acosf |
| #define | bj_atan2f atan2f |
| #define | bj_copysignf copysignf |
| #define | bj_cosf cosf |
| #define | bj_expf expf |
| #define | bj_floorf floorf |
| #define | bj_fmodf fmodf |
| #define | bj_logf logf |
| #define | bj_maxf fmaxf |
| #define | bj_minf fminf |
| #define | bj_powf powf |
| #define | bj_roundf roundf |
| #define | bj_sinf sinf |
| #define | bj_sqrtf sqrtf |
| #define | bj_tanf tanf |
Typed wrappers (double) | |
Thin aliases to <math.h> double functions. | |
| #define | bj_absd fabs |
| #define | bj_acosd acos |
| #define | bj_atan2d atan2 |
| #define | bj_copysignd copysign |
| #define | bj_cosd cos |
| #define | bj_expd exp |
| #define | bj_floord floor |
| #define | bj_fmodd fmod |
| #define | bj_logd log |
| #define | bj_maxd fmax |
| #define | bj_mind fmin |
| #define | bj_powd pow |
| #define | bj_roundd round |
| #define | bj_sind sin |
| #define | bj_sqrtd sqrt |
| #define | bj_tand tan |
Typed wrappers (long double) | |
Thin aliases to <math.h> long double functions. | |
| #define | bj_absl fabsl |
| #define | bj_acosl acosl |
| #define | bj_atan2l atan2l |
| #define | bj_copysignl copysignl |
| #define | bj_cosl cosl |
| #define | bj_expl expl |
| #define | bj_floorl floorl |
| #define | bj_fmodl fmodl |
| #define | bj_logl logl |
| #define | bj_maxl fmaxl |
| #define | bj_minl fminl |
| #define | bj_powl powl |
| #define | bj_roundl roundl |
| #define | bj_sinl sinl |
| #define | bj_sqrtl sqrtl |
| #define | bj_tanl tanl |
Precision-dispatch to match bj_real | |
Map generic bj_* names to the active precision. | |
| #define | bj_abs bj_absf |
| #define | bj_acos bj_acosf |
| #define | bj_atan2 bj_atan2f |
| #define | bj_copysign bj_copysignf |
| #define | bj_cos bj_cosf |
| #define | bj_exp bj_expf |
| #define | bj_floor bj_floorf |
| #define | bj_fmod bj_fmodf |
| #define | bj_log bj_logf |
| #define | bj_max bj_maxf |
| #define | bj_min bj_minf |
| #define | bj_pow bj_powf |
| #define | bj_round bj_roundf |
| #define | bj_sin bj_sinf |
| #define | bj_sqrt bj_sqrtf |
| #define | bj_tan bj_tanf |
Math utilities (precision abstraction, constants, scalar functions).
This header provides:
All functions are thin wrappers around <math.h> with consistent naming and precision handling. They are dimensionless utilities: values are treated as pure scalars without physical units.
| struct bj_mat3x3 |
| Data Fields | ||
|---|---|---|
| bj_real | m[9] | |
| struct bj_mat3x2 |
| struct bj_mat4x4 |
| struct bj_mat4x3 |
| struct bj_rect |
| struct bj_vec2 |
| struct bj_vec3 |
| struct bj_vec4 |
| #define bj_abs bj_absf |
Absolute value.
| #define bj_absd fabs |
Absolute value (double)
| #define bj_absf fabsf |
Absolute value (float)
| #define bj_absl fabsl |
Absolute value (long double)
| #define bj_acos bj_acosf |
Arc cosine.
| #define bj_acosd acos |
Arc cosine (double)
| #define bj_acosf acosf |
Arc cosine (float)
| #define bj_acosl acosl |
Arc cosine (long double)
| #define bj_atan2 bj_atan2f |
Arc tangent.
| #define bj_atan2d atan2 |
Arc tangent (float)
| #define bj_atan2f atan2f |
Arc tangent (float)
| #define bj_atan2l atan2l |
Arc tangent (float)
| #define bj_copysign bj_copysignf |
Copy sign.
| #define bj_copysignd copysign |
Copy sign (double)
| #define bj_copysignf copysignf |
Copy sign (float)
| #define bj_copysignl copysignl |
Copy sign (long double)
| #define bj_cos bj_cosf |
Cosine.
| #define bj_cosd cos |
Cosine (double)
| #define bj_cosf cosf |
Cosine (float)
| #define bj_cosl cosl |
Cosine (long double)
| #define BJ_EPSILON (FLT_EPSILON) |
Machine epsilon for bj_real when float is selected.
| #define bj_exp bj_expf |
Exponential.
| #define bj_expd exp |
Exponential (double)
| #define bj_expf expf |
Exponential (float)
| #define bj_expl expl |
Exponential (long double)
| #define BJ_F | ( | x | ) |
Literal suffix helper for bj_real when float is selected.
| #define BJ_FI | ( | x | ) |
| #define bj_floor bj_floorf |
Floor.
| #define bj_floord floor |
Floor (double)
| #define bj_floorf floorf |
Floor (float)
| #define bj_floorl floorl |
Floor (long double)
| #define bj_fmod bj_fmodf |
Floating modulus.
| #define bj_fmodd fmod |
Floating modulus (double)
| #define bj_fmodf fmodf |
Floating modulus (float)
| #define bj_fmodl fmodl |
Floating modulus (long double)
| #define bj_log bj_logf |
Natural logarithm.
| #define bj_logd log |
Natural log (double)
| #define bj_logf logf |
Natural log (float)
| #define bj_logl logl |
Natural log (long double)
| #define BJ_M3 | ( | c, | |
| r ) |
| #define BJ_M32 | ( | c, | |
| r ) |
| #define BJ_M4 | ( | c, | |
| r ) |
| #define BJ_M43 | ( | c, | |
| r ) |
| #define bj_max bj_maxf |
Maximum of two floats.
| #define bj_maxd fmax |
Maximum of two doubles.
| #define bj_maxf fmaxf |
Maximum of two floats.
| #define bj_maxl fmaxl |
Maximum of two long doubles.
| #define bj_min bj_minf |
Minimum of two floats.
| #define bj_mind fmin |
Minimum of two doubles.
| #define bj_minf fminf |
Minimum of two floats.
| #define bj_minl fminl |
Minimum of two long doubles.
| #define BJ_PI_D (3.14159265358979323846264338327950288) |
Double-precision PI.
| #define BJ_PI_F (3.14159265358979323846f) |
Single-precision PI.
| #define BJ_PI_L (3.141592653589793238462643383279502884L) |
Long-double PI.
| #define bj_pow bj_powf |
Power.
| #define bj_powd pow |
Power (double)
| #define bj_powf powf |
Power (float)
| #define bj_powl powl |
Power (long double)
| #define bj_round bj_roundf |
Round to nearest integer.
| #define bj_roundd round |
Round to nearest (double)
| #define bj_roundf roundf |
Round to nearest (float)
| #define bj_roundl roundl |
Round to nearest (long double)
| #define bj_sin bj_sinf |
Sine.
| #define bj_sind sin |
Sine (double)
| #define bj_sinf sinf |
Sine (float)
| #define bj_sinl sinl |
Sine (long double)
| #define bj_sqrt bj_sqrtf |
Square root.
| #define bj_sqrtd sqrt |
Square root (double)
| #define bj_sqrtf sqrtf |
Square root (float)
| #define bj_sqrtl sqrtl |
Square root (long double)
| #define bj_tan bj_tanf |
Tangent.
| #define bj_tand tan |
Tangent (double)
| #define bj_tanf tanf |
Tangent (float)
| #define bj_tanl tanl |
Tangent (long double)
| #define BJ_TAU (BJ_F(6.283185307179586476925286766559005768)) |
TAU in the selected bj_real precision.
| #define BJ_TAU_D (6.28318530717958647692528676655900576) |
Double-precision TAU (2 * PI).
| #define BJ_TAU_F (6.28318530717958647692f) |
Single-precision TAU (2 * PI).
| #define BJ_TAU_L (6.283185307179586476925286766559005768L) |
Long-double TAU (2 * PI).
| typedef float bj_real |
Selected real type for float configuration.
Clamp x to the closed interval [lo, hi].
| x | Input value |
| lo | Lower bound |
| hi | Upper bound |
Fractional part of x.
| x | Input value |
|
inlinestatic |
Component-wise addition: out = A + B.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
| B | Input 3×3 matrix. |
Extract a matrix column as a vector.
| M | Input 3×3 matrix. |
| c | index (0-based). |
|
inlinestatic |
Copy a matrix.
| dst | Output 3×3 matrix. |
| src | Input 3×3 matrix. |
|
inlinestatic |
Promote a 3×2 affine matrix to 3×3.
| M | Output 3×3 matrix. |
| A | Input 3×2 matrix. |
|
inlinestatic |
Invert a 3×3 matrix (safe, adjugate).
Computes A^{-1} = adj(A) / det(A). If det(A) is zero by bj_real_is_zero, returns 0 and leaves out unspecified.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
|
inlinestatic |
Invert a 3×3 matrix (unsafe, adjugate).
Same as bj_mat3_invert but skips the singularity check and divides by det(A) unconditionally. Faster when invertibility is guaranteed.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix (must be nonsingular). |
|
inlinestatic |
Matrix product: out = A * B.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
| B | Input 3×3 matrix. |
|
inlinestatic |
Scalar multiply: out = A * k.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
| k | Uniform scale factor. |
Extract a matrix row as a vector.
| M | Input 3×3 matrix. |
| r | index (0-based). |
|
inlinestatic |
Set a 3×3 matrix to identity.
| M | Output 3×3 matrix. |
|
inlinestatic |
Build a 2D orthographic projection into a 3×3 matrix.
| M | Output 3×3 matrix. |
| l | Input scalar. |
| r | scalar (0-based). |
| b | Input scalar. |
| t | Input scalar. |
Matrix operation.
| M | Output 3×3 matrix. |
| angle | Rotation angle in radians. |
Apply non-uniform XY scale to a 3×3 matrix.
| M | Output 3×3 matrix. |
| sx | Scale on x. |
| sy | Scale on y. |
Build an XY shear into a 3×3 matrix.
| M | Output 3×3 matrix. |
| shx | Input scalar. |
| shy | Input scalar. |
Build a 3×3 translation matrix.
| M | Output 3×3 matrix. |
| tx | Translation along x. |
| ty | Translation along y. |
|
inlinestatic |
Build a 2D viewport transform into a 3×3 matrix.
| M | Output 3×3 matrix. |
| x | Viewport X origin in pixels. |
| y | Viewport Y origin in pixels. |
| w | Viewport width in pixels. |
| h | Viewport height in pixels. |
|
inlinestatic |
Component-wise subtraction: out = A - B.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
| B | Input 3×3 matrix. |
|
inlinestatic |
Transform a 2D point by a 3×3 homogeneous transform.
| M | Input 3×3 matrix. |
| p | Input point. |
|
inlinestatic |
Multiply a 3×3 matrix by a 3D vector: r = M * v.
| M | Input 3×3 matrix. |
| v | Input vector. |
Right-multiply by a translation: M = M * T(tx,ty).
| M | Output 3×3 matrix. |
| tx | Translation along x. |
| ty | Translation along y. |
|
inlinestatic |
Transpose a matrix.
| out | Output 3×3 matrix. |
| A | Input 3×3 matrix. |
|
inlinestatic |
Demote a 3×3 matrix to 3×2 (drop projective terms).
| M | Output 3×2 matrix. |
| A | Input 3×3 matrix. |
|
inlinestatic |
Matrix product: out = A * B.
| out | Output 3×2 matrix. |
| A | Input 3×2 matrix. |
| B | Input 3×2 matrix. |
|
inlinestatic |
Set a 3×2 affine matrix to identity.
| M | Output 3×2 matrix. |
Matrix operation.
| M | Output 3×2 matrix. |
| angle | Rotation angle in radians. |
Scalar multiply: M = sx * k.
| M | Output 3×2 matrix. |
| sx | Scale on x. |
| sy | Scale on y. |
|
inlinestatic |
Matrix operation.
| M | Output 3×2 matrix. |
| tx | Translation along x. |
| ty | Translation along y. |
|
inlinestatic |
Transform a direction vector (ignoring translation).
| M | Input 3×2 matrix. |
| v | Input vector. |
|
inlinestatic |
Transform a 2D point by a 3×2 affine matrix.
| M | Input 3×2 matrix. |
| p | Input point. |
|
inlinestatic |
Component-wise addition: out = A + B.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
| B | Input 4×4 matrix. |
Extract a matrix column as a vector.
| M | Input 4×4 matrix. |
| c | index (0-based). |
|
inlinestatic |
Copy a matrix.
| dst | Output 4×4 matrix. |
| src | Input 4×4 matrix. |
|
inlinestatic |
Promote a 4×3 affine matrix to 4×4.
| M | Output 4×4 matrix. |
| A | Input 4×3 matrix. |
|
inlinestatic |
Invert a 4×4 matrix (safe).
Computes A^{-1} via cofactors. If det(A) is zero by bj_real_is_zero, returns 0 and leaves out unspecified.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
|
inlinestatic |
Invert a 4×4 matrix (unsafe).
Same as bj_mat4_invert but skips the singularity check and divides by det(A) unconditionally.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix (must be nonsingular). |
|
inlinestatic |
Matrix product: out = A * B.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
| B | Input 4×4 matrix. |
|
inlinestatic |
Scalar multiply: out = A * k.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
| k | Uniform scale factor. |
|
inlinestatic |
Orthonormalize the 3×3 linear part of a 4×4 matrix.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
|
inlinestatic |
Build a 4×4 rotation from two unit vectors (arcball).
| R | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
| a | Input 2D vector. |
| b | Input 2D vector. |
| s | Scale factors as a vector. |
|
inlinestatic |
Right-multiply a 4×4 by a rotation around an arbitrary axis.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
| axis | Unit axis of rotation. |
| angle | Rotation angle in radians. |
|
inlinestatic |
Right-multiply by an X-axis rotation.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
| a | Input scalar. |
|
inlinestatic |
Right-multiply by a Y-axis rotation.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
| a | Input scalar. |
|
inlinestatic |
Right-multiply by a Z-axis rotation.
| out | Output 4×4 matrix. |
| M | Input 4×4 matrix. |
| a | Input scalar. |
Extract a matrix row as a vector.
| M | Input 4×4 matrix. |
| r | index (0-based). |
|
inlinestatic |
Scale basis vectors of a 4×4 matrix by per-axis factors.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
| sx | Scale on x. |
| sy | Scale on y. |
| sz | Scale on z. |
|
inlinestatic |
Build a perspective frustum into a 4×4 matrix.
| M | Output 4×4 matrix. |
| l | Input scalar. |
| r | scalar (0-based). |
| b | Input scalar. |
| t | Input scalar. |
| n | Near plane distance. |
| f | Far plane distance. |
|
inlinestatic |
Set a 4×4 matrix to identity.
| M | Output 4×4 matrix. |
|
inlinestatic |
Build a right-handed look-at view matrix.
| M | Output 4×4 matrix. |
| eye | Camera position. |
| center | Target point the camera looks at. |
| up | Approximate up direction. |
|
inlinestatic |
Build a 3D orthographic projection into a 4×4 matrix.
| M | Output 4×4 matrix. |
| l | Input scalar. |
| r | scalar (0-based). |
| b | Input scalar. |
| t | Input scalar. |
| n | Near plane distance. |
| f | Far plane distance. |
|
inlinestatic |
Add outer product r += s * v^T to a 4×4 matrix.
| out | Output 4×4 matrix. |
| a | Input 3D vector. |
| b | Input 3D vector. |
|
inlinestatic |
Build a 4×4 perspective projection from vertical FOV.
| M | Output 4×4 matrix. |
| y_fov | Vertical field of view in radians. |
| aspect | Aspect ratio width/height. |
| n | Near plane distance. |
| f | Far plane distance. |
|
inlinestatic |
Build a 4×4 translation matrix.
| M | Output 4×4 matrix. |
| x | Viewport X origin in pixels. |
| y | Viewport Y origin in pixels. |
| z | Input scalar. |
|
inlinestatic |
Build a 3D viewport transform into a 4×4 matrix.
| M | Output 4×4 matrix. |
| x | Viewport X origin in pixels. |
| y | Viewport Y origin in pixels. |
| w | Viewport width in pixels. |
| h | Viewport height in pixels. |
|
inlinestatic |
Component-wise subtraction: out = A - B.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
| B | Input 4×4 matrix. |
|
inlinestatic |
Multiply a 4×4 matrix by a 4D vector: r = M * v.
| M | Input 4×4 matrix. |
| v | Input vector. |
|
inlinestatic |
Right-multiply by a translation: M = M * T(tx,ty,tz).
| M | Output 4×4 matrix. |
| x | Viewport X origin in pixels. |
| y | Viewport Y origin in pixels. |
| z | Input scalar. |
|
inlinestatic |
Transpose a matrix.
| out | Output 4×4 matrix. |
| A | Input 4×4 matrix. |
|
inlinestatic |
Demote a 4×4 matrix to 4×3 (drop projective terms).
| M | Output 4×3 matrix. |
| A | Input 4×4 matrix. |
|
inlinestatic |
Matrix product: out = A * B.
| out | Output 4×3 matrix. |
| A | Input 4×3 matrix. |
| B | Input 4×3 matrix. |
|
inlinestatic |
Set a 4×3 affine matrix to identity.
| M | Output 4×3 matrix. |
Right-multiply by an X-axis rotation.
| M | Output 4×3 matrix. |
| a | Input scalar. |
Right-multiply by a Y-axis rotation.
| M | Output 4×3 matrix. |
| a | Input scalar. |
Right-multiply by a Z-axis rotation.
| M | Output 4×3 matrix. |
| a | Input scalar. |
|
inlinestatic |
Scalar multiply: M = sx * k.
| M | Output 4×3 matrix. |
| sx | Scale on x. |
| sy | Scale on y. |
| sz | Scale on z. |
|
inlinestatic |
Matrix operation.
| M | Output 4×3 matrix. |
| tx | Translation along x. |
| ty | Translation along y. |
| tz | Translation along z. |
|
inlinestatic |
Transform a direction vector (ignoring translation).
| M | Input 4×3 matrix. |
| v | Input vector. |
|
inlinestatic |
Transform a 3D point by a 4×3 affine matrix.
| M | Input 4×3 matrix. |
| p | Input point. |
Positive modulus with non-negative result magnitude.
| x | Dividend |
| y | Divisor (must be non-zero) |
Conjugate of a quaternion.
Negates the vector part and keeps the scalar part: conj(q) = {-x,-y,-z,w}.
| q | Quaternion. |
4D dot product between two quaternions.
| a | First quaternion. |
| b | Second quaternion. |
a·b.cos(theta) where theta is the half-angle between orientations used by bj_quat_slerp. Build a quaternion from a rotation axis and angle.
| axis | Rotation axis. Need not be unit length. |
| angle_rad | Rotation angle in radians. |
Build a quaternion from a 4×4 rotation matrix.
Only the upper-left 3×3 block is used. Assumes it encodes a proper rotation. The result is normalized.
| M | Source 4×4 matrix (column-major). |
|
inlinestatic |
Return the identity quaternion.
Represents a no-rotation. Equivalent to {0,0,0,1}.
Multiplicative inverse of a quaternion.
Returns identity if the squared norm is near zero (<= BJ_EPSILON). Otherwise q^{-1} = conj(q) / ||q||^2.
| q | Quaternion. |
Hamilton product p * q.
Composition order follows standard Hamilton convention. When used to rotate vectors via v' = q * v * q^{-1}, apply q on the left.
| p | Left quaternion. |
| q | Right quaternion. |
p*q. Euclidean norm (length).
| q | Quaternion. |
||q||. Squared Euclidean norm.
| q | Quaternion. |
||q||^2.Normalize a quaternion.
Returns identity if the input length is near zero (<= BJ_EPSILON).
| q | Quaternion. |
Rotate a 3D vector by a quaternion.
| q | Rotation quaternion. Expected to be unit length for pure rotation. |
| v | Vector to rotate. |
q is not normalized inside the function. Call bj_quat_normalize beforehand if needed. Rotate a 4D vector by a quaternion, preserving w.
| q | Rotation quaternion. Expected to be unit length for pure rotation. |
| v | Vector to rotate. Its w component is passed through unchanged. |
w. Spherical linear interpolation between two orientations.
Interpolates along the shortest arc on S^3. If inputs are nearly parallel, falls back to normalized linear interpolation to avoid divide-by-zero.
| a | Start quaternion. |
| b | End quaternion. |
| t | Interpolation factor in [0,1]. |
Fill a 4×4 rotation matrix from a quaternion.
| [out] | M | Destination matrix (column-major). |
| [in] | q | Input quaternion. It is normalized internally. |
Three-way compare using absolute epsilon.
| a | First value |
| b | Second value |
Three-way compare using relative epsilon.
| a | First value |
| b | Second value |
Equality within absolute epsilon.
| a | First value |
| b | Second value |
Equality within relative epsilon.
| a | First value |
| b | Second value |
a > b by more than absolute epsilon.
| a | First value |
| b | Second value |
a > b by more than relative epsilon.
| a | First value |
| b | Second value |
a >= b within absolute epsilon.
| a | First value |
| b | Second value |
a >= b within relative epsilon.
| a | First value |
| b | Second value |
|
inlinestatic |
Absolute-zero test.
| x | Input value |
Scaled zero test using max(1, |scale|).
| x | Input value |
| scale | Scale reference |
a < b by more than absolute epsilon.
| a | First value |
| b | Second value |
a < b by more than relative epsilon.
| a | First value |
| b | Second value |
a <= b within absolute epsilon.
| a | First value |
| b | Second value |
a <= b within relative epsilon.
| a | First value |
| b | Second value |
Inequality within absolute epsilon.
| a | First value |
| b | Second value |
Inequality within relative epsilon.
| a | First value |
| b | Second value |
Internal scale helper max(1, |a|, |b|).
| a | First value |
| b | Second value |
Snap to exact zero under absolute epsilon.
| x | Input value |
Safe scalar normalization.
| x | Numerator |
| len | Denominator magnitude |
| bj_bool bj_rect_intersection | ( | const struct bj_rect * | rect_a, |
| const struct bj_rect * | rect_b, | ||
| struct bj_rect * | result ) |
Computes the intersection of two bj_rect.
| rect_a | Pointer to the first rectangle. Must not be 0. |
| rect_b | Pointer to the second rectangle. Must not be 0. |
| result | Pointer to the rectangle where the result will be stored. Can be 0 if only checking intersection presence. |
Example usage:
Smooth Hermite step between e0 and e1.
Clamps t to [0,1].
| e0 | Start edge |
| e1 | End edge |
| x | Input value |
Step function.
| edge | Threshold edge |
| x | Input value |
Component-wise addition of two 2D vectors: res = lhs + rhs.
| lhs | Left-hand input vector. |
| rhs | Right-hand input vector. |
|
inlinestatic |
Add a scaled vector: res = a + s * b.
| lhs | Input component or vector a. |
| rhs | Input component or vector b. |
| s | Scalar factor. |
Euclidean distance between two 2D vectors.
| a | Input vector a. |
| b | Input vector b. |
Squared Euclidean distance between two 2D vectors.
| a | Input vector a. |
| b | Input vector b. |
Dot product of two 2D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Euclidean length (L2 norm) of a 2D vector.
| v | Input vector. |
Component-wise maximum of two 2D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Component-wise minimum of two 2D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Per-component scaling: res[i] = v[i] * s[i].
| v | Input vector. |
| s | Scalar factor. |
Normalize a 2D vector to unit length (safe).
Computes v / ||v||. If the squared length is zero according to bj_real_is_zero, returns the zero vector to avoid division by zero. Uses a single square root.
| v | Input vector. |
v, or {0,0} if ||v|| == 0 by bj_real_is_zero.Normalize a 2D vector to unit length (unsafe).
Computes v / ||v|| without any zero-length check. Faster on hot paths where nonzero length is guaranteed.
| v | Input vector (must be nonzero). |
v.2D "cross product" (perp dot): returns scalar a.x*b.y - a.y*b.x.
Useful for orientation tests, signed area, segment intersection.
Uniform scaling by scalar: res = v * s.
| v | Input vector. |
| s | Scalar factor. |
Scale a 2D vector to a given length.
| v | Input vector. |
| L | Desired length of the result. |
Component-wise subtraction of two 2D vectors: res = lhs - rhs.
| lhs | Left-hand input vector. |
| rhs | Right-hand input vector. |
Component-wise addition of two 3D vectors: res = lhs + rhs.
| lhs | Left-hand input vector. |
| rhs | Right-hand input vector. |
|
inlinestatic |
Add a scaled vector: res = a + s * b.
| lhs | Input component or vector a. |
| rhs | Input component or vector b. |
| s | Scalar factor. |
3D cross product: res = l × r (right-hand rule).
| l | Left-hand input vector. |
| r | Right-hand input vector. |
Euclidean distance between two 3D vectors.
| a | Input vector a. |
| b | Input vector b. |
Squared Euclidean distance between two 3D vectors.
| a | Input vector a. |
| b | Input vector b. |
Dot product of two 3D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Euclidean length (L2 norm) of a 3D vector.
| v | Input vector. |
Component-wise maximum of two 3D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Component-wise minimum of two 3D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Normalize a 3D vector to unit length (safe).
Computes v / ||v||. Returns {0,0,0} if ||v|| is zero by bj_real_is_zero. Uses one square root.
| v | Input vector. |
v, or {0,0,0} if ||v|| == 0 by bj_real_is_zero.Normalize a 3D vector to unit length (unsafe).
Computes v / ||v|| without any zero-length check.
| v | Input vector (must be nonzero). |
v.Reflect a vector about a normal: res = v - 2*dot(v, n)*n.
| v | Input vector. |
| n | Surface normal (expected normalized). |
n should be normalized for a true reflection. Uniform scaling by scalar: res = v * s.
| v | Input vector. |
| s | Scalar factor. |
Scale a 3D vector to a given length.
| v | Input vector. |
| L | Desired length of the result. |
Component-wise subtraction of two 3D vectors: res = lhs - rhs.
| lhs | Left-hand input vector. |
| rhs | Right-hand input vector. |
Component-wise addition of two 4D vectors: res = lhs + rhs.
| lhs | Left-hand input vector. |
| rhs | Right-hand input vector. |
|
inlinestatic |
Add a scaled vector: res = a + s * b.
| lhs | Input component or vector a. |
| rhs | Input component or vector b. |
| s | Scalar factor. |
Cross product using xyz components; w is set to 1.
| l | Left-hand input vector. |
| r | Right-hand input vector. |
Dot product of two 4D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Euclidean length (L2 norm) of a 4D vector.
| v | Input vector. |
Component-wise maximum of two 4D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Component-wise minimum of two 4D vectors.
| a | Input component or vector a. |
| b | Input component or vector b. |
Normalize a 4D vector to unit length (safe).
Computes v / ||v||. Returns {0,0,0,0} if ||v|| is zero by bj_real_is_zero. Uses one square root.
| v | Input vector. |
v, or {0,0,0,0} if ||v|| == 0 by bj_real_is_zero.Normalize a 4D vector to unit length (unsafe).
Computes v / ||v|| without any zero-length check.
| v | Input vector (must be nonzero). |
v.Reflect a vector about a normal: res = v - 2*dot(v, n)*n.
| v | Input vector. |
| n | Surface normal (expected normalized). |
n should be normalized for a true reflection. Uniform scaling by scalar: res = v * s.
| v | Input vector. |
| s | Scalar factor. |