64#if defined(BJ_API_LONG_DOUBLE)
70 #define BJ_EPSILON (LDBL_EPSILON)
71#elif defined(BJ_API_FLOAT64)
77 #define BJ_EPSILON (DBL_EPSILON)
84 #define BJ_EPSILON (FLT_EPSILON)
90#define BJ_FI(x) BJ_F(1.0) / BJ_F(x)
93#define BJ_FZERO (BJ_F(0.0))
103#define BJ_PI_F (3.14159265358979323846f)
105#define BJ_TAU_F (6.28318530717958647692f)
107#define BJ_PI_D (3.14159265358979323846264338327950288)
109#define BJ_TAU_D (6.28318530717958647692528676655900576)
111#define BJ_PI_L (3.141592653589793238462643383279502884L)
113#define BJ_TAU_L (6.283185307179586476925286766559005768L)
115#define BJ_PI (BJ_F(3.141592653589793238462643383279502884))
117#define BJ_TAU (BJ_F(6.283185307179586476925286766559005768))
128#define bj_acosf acosf
129#define bj_atan2f atan2f
130#define bj_copysignf copysignf
133#define bj_floorf floorf
134#define bj_fmodf fmodf
139#define bj_roundf roundf
141#define bj_sqrtf sqrtf
154#define bj_atan2d atan2
155#define bj_copysignd copysign
158#define bj_floord floor
164#define bj_roundd round
178#define bj_acosl acosl
179#define bj_atan2l atan2l
180#define bj_copysignl copysignl
183#define bj_floorl floorl
184#define bj_fmodl fmodl
189#define bj_roundl roundl
191#define bj_sqrtl sqrtl
202#if defined(BJ_API_LONG_DOUBLE)
203 #define bj_abs bj_absl
204 #define bj_acos bj_acosl
205 #define bj_atan2 bj_atan2l
206 #define bj_copysign bj_copysignl
207 #define bj_cos bj_cosl
208 #define bj_exp bj_expl
209 #define bj_floor bj_floorl
210 #define bj_fmod bj_fmodl
211 #define bj_log bj_logl
212 #define bj_max bj_maxl
213 #define bj_min bj_minl
214 #define bj_pow bj_powl
215 #define bj_round bj_roundl
216 #define bj_sin bj_sinl
217 #define bj_sqrt bj_sqrtl
218 #define bj_tan bj_tanl
219#elif defined(BJ_API_FLOAT64)
220 #define bj_abs bj_absd
221 #define bj_acos bj_acosd
222 #define bj_atan2 bj_atan2d
223 #define bj_copysign bj_copysignd
224 #define bj_cos bj_cosd
225 #define bj_exp bj_expd
226 #define bj_floor bj_floord
227 #define bj_fmod bj_fmodd
228 #define bj_log bj_logd
229 #define bj_max bj_maxd
230 #define bj_min bj_mind
231 #define bj_pow bj_powd
232 #define bj_round bj_roundd
233 #define bj_sin bj_sind
234 #define bj_sqrt bj_sqrtd
235 #define bj_tan bj_tand
237 #define bj_abs bj_absf
238 #define bj_acos bj_acosf
239 #define bj_atan2 bj_atan2f
240 #define bj_copysign bj_copysignf
241 #define bj_cos bj_cosf
242 #define bj_exp bj_expf
243 #define bj_floor bj_floorf
244 #define bj_fmod bj_fmodf
245 #define bj_log bj_logf
246 #define bj_max bj_maxf
247 #define bj_min bj_minf
248 #define bj_pow bj_powf
249 #define bj_round bj_roundf
250 #define bj_sin bj_sinf
251 #define bj_sqrt bj_sqrtf
252 #define bj_tan bj_tanf
271 return (x < lo) ? lo : (x > hi) ? hi : x;
292 bj_real t = (x - e0) / (e1 - e0);
294 return t * t * (
BJ_F(3.0) -
BJ_F(2.0) * t);
static int bj_real_gt_rel(bj_real a, bj_real b)
a > b by more than relative epsilon.
static int bj_real_lte_rel(bj_real a, bj_real b)
a <= b within relative epsilon.
static int bj_real_cmp_rel(bj_real a, bj_real b)
Three-way compare using relative epsilon.
static bj_real bj_smoothstep(bj_real e0, bj_real e1, bj_real x)
Smooth Hermite step between e0 and e1.
static bj_real bj_real_relative_scale(bj_real a, bj_real b)
Internal scale helper max(1, |a|, |b|).
static int bj_real_eq_rel(bj_real a, bj_real b)
Equality within relative epsilon.
static int bj_real_cmp(bj_real a, bj_real b)
Three-way compare using absolute epsilon.
static int bj_real_neq_rel(bj_real a, bj_real b)
Inequality within relative epsilon.
static int bj_real_gt(bj_real a, bj_real b)
a > b by more than absolute epsilon.
static bj_real bj_clamp(bj_real x, bj_real lo, bj_real hi)
Clamp x to the closed interval [lo, hi].
static bj_real bj_real_snorm_safe(bj_real x, bj_real len)
Safe scalar normalization.
static int bj_real_lt(bj_real a, bj_real b)
a < b by more than absolute epsilon.
#define BJ_FZERO
Zero constant in bj_real.
#define bj_abs
Absolute value.
static bj_real bj_fract(bj_real x)
Fractional part of x.
static int bj_real_is_zero(bj_real x)
Absolute-zero test.
static int bj_real_gte_rel(bj_real a, bj_real b)
a >= b within relative epsilon.
#define bj_fmod
Floating modulus.
static int bj_real_is_zero_scaled(bj_real x, bj_real scale)
Scaled zero test using max(1, |scale|).
static int bj_real_neq(bj_real a, bj_real b)
Inequality within absolute epsilon.
static bj_real bj_mod(bj_real x, bj_real y)
Positive modulus with non-negative result magnitude.
static bj_real bj_step(bj_real edge, bj_real x)
Step function.
static int bj_real_gte(bj_real a, bj_real b)
a >= b within absolute epsilon.
#define BJ_EPSILON
Machine epsilon for bj_real when float is selected.
static bj_real bj_real_snap_zero(bj_real x)
Snap to exact zero under absolute epsilon.
#define BJ_F(x)
Literal suffix helper for bj_real when float is selected.
static int bj_real_lt_rel(bj_real a, bj_real b)
a < b by more than relative epsilon.
static int bj_real_lte(bj_real a, bj_real b)
a <= b within absolute epsilon.
float bj_real
Selected real type for float configuration.
#define bj_max
Maximum of two floats.
static int bj_real_eq(bj_real a, bj_real b)
Equality within absolute epsilon.
C99 math shim with bj_real precision type and scalar utilities.