Banjo API 0.0.1
C99 game development API
|
Topics | |
Geometry 2D |
Data Structures | |
struct | bj_rect_t |
Macros | |
#define | bj_quat_add bj_vec4_add |
#define | bj_quat_sub bj_vec4_sub |
#define | bj_quat_norm bj_vec4_normalize |
#define | bj_quat_scale bj_vec4_scale |
#define | bj_quat_dot bj_vec4_dot |
Typedefs | |
typedef bj_vec3 | bj_mat3x3[3] |
typedef bj_mat3x3 | bj_mat3 |
typedef bj_vec2 | bj_mat3x2[3] |
typedef bj_vec4 | bj_mat4x4[4] |
typedef bj_mat4x4 | bj_mat4 |
typedef bj_vec3 | bj_mat4x3[4] |
typedef bj_real | bj_quat[4] |
typedef struct bj_rect_t | bj_rect |
typedef bj_real | bj_vec2[2] |
typedef bj_real | bj_vec3[3] |
typedef bj_real | bj_vec4[4] |
Functions | |
static void | bj_mat3_identity (bj_mat3x3 m) |
static void | bj_mat3_copy (bj_mat3x3 to, const bj_mat3x3 from) |
static void | bj_mat3_row (bj_vec3 res, const bj_mat3x3 m, int r) |
static void | bj_mat3_col (bj_vec3 res, const bj_mat3x3 m, int c) |
static void | bj_mat3_transpose (bj_mat3x3 res, const bj_mat3x3 m) |
static void | bj_mat3_add (bj_mat3x3 res, const bj_mat3x3 a, const bj_mat3x3 b) |
static void | bj_mat3_sub (bj_mat3x3 res, const bj_mat3x3 a, const bj_mat3x3 b) |
static void | bj_mat3_scale (bj_mat3x3 res, const bj_mat3x3 m, bj_real k) |
static void | bj_mat3_mul (bj_real res[restrict static(3)][3], const bj_real lhs[restrict static(3)][3], const bj_real rhs[restrict static(3)][3]) |
static void | bj_mat3_mul_vec3 (bj_real res[restrict static(3)], const bj_real m[restrict static(3)][3], const bj_real v[restrict static(3)]) |
static void | bj_mat3_mul_point (bj_vec2 res, const bj_mat3x3 m, const bj_vec2 p) |
static void | bj_mat3_mul_vector2 (bj_vec2 res, const bj_mat3x3 m, const bj_vec2 v2) |
static void | bj_mat3_translation (bj_mat3x3 res, bj_real tx, bj_real ty) |
static void | bj_mat3_translation_inplace (bj_mat3x3 M, bj_real tx, bj_real ty) |
static void | bj_mat3_scale_xy (bj_mat3x3 res, bj_real sx, bj_real sy) |
static void | bj_mat3_shear (bj_mat3x3 res, bj_real shx, bj_real shy) |
static void | bj_mat3_rotate (bj_mat3x3 res, bj_real angle) |
static void | bj_mat3_inverse (bj_mat3x3 res, const bj_mat3x3 m) |
static void | bj_mat3_ortho (bj_real omat[restrict static(3)][3], bj_real l, bj_real r, bj_real b, bj_real t) |
static void | bj_mat3_viewport (bj_real vpmat[restrict static(3)][3], bj_real x, bj_real y, bj_real w, bj_real h) |
static void | bj_mat3x2_identity (bj_real m[restrict static(3)][2]) |
static void | bj_mat3x2_translate (bj_real m[restrict static(3)][2], bj_real tx, bj_real ty) |
static void | bj_mat3x2_scale (bj_real m[restrict static(3)][2], bj_real sx, bj_real sy) |
static void | bj_mat3x2_rotate (bj_real m[restrict static(3)][2], bj_real angle) |
static void | bj_mat3x2_mul (bj_real res[restrict static(3)][2], const bj_real A[restrict static(3)][2], const bj_real B[restrict static(3)][2]) |
static void | bj_mat3x2_mul_point (bj_real r[restrict static(2)], const bj_real m[restrict static(3)][2], const bj_real p[restrict static(2)]) |
static void | bj_mat3x2_mul_dir (bj_real r[restrict static(2)], const bj_real m[restrict static(3)][2], const bj_real v[restrict static(2)]) |
static void | bj_mat3_from_mat3x2 (bj_real out3x3[restrict static(3)][3], const bj_real a[restrict static(3)][2]) |
static void | bj_mat3x2_from_mat3 (bj_real out3x2[restrict static(3)][2], const bj_real m[restrict static(3)][3]) |
static void | bj_mat4_identity (bj_mat4x4 mat) |
static void | bj_mat4_copy (bj_mat4x4 to, const bj_mat4x4 from) |
static void | bj_mat4_row (bj_vec4 res, const bj_mat4x4 mat, int r) |
static void | bj_mat4_col (bj_vec4 res, const bj_mat4x4 mat, int c) |
static void | bj_mat4_transpose (bj_mat4x4 res, const bj_mat4x4 mat) |
static void | bj_mat4_add (bj_mat4x4 res, const bj_mat4x4 lhs, const bj_mat4x4 rhs) |
static void | bj_mat4_sub (bj_mat4x4 res, const bj_mat4x4 lhs, const bj_mat4x4 rhs) |
static void | bj_mat4_scale (bj_mat4x4 res, const bj_mat4x4 lhs, bj_real k) |
static void | bj_mat4_scale_xyz (bj_mat4x4 res, const bj_mat4x4 mat, bj_real x, bj_real y, bj_real z) |
static void | bj_mat4_mul (bj_real res[restrict static(4)][4], const bj_real lhs[restrict static(4)][4], const bj_real rhs[restrict static(4)][4]) |
static void | bj_mat4_mul_vec4 (bj_real res[restrict static(4)], const bj_real mat[restrict static(4)][4], const bj_real v[restrict static(4)]) |
static void | bj_mat4_translation (bj_mat4x4 res, bj_real x, bj_real y, bj_real z) |
static void | bj_mat4_translation_inplace (bj_mat4x4 M, bj_real x, bj_real y, bj_real z) |
static void | bj_mat4_mul_outer (bj_mat4x4 res, const bj_vec3 a, const bj_vec3 b) |
static void | bj_mat4_rotate (bj_mat4x4 res, const bj_mat4x4 mat, bj_real x, bj_real y, bj_real z, bj_real angle) |
static void | bj_mat4_rotate_x (bj_mat4x4 res, const bj_mat4x4 mat, bj_real angle) |
static void | bj_mat4_rotate_y (bj_mat4x4 res, const bj_mat4x4 mat, bj_real angle) |
static void | bj_mat4_rotate_z (bj_mat4x4 res, const bj_mat4x4 mat, bj_real angle) |
static void | bj_mat4_rotate_arcball (bj_mat4x4 R, const bj_mat4x4 M, bj_vec2 const _a, bj_vec2 const _b, bj_real s) |
static void | bj_mat4_inverse (bj_mat4x4 res, const bj_mat4x4 mat) |
static void | bj_mat4_orthonormalize (bj_mat4x4 res, const bj_mat4x4 mat) |
static void | bj_mat4_frustum (bj_real fmat[restrict static(4)][4], bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f) |
static void | bj_mat4_ortho (bj_real omat[restrict static(4)][4], bj_real l, bj_real r, bj_real b, bj_real t, bj_real n, bj_real f) |
static void | bj_mat4_perspective (bj_real pmat[restrict static(4)][4], bj_real y_fov, bj_real aspect, bj_real n, bj_real f) |
static void | bj_mat4_viewport (bj_real vpmat[restrict static(4)][4], bj_real x, bj_real y, bj_real w, bj_real h) |
static void | bj_mat4_lookat (bj_real m[restrict static(4)][4], const bj_vec3 eye, const bj_vec3 center, const bj_vec3 up) |
static void | bj_mat4x3_identity (bj_real m[restrict static(4)][3]) |
static void | bj_mat4x3_translate (bj_real m[restrict static(4)][3], bj_real tx, bj_real ty, bj_real tz) |
static void | bj_mat4x3_scale (bj_real m[restrict static(4)][3], bj_real sx, bj_real sy, bj_real sz) |
static void | bj_mat4x3_rotate_x (bj_real m[restrict static(4)][3], bj_real angle) |
static void | bj_mat4x3_rotate_y (bj_real m[restrict static(4)][3], bj_real angle) |
static void | bj_mat4x3_rotate_z (bj_real m[restrict static(4)][3], bj_real angle) |
static void | bj_mat4x3_mul (bj_real res[restrict static(4)][3], const bj_real A[restrict static(4)][3], const bj_real B[restrict static(4)][3]) |
static void | bj_mat4x3_mul_point (bj_real r[restrict static(3)], const bj_real m[restrict static(4)][3], const bj_real p[restrict static(3)]) |
static void | bj_mat4x3_mul_dir (bj_real r[restrict static(3)], const bj_real m[restrict static(4)][3], const bj_real v[restrict static(3)]) |
static void | bj_mat4_from_mat4x3 (bj_mat4x4 out, const bj_real a[restrict static(4)][3]) |
static void | bj_mat4x3_from_mat4 (bj_real out43[restrict static(4)][3], const bj_mat4x4 m) |
static void | bj_mat4x3_lookat (bj_real m[restrict static(4)][3], const bj_real eye[restrict static(3)], const bj_real center[restrict static(3)], const bj_real up[restrict static(3)]) |
static void | bj_quat_identity (bj_quat q) |
static void | bj_quat_mul (bj_quat res, const bj_quat p, const bj_quat q) |
static void | bj_quat_conjugate (bj_quat res, const bj_quat q) |
static void | bj_quat_rotation (bj_quat res, bj_real angle, const bj_vec3 axis) |
static void | bj_quat_mul_vec3 (bj_vec3 res, const bj_quat q, const bj_vec3 v) |
static void | bj_mat4_from_quat (bj_mat4 res, const bj_quat q) |
static void | bj_mat4_rotate_from_quat (bj_mat4 R, const bj_mat4 M, const bj_quat q) |
static void | bj_quat_from_mat4 (bj_quat q, const bj_mat4 M) |
bj_bool | bj_rect_intersection (const bj_rect *p_rect_a, const bj_rect *p_rect_b, bj_rect *p_result) |
static void | bj_vec2_set (bj_vec2 res, bj_real a, bj_real b) |
static void | bj_vec2_zero (bj_vec2 res) |
static void | bj_vec2_apply (bj_vec2 res, const bj_vec2 a, bj_real(*f)(bj_real)) |
static void | bj_vec2_add (bj_vec2 res, const bj_vec2 lhs, const bj_vec2 rhs) |
static void | bj_vec2_add_scaled (bj_vec2 res, const bj_vec2 a, const bj_vec2 b, bj_real s) |
static void | bj_vec2_sub (bj_vec2 res, const bj_vec2 lhs, const bj_vec2 rhs) |
static void | bj_vec2_scale (bj_vec2 res, const bj_vec2 v, bj_real s) |
static void | bj_vec2_scale_each (bj_vec2 res, const bj_vec2 v, const bj_vec2 s) |
static bj_real | bj_vec2_dot (const bj_vec2 a, const bj_vec2 b) |
static bj_real | bj_vec2_cross (const bj_vec2 a, const bj_vec2 b) |
static bj_real | bj_vec2_len (const bj_vec2 v) |
static void | bj_vec2_set_len (bj_vec2 res, const bj_vec2 v, bj_real target_len) |
static bj_real | bj_vec2_dist_squared (const bj_vec2 a, const bj_vec2 b) |
static bj_real | bj_vec2_dist (const bj_vec2 a, const bj_vec2 b) |
static void | bj_vec2_normalize (bj_vec2 res, const bj_vec2 v) |
static void | bj_vec2_min (bj_vec2 res, const bj_vec2 a, const bj_vec2 b) |
static void | bj_vec2_max (bj_vec2 res, const bj_vec2 a, const bj_vec2 b) |
static void | bj_vec2_copy (bj_vec2 res, const bj_vec2 src) |
static void | bj_vec3_set (bj_vec3 res, bj_real a, bj_real b, bj_real c) |
static void | bj_vec3_zero (bj_vec3 res) |
static void | bj_vec3_apply (bj_vec3 res, const bj_vec3 a, bj_real(*f)(bj_real)) |
static void | bj_vec3_add (bj_vec3 res, const bj_vec3 lhs, const bj_vec3 rhs) |
static void | bj_vec3_add_scaled (bj_vec3 res, const bj_vec3 a, const bj_vec3 b, bj_real s) |
static void | bj_vec3_sub (bj_vec3 res, const bj_vec3 lhs, const bj_vec3 rhs) |
static void | bj_vec3_scale (bj_vec3 res, const bj_vec3 v, bj_real s) |
static bj_real | bj_vec3_dot (const bj_vec3 a, const bj_vec3 b) |
static bj_real | bj_vec3_len (const bj_vec3 v) |
static void | bj_vec3_set_len (bj_vec3 res, const bj_vec3 v, bj_real target_len) |
static bj_real | bj_vec3_dist_squared (const bj_vec3 a, const bj_vec3 b) |
static bj_real | bj_vec3_dist (const bj_vec3 a, const bj_vec3 b) |
static void | bj_vec3_normalize (bj_vec3 res, const bj_vec3 v) |
static void | bj_vec3_min (bj_vec3 res, const bj_vec3 a, const bj_vec3 b) |
static void | bj_vec3_max (bj_vec3 res, const bj_vec3 a, const bj_vec3 b) |
static void | bj_vec3_copy (bj_vec3 res, const bj_vec3 src) |
static void | bj_vec3_cross (bj_vec3 res, const bj_vec3 l, const bj_vec3 r) |
static void | bj_vec3_reflect (bj_vec3 res, const bj_vec3 v, const bj_vec3 n) |
static void | bj_vec4_set (bj_vec4 res, bj_real a, bj_real b, bj_real c, bj_real d) |
static void | bj_vec4_apply (bj_vec4 res, const bj_vec4 a, bj_real(*f)(bj_real)) |
static void | bj_vec4_add (bj_vec4 res, const bj_vec4 lhs, const bj_vec4 rhs) |
static void | bj_vec4_add_scaled (bj_vec4 res, const bj_vec4 a, const bj_vec4 b, bj_real s) |
static void | bj_vec4_sub (bj_vec4 res, const bj_vec4 lhs, const bj_vec4 rhs) |
static void | bj_vec4_scale (bj_vec4 res, const bj_vec4 v, bj_real s) |
static bj_real | bj_vec4_dot (const bj_vec4 a, const bj_vec4 b) |
static bj_real | bj_vec4_len (const bj_vec4 v) |
static void | bj_vec4_normalize (bj_vec4 res, const bj_vec4 v) |
static void | bj_vec4_min (bj_vec4 res, const bj_vec4 a, const bj_vec4 b) |
static void | bj_vec4_max (bj_vec4 res, const bj_vec4 a, const bj_vec4 b) |
static void | bj_vec4_copy (bj_vec4 res, const bj_vec4 src) |
static void | bj_vec4_cross (bj_vec4 res, const bj_vec4 l, const bj_vec4 r) |
static void | bj_vec4_reflect (bj_vec4 res, const bj_vec4 v, const 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_rect_t |
#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_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_quat_add bj_vec4_add |
Alias to vector add (component-wise).
#define bj_quat_dot bj_vec4_dot |
Alias to 4D dot product.
#define bj_quat_norm bj_vec4_normalize |
Alias to normalize quaternion (scales to unit length).
#define bj_quat_scale bj_vec4_scale |
Alias to uniform scale all four components.
#define bj_quat_sub bj_vec4_sub |
Alias to vector subtract (component-wise).
#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 bj_vec2 bj_mat3x2[3] |
typedef bj_vec3 bj_mat3x3[3] |
typedef bj_vec3 bj_mat4x3[4] |
typedef bj_vec4 bj_mat4x4[4] |
typedef bj_real bj_quat[4] |
typedef float bj_real |
Selected real type for float configuration.
typedef bj_real bj_vec2[2] |
typedef bj_real bj_vec3[3] |
typedef bj_real bj_vec4[4] |
Clamp x to the closed interval [lo, hi].
x | Input value |
lo | Lower bound |
hi | Upper bound |
Fractional part of x.
x | Input value |
Component-wise addition: res = a + b.
Extract a column as a vector (column index into first subscript).
res | Output vector. |
m | Input matrix. |
c | Column index. |
Copy matrix contents.
to | Output matrix. |
from | Input matrix. |
|
inlinestatic |
Promote 3×2 to 3×3 homogeneous.
|
inlinestatic |
Set to identity matrix.
m | Output buffer. |
|
inlinestatic |
Matrix multiplication: res = lhs * rhs (column-major).
res
= lhs * rhs. Transform a point (homogeneous w=1).
res
= m * p.
|
inlinestatic |
Multiply 3×3 matrix by a 3D column vector: res = M * v.
res
= lhs * rhs. Transform a direction (w=0; ignores translation).
res
= m * v2.
|
inlinestatic |
Orthographic projection matrix (3×3).
Extract a row as a vector (row index into second subscript).
res | Output vector. |
m | Input matrix. |
r | Row index. |
Uniformly scale all elements by scalar k.
Create 2D scaling matrix with independent X/Y scales.
Component-wise subtraction: res = a - b.
Create a translation matrix.
Apply a translation in-place.
Transpose the matrix.
res | Output matrix. |
m | Input matrix. |
|
inlinestatic |
Viewport transform matrix (3×3).
|
inlinestatic |
Extract 3×2 from 3×3.
|
inlinestatic |
Set 3×2 to identity.
|
inlinestatic |
3×2 multiplication: res = A * B.
|
inlinestatic |
3×2 transform direction (no translation).
|
inlinestatic |
3×2 transform point.
Build 3×2 rotation.
Build 3×2 scale.
Build 3×2 translation.
Promote 4×3 to 4×4 homogeneous.
Convert unit quaternion to a 4×4 rotation matrix.
res | Output quaternion. |
q | Input quaternion. |
|
inlinestatic |
Off-center perspective frustum (4×4).
|
inlinestatic |
Set 4×4 to identity.
|
inlinestatic |
Look-at view matrix builder (4×4).
|
inlinestatic |
4×4 multiplication: res = lhs * rhs.
Outer product to upper-left 3×3 block of 4×4.
|
inlinestatic |
4×4 multiply by vec4.
|
inlinestatic |
Orthographic projection (4×4).
Orthonormalize upper-left 3×3 of 4×4.
|
inlinestatic |
Symmetric perspective from FOV+aspect (4×4).
|
inlinestatic |
Rotate about axis, post-multiply.
|
inlinestatic |
Arcball rotation.
Post-multiply matrix by rotation from quaternion: R = M * rot(q).
R | Output matrix. |
M | Input 4×4 matrix. |
q | Input quaternion. |
Rotate about X/Y/Z, post-multiply.
|
inlinestatic |
Scale basis vectors.
Create 4×4 translation matrix.
Apply 4×4 translation in-place.
|
inlinestatic |
Viewport transform (4×4).
Extract 4×3 from 4×4.
|
inlinestatic |
Set 4×3 to identity.
|
inlinestatic |
Look-at builder for 4×3.
|
inlinestatic |
4×3 multiplication: res = A * B.
|
inlinestatic |
4×3 transform direction (no translation).
|
inlinestatic |
4×3 transform point.
4×3 rotate X/Y/Z.
|
inlinestatic |
4×3 scale.
|
inlinestatic |
4×3 translation.
Positive modulus with non-negative result magnitude.
x | Dividend |
y | Divisor (must be non-zero) |
Conjugate quaternion: (x,y,z,w) -> (-x,-y,-z,w).
res | Output quaternion. |
q | Input quaternion. |
Extract a unit quaternion from a 4×4 rotation matrix.
q | Input quaternion. |
M | Input 4×4 matrix. |
|
inlinestatic |
Set quaternion to identity (no rotation).
q | Input quaternion. |
Hamilton product: res = p * q.
res | Output quaternion. |
p | Input quaternion. |
q | Input quaternion. |
Rotate a 3D vector by a unit quaternion.
res | Output quaternion. |
q | Input quaternion. |
v | 3D vector. |
Build a unit quaternion from axis-angle.
res | Output quaternion. |
angle | Rotation angle in radians. |
axis | 3D vector. |
axis
is near zero length, the result is implementation-defined. 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 bj_rect * | p_rect_a, |
const bj_rect * | p_rect_b, | ||
bj_rect * | p_result ) |
Computes the intersection of two bj_rect.
p_rect_a | Pointer to the first rectangle. Must not be 0. |
p_rect_b | Pointer to the second rectangle. Must not be 0. |
p_result | Pointer to the rectangle where the result will be stored. Can be 0 if only checking intersection presence. |
p_result
is 0, the function only checks for intersection presence and does not compute the intersection rectangle.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.
res | Output 2D vector. |
lhs | Left-hand input vector. |
rhs | Right-hand input vector. |
Add a scaled vector: res = a + s * b.
res | Output 2D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
s | Scalar factor. |
Copy a 2D vector.
res | Output 2D vector. |
src | Source vector to copy from. |
2D "cross product" (perp dot): returns scalar a.x*b.y - a.y*b.x.
Useful for orientation tests, signed area, segment intersection.
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.
res | Output 2D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Component-wise minimum of two 2D vectors.
res | Output 2D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Normalize a 2D vector to unit length.
res | Output 2D vector. |
v | Input vector. |
Uniform scaling by scalar: res = v * s.
res | Output 2D vector. |
v | Input vector. |
s | Scalar factor. |
Per-component scaling: res[i] = v[i] * s[i].
res | Output 2D vector. |
v | Input vector. |
s | Scalar factor. |
Set a 2D vector from components (x, y).
res | Output 2D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Scale a 2D vector to a given length.
res | Output 2D vector. |
v | Input vector. |
target_len | Desired length of the result. |
Component-wise subtraction of two 2D vectors: res = lhs - rhs.
res | Output 2D vector. |
lhs | Left-hand input vector. |
rhs | Right-hand input vector. |
|
inlinestatic |
Component-wise addition of two 3D vectors: res = lhs + rhs.
res | Output 3D vector. |
lhs | Left-hand input vector. |
rhs | Right-hand input vector. |
Add a scaled vector: res = a + s * b.
res | Output 3D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
s | Scalar factor. |
Copy a 3D vector.
res | Output 3D vector. |
src | Source vector to copy from. |
3D cross product: res = l × r (right-hand rule).
res | Output 3D vector. |
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.
res | Output 3D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Component-wise minimum of two 3D vectors.
res | Output 3D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Normalize a 3D vector to unit length.
res | Output 3D vector. |
v | Input vector. |
Reflect a vector about a normal: res = v - 2*dot(v, n)*n.
res | Output 3D vector. |
v | Input vector. |
n | Surface normal (expected normalized). |
n
should be normalized for a true reflection. Uniform scaling by scalar: res = v * s.
res | Output 3D vector. |
v | Input vector. |
s | Scalar factor. |
Set a 3D vector from components (x, y, z).
res | Output 3D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
c | Input component or vector c. |
Scale a 3D vector to a given length.
res | Output 3D vector. |
v | Input vector. |
target_len | Desired length of the result. |
Component-wise subtraction of two 3D vectors: res = lhs - rhs.
res | Output 3D vector. |
lhs | Left-hand input vector. |
rhs | Right-hand input vector. |
|
inlinestatic |
Component-wise addition of two 4D vectors: res = lhs + rhs.
res | Output 4D vector. |
lhs | Left-hand input vector. |
rhs | Right-hand input vector. |
Add a scaled vector: res = a + s * b.
res | Output 4D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
s | Scalar factor. |
Copy a 4D vector.
res | Output 4D vector. |
src | Source vector to copy from. |
Cross product using xyz components; w is set to 1.
res | Output 4D vector. |
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.
res | Output 4D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Component-wise minimum of two 4D vectors.
res | Output 4D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
Normalize a 4D vector to unit length.
res | Output 4D vector. |
v | Input vector. |
Reflect a vector about a normal: res = v - 2*dot(v, n)*n.
res | Output 4D vector. |
v | Input vector. |
n | Surface normal (expected normalized). |
n
should be normalized for a true reflection. Uniform scaling by scalar: res = v * s.
res | Output 4D vector. |
v | Input vector. |
s | Scalar factor. |
Set a 4D vector from components (x, y, z, w).
res | Output 4D vector. |
a | Input component or vector a. |
b | Input component or vector b. |
c | Input component or vector c. |
d | Input component or vector d. |