2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
28
29
30
31
32
33
34
35
36
37
40#define SHZ_FLT_EPSILON 0.000001f
45
46
47
50SHZ_FORCE_INLINE
float shz_fminf(
float a,
float b) SHZ_NOEXCEPT;
53SHZ_FORCE_INLINE
float shz_fmaxf(
float a,
float b) SHZ_NOEXCEPT;
56SHZ_FORCE_INLINE
bool shz_equalf(
float a,
float b) SHZ_NOEXCEPT;
67
68
69
72
73
74
75
76
77
78
79
83
84
85
86
87
88
89
90
91
92SHZ_FORCE_INLINE
float shz_ceilf(
float x) SHZ_NOEXCEPT;
95
96
97
98
99
100
101
105
106
107
108
109
110
111
115
116
117
118
119
120
121
122
123
124
128
129
130
131
132
133
134
135
136
137SHZ_FORCE_INLINE
float shz_fmodf(
float num,
float denom) SHZ_NOEXCEPT;
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154SHZ_FORCE_INLINE
float shz_remquof(
float num,
float denom,
float* quot) SHZ_NOEXCEPT;
159
160
161
164SHZ_FORCE_INLINE
float shz_clampf(
float value,
float min,
float max) SHZ_NOEXCEPT;
167SHZ_FORCE_INLINE
float shz_normalizef(
float current,
float from,
float to) SHZ_NOEXCEPT;
173SHZ_FORCE_INLINE
float shz_remapf(
float value,
float inputStart,
float inputEnd,
float outputStart,
float outputEnd) SHZ_NOEXCEPT;
176SHZ_FORCE_INLINE
float shz_remapf_fsrra(
float value,
float inputStart,
float inputEnd,
float outputStart,
float outputEnd) SHZ_NOEXCEPT;
179SHZ_FORCE_INLINE
float shz_wrapf(
float value,
float min,
float max) SHZ_NOEXCEPT;
182SHZ_FORCE_INLINE
float shz_wrapf_fsrra(
float value,
float min,
float max) SHZ_NOEXCEPT;
197
198
199
202
203
204
208
209
210
214
215
216
217SHZ_FORCE_INLINE
float shz_fmaf(
float a,
float b,
float c) SHZ_NOEXCEPT;
220
221
222
223
224
225
226
227SHZ_FORCE_INLINE
float shz_fdimf(
float x,
float y) SHZ_NOEXCEPT;
230
231
232
233
234
235
236SHZ_FORCE_INLINE
float shz_hypotf(
float x,
float y) SHZ_NOEXCEPT;
239
240
241
245SHZ_FORCE_INLINE
float shz_lerpf(
float a,
float b,
float t) SHZ_NOEXCEPT;
251SHZ_FORCE_INLINE
bool shz_quadratic_roots(
float a,
float b,
float c,
float* root1,
float* root2) SHZ_NOEXCEPT;
254SHZ_FORCE_INLINE
float shz_randf(
int* seed) SHZ_NOEXCEPT;
260SHZ_FORCE_INLINE
float shz_stepf(
float x,
float edge) SHZ_NOEXCEPT;
263SHZ_FORCE_INLINE
float shz_smoothstepf(
float x,
float edge0,
float edge1) SHZ_NOEXCEPT;
271
272
273
291SHZ_FORCE_INLINE
float shz_invf(
float x) SHZ_NOEXCEPT;
297SHZ_FORCE_INLINE
float shz_divf(
float num,
float denom) SHZ_NOEXCEPT;
302
303
304
305
308SHZ_FORCE_INLINE
float shz_dot6f(
float x1,
float y1,
float z1,
309 float x2,
float y2,
float z2) SHZ_NOEXCEPT;
312SHZ_FORCE_INLINE
float shz_dot8f(
float x1,
float y1,
float z1,
float w1,
313 float x2,
float y2,
float z2,
float w2) SHZ_NOEXCEPT;
316SHZ_FORCE_INLINE
float shz_mag_sqr3f(
float x,
float y,
float z) SHZ_NOEXCEPT;
319SHZ_FORCE_INLINE
float shz_mag_sqr4f(
float x,
float y,
float z,
float w) SHZ_NOEXCEPT;
324
325
326
332SHZ_FORCE_INLINE
float shz_powf(
float x,
float p) SHZ_NOEXCEPT;
341SHZ_FORCE_INLINE
float shz_logf(
float x) SHZ_NOEXCEPT;
347SHZ_FORCE_INLINE
float shz_expf(
float p) SHZ_NOEXCEPT;
351#include "inline/shz_scalar.inl.h"
float shz_mag_sqr3f(float x, float y, float z) SHZ_NOEXCEPT
Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation.
float shz_powf(float x, float p) SHZ_NOEXCEPT
Fast approximation for C's powf().
bool shz_equalf_abs(float a, float b) SHZ_NOEXCEPT
Checks for equality based on the absolute tolerance using SHZ_FLT_EPSILON.
float shz_remquof(float num, float denom, float *quot) SHZ_NOEXCEPT
(Sorta) Replacement for the <math.h> routine, remquof().
float shz_expf(float p) SHZ_NOEXCEPT
Fast approximation for C's expf().
float shz_normalizef_fsrra(float current, float from, float to) SHZ_NOEXCEPT
Maps a value within the given range from to to, to be within the range of 0.0f + 1....
float shz_randf(int *seed) SHZ_NOEXCEPT
Returns a random floating-point number between 0.0f and 1.0f, using and updating the given seed.
float shz_log10f(float x) SHZ_NOEXCEPT
Fast approximation for C's log10f().
float shz_floorf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, floorf().
float shz_wrapf_fsrra(float value, float min, float max) SHZ_NOEXCEPT
Wraps the given value back to be within the range of min to max more quickly, provided max - min is a...
float shz_normalizef(float current, float from, float to) SHZ_NOEXCEPT
Maps a value within the given range from to to, to be within the range of 0.0f += 1....
float shz_log2f(float x) SHZ_NOEXCEPT
Fast approximation for C's log2f().
float shz_mag_sqr4f(float x, float y, float z, float w) SHZ_NOEXCEPT
Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation.
float shz_smoothstepf(float x, float edge0, float edge1) SHZ_NOEXCEPT
Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less tha...
float shz_dot8f(float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2) SHZ_NOEXCEPT
Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation.
float shz_fmaxf(float a, float b) SHZ_NOEXCEPT
Returns the maximum value of two given floats.
float shz_signf(float x) SHZ_NOEXCEPT
Returns -1.0f if x < 0, 0.0f if x == 0, or 1.0f if x > 0.
float shz_fdimf(float x, float y) SHZ_NOEXCEPT
Replacement for the <math.h> routine, fdimf(),.
float shz_sqrtf_fsrra(float x) SHZ_NOEXCEPT
Returns the fast approximate square root of the given value, x.
float shz_pow10f(float x) SHZ_NOEXCEPT
Fast approximation of POSIX's pow10f().
bool shz_quadratic_roots(float a, float b, float c, float *root1, float *root2) SHZ_NOEXCEPT
Uses the quadratic formula with the given coefficients to solve for the two roots,...
float shz_dot6f(float x1, float y1, float z1, float x2, float y2, float z2) SHZ_NOEXCEPT
Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation.
float shz_ceilf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, ceilf().
float shz_remapf_fsrra(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to ...
float shz_hypotf(float x, float y) SHZ_NOEXCEPT
Replacement for the <math.h> routine, hypotf().
float shz_copysignf(float x, float y) SHZ_NOEXCEPT
Replacement for the <math.h> routine, copysignf().
float shz_invf(float x) SHZ_NOEXCEPT
Takes the inverse of x using a slighty faster approximation than doing a full division,...
float shz_wrapf(float value, float min, float max) SHZ_NOEXCEPT
Wraps the given value back to be within the range of min to max.
float shz_saturatef(float x) SHZ_NOEXCEPT
Clamps x to the range [0.0f, 1.0f].
float shz_truncf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, truncf().
float shz_invf_fsrra(float x) SHZ_NOEXCEPT
Takes the inverse of x using a very fast approximation, returning a positive result.
float shz_sqrtf(float x) SHZ_NOEXCEPT
Returns the fast approximate square root of the given value, x, safely returning 0....
float shz_fmaf(float a, float b, float c) SHZ_NOEXCEPT
Replacement for the <math.h> routine, fmaf().
float shz_barycentric_lerpf(float a, float b, float c, float u, float v) SHZ_NOEXCEPT
Returns a value that is barycentrically interpolated between a, b, and c using the given barycentric ...
bool shz_equalf(float a, float b) SHZ_NOEXCEPT
Checks for equality based on EITHER the absolute tolerance or relative tolerance, using SHZ_FLT_EPSIL...
float shz_smoothstepf_safe(float x, float edge0, float edge1) SHZ_NOEXCEPT
Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. Accepts inverse edges.
float shz_inv_sqrtf_fsrra(float x) SHZ_NOEXCEPT
Calculates 1.0f/sqrtf( x), using a fast approximation.
float shz_cbrtf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, cbrtf().
bool shz_equalf_rel(float a, float b) SHZ_NOEXCEPT
Checks for equality based on the relative tolerance using SHZ_FLT_EPSILON.
float shz_fractf(float x) SHZ_NOEXCEPT
Returns the fractional part of x, equivalent to GLSL fract().
float shz_fmodf(float num, float denom) SHZ_NOEXCEPT
Replacement for the <math.h> routine, fmodf().
float shz_lerpf(float a, float b, float t) SHZ_NOEXCEPT
Returns a value that is linearly interpolated between a and b by the given ratio, t.
float shz_remainderf(float num, float denom) SHZ_NOEXCEPT
Replacement for the <math.h> routine, remainderf().
float shz_divf_fsrra(float num, float denom) SHZ_NOEXCEPT
Divides num by denom using a very fast approximation, which requires denom be a positive value.
float shz_divf(float num, float denom) SHZ_NOEXCEPT
Divides num by denom using a slightly faster approximation, allowing denom to be negative.
float shz_fminf(float a, float b) SHZ_NOEXCEPT
Returns the minimum value of two given floats.
float shz_inv_sqrtf(float x) SHZ_NOEXCEPT
Calculates 1.0f/sqrtf( x ), using a fast approximation, while safely protecting against division-by-z...
float shz_randf_range(int *seed, float min, float max) SHZ_NOEXCEPT
Returns a random floating-point number between min and max, using and updating the given seed.
float shz_clampf(float value, float min, float max) SHZ_NOEXCEPT
Clamps a floating-point value by the given min and max values.
float shz_roundf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, roundf().
float shz_fabsf(float x) SHZ_NOEXCEPT
Replacement for the <math.h> routine, fabsf().
float shz_logf(float x) SHZ_NOEXCEPT
Fast approximation for C's logf().
float shz_remapf(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to ...
float shz_stepf(float x, float edge) SHZ_NOEXCEPT
returns 0.0f if x < edge, otherwise 1.0f
float shz_pow2f(float p) SHZ_NOEXCEPT
Fast approximation for raising 2 to a floating-point power.