![]() |
SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
|


Go to the source code of this file.
Macros | |
| #define | SHZ_FLT_EPSILON |
Functions | |
Comparisons | |
Routines for comparing and classifying floating-point values. | |
| float | shz_fminf (float a, float b) SHZ_NOEXCEPT |
| float | shz_fmaxf (float a, float b) SHZ_NOEXCEPT |
| bool | shz_equalf (float a, float b) SHZ_NOEXCEPT |
| bool | shz_equalf_abs (float a, float b) SHZ_NOEXCEPT |
| bool | shz_equalf_rel (float a, float b) SHZ_NOEXCEPT |
Rounding | |
Routines for rounding and manipulating floats. | |
| float | shz_floorf (float x) SHZ_NOEXCEPT |
| float | shz_ceilf (float x) SHZ_NOEXCEPT |
| float | shz_roundf (float x) SHZ_NOEXCEPT |
| float | shz_truncf (float x) SHZ_NOEXCEPT |
| float | shz_remainderf (float num, float denom) SHZ_NOEXCEPT |
| float | shz_fmodf (float num, float denom) SHZ_NOEXCEPT |
| float | shz_remquof (float num, float denom, float *quot) SHZ_NOEXCEPT |
Mapping | |
Routines for mapping a number to another range. | |
| float | shz_clampf (float value, float min, float max) SHZ_NOEXCEPT |
| float | shz_normalizef (float current, float from, float to) SHZ_NOEXCEPT |
| float | shz_normalizef_fsrra (float current, float from, float to) SHZ_NOEXCEPT |
| float | shz_remapf (float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT |
| float | shz_remapf_fsrra (float value, float inputStart, float inputEnd, float outputStart, float outputEnd) SHZ_NOEXCEPT |
| float | shz_wrapf (float value, float min, float max) SHZ_NOEXCEPT |
| float | shz_wrapf_fsrra (float value, float min, float max) SHZ_NOEXCEPT |
| float | shz_fractf (float x) SHZ_NOEXCEPT |
| float | shz_signf (float x) SHZ_NOEXCEPT |
| float | shz_saturatef (float x) SHZ_NOEXCEPT |
Miscellaneous | |
Assorted routines implementing other fp operations. | |
| float | shz_fabsf (float x) SHZ_NOEXCEPT |
| float | shz_copysignf (float x, float y) SHZ_NOEXCEPT |
| float | shz_fmaf (float a, float b, float c) SHZ_NOEXCEPT |
| float | shz_fdimf (float x, float y) SHZ_NOEXCEPT |
| float | shz_hypotf (float x, float y) SHZ_NOEXCEPT |
| float | shz_cbrtf (float x) SHZ_NOEXCEPT |
| float | shz_lerpf (float a, float b, float t) SHZ_NOEXCEPT |
| float | shz_barycentric_lerpf (float a, float b, float c, float u, float v) SHZ_NOEXCEPT |
| bool | shz_quadratic_roots (float a, float b, float c, float *root1, float *root2) SHZ_NOEXCEPT |
| float | shz_randf (int *seed) SHZ_NOEXCEPT |
| float | shz_randf_range (int *seed, float min, float max) SHZ_NOEXCEPT |
| float | shz_stepf (float x, float edge) SHZ_NOEXCEPT |
| float | shz_smoothstepf (float x, float edge0, float edge1) SHZ_NOEXCEPT |
| float | shz_smoothstepf_safe (float x, float edge0, float edge1) SHZ_NOEXCEPT |
FSRRA | |
Routines built around fast reciprocal square root instruction. | |
| float | shz_inv_sqrtf_fsrra (float x) SHZ_NOEXCEPT |
| float | shz_inv_sqrtf (float x) SHZ_NOEXCEPT |
| float | shz_sqrtf_fsrra (float x) SHZ_NOEXCEPT |
| float | shz_sqrtf (float x) SHZ_NOEXCEPT |
| float | shz_invf_fsrra (float x) SHZ_NOEXCEPT |
| float | shz_invf (float x) SHZ_NOEXCEPT |
| float | shz_divf_fsrra (float num, float denom) SHZ_NOEXCEPT |
| float | shz_divf (float num, float denom) SHZ_NOEXCEPT |
FIPR | |
Routines built around fast 4D dot product.
| |
| float | shz_dot6f (float x1, float y1, float z1, float x2, float y2, float z2) SHZ_NOEXCEPT |
| float | shz_dot8f (float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2) SHZ_NOEXCEPT |
| float | shz_mag_sqr3f (float x, float y, float z) SHZ_NOEXCEPT |
| float | shz_mag_sqr4f (float x, float y, float z, float w) SHZ_NOEXCEPT |
Transcendental | |
Fast approximations for non-trig transcendental functions. | |
| float | shz_pow2f (float p) SHZ_NOEXCEPT |
| float | shz_powf (float x, float p) SHZ_NOEXCEPT |
| float | shz_pow10f (float x) SHZ_NOEXCEPT |
| float | shz_log2f (float x) SHZ_NOEXCEPT |
| float | shz_logf (float x) SHZ_NOEXCEPT |
| float | shz_log10f (float x) SHZ_NOEXCEPT |
| float | shz_expf (float p) SHZ_NOEXCEPT |
General-purpose scalar math routines.
This file provides a collection of general-purpose math routines for operating on floating-point scalar values.
Definition in file shz_scalar.h.
| #define SHZ_FLT_EPSILON |
Floating-point epsilon used with inexact FP-based comparisons.
Definition at line 40 of file shz_scalar.h.
| float shz_fminf | ( | float | a, |
| float | b ) |
Returns the minimum value of two given floats.
| float shz_fmaxf | ( | float | a, |
| float | b ) |
Returns the maximum value of two given floats.
| bool shz_equalf | ( | float | a, |
| float | b ) |
Checks for equality based on EITHER the absolute tolerance or relative tolerance, using SHZ_FLT_EPSILON.
| bool shz_equalf_abs | ( | float | a, |
| float | b ) |
Checks for equality based on the absolute tolerance using SHZ_FLT_EPSILON.
| bool shz_equalf_rel | ( | float | a, |
| float | b ) |
Checks for equality based on the relative tolerance using SHZ_FLT_EPSILON.
| float shz_floorf | ( | float | x | ) |
Replacement for the <math.h> routine, floorf().
Returns the closest integral value to x, rounded down, as a float.
x <= INT32_MAX.| float shz_ceilf | ( | float | x | ) |
Replacement for the <math.h> routine, ceilf().
Returns the closest integral value to x, rounded up, as a float.
x <= INT32_MAX.| float shz_roundf | ( | float | x | ) |
Replacement for the <math.h> routine, roundf().
Returns the value of x rounded to the nearest integer, as a float.
x <= UINT32_MAX. | float shz_truncf | ( | float | x | ) |
Replacement for the <math.h> routine, truncf().
Returns the value of with its fractional component discarded.
x <= INT32_MAX. | float shz_remainderf | ( | float | num, |
| float | denom ) |
Replacement for the <math.h> routine, remainderf().
Returns the floating-point remainder of num divided by denom, rounded to the nearest integer (as a float).
num / denom <= INT32_MAX.| float shz_fmodf | ( | float | num, |
| float | denom ) |
Replacement for the <math.h> routine, fmodf().
Returns the floating-point remainder of num divided by denom, rounded towards zero.
| float shz_remquof | ( | float | num, |
| float | denom, | ||
| float * | quot ) |
(Sorta) Replacement for the <math.h> routine, remquof().
Returns the floating-point remainder of num divided by denom, rounded to the nearest integer (as a float). quot is set equal to the quotient which is used as part of the calculation.
quot is returning as a float rather than an int as with standard C. Simply cast to an int manually afterwards if that is the desired behavior.| float shz_clampf | ( | float | value, |
| float | min, | ||
| float | max ) |
Clamps a floating-point value by the given min and max values.
| float shz_normalizef | ( | float | current, |
| float | from, | ||
| float | to ) |
Maps a value within the given range from to to, to be within the range of 0.0f += 1.0f.
| float shz_normalizef_fsrra | ( | float | current, |
| float | from, | ||
| float | to ) |
Maps a value within the given range from to to, to be within the range of 0.0f + 1.0f more quickly, provided to - from is a positive difference.
| float shz_remapf | ( | float | value, |
| float | inputStart, | ||
| float | inputEnd, | ||
| float | outputStart, | ||
| float | outputEnd ) |
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd.
| float shz_remapf_fsrra | ( | float | value, |
| float | inputStart, | ||
| float | inputEnd, | ||
| float | outputStart, | ||
| float | outputEnd ) |
Maps a value within the given range inputStart to inputEnd, to be within the range of outputStart to outputEnd more quickly, provided the outputEnd - outputStart is a positive difference.
| float shz_wrapf | ( | float | value, |
| float | min, | ||
| float | max ) |
Wraps the given value back to be within the range of min to max.
| float shz_wrapf_fsrra | ( | float | value, |
| float | min, | ||
| float | max ) |
Wraps the given value back to be within the range of min to max more quickly, provided max - min is a positive difference.
| float shz_fractf | ( | float | x | ) |
Returns the fractional part of x, equivalent to GLSL fract().
| float shz_signf | ( | float | x | ) |
Returns -1.0f if x < 0, 0.0f if x == 0, or 1.0f if x > 0.
| float shz_saturatef | ( | float | x | ) |
Clamps x to the range [0.0f, 1.0f].
| float shz_fabsf | ( | float | x | ) |
Replacement for the <math.h> routine, fabsf().
Returns the absolute value of x.
| float shz_copysignf | ( | float | x, |
| float | y ) |
Replacement for the <math.h> routine, copysignf().
Returns the value of x with the sign of y.
| float shz_fmaf | ( | float | a, |
| float | b, | ||
| float | c ) |
Replacement for the <math.h> routine, fmaf().
Returns a * b + c, performing an FP multiply + accumulate operation.
| float shz_fdimf | ( | float | x, |
| float | y ) |
Replacement for the <math.h> routine, fdimf(),.
Returns the positive difference between x and y or zero if y >= x.
| float shz_hypotf | ( | float | x, |
| float | y ) |
Replacement for the <math.h> routine, hypotf().
Returns the hypoteneuse of the right triangle with the given legs.
| float shz_cbrtf | ( | float | x | ) |
Replacement for the <math.h> routine, cbrtf().
Returns the cubed root of x, using a fast approximation.
| float shz_lerpf | ( | float | a, |
| float | b, | ||
| float | t ) |
Returns a value that is linearly interpolated between a and b by the given ratio, t.
| float shz_barycentric_lerpf | ( | float | a, |
| float | b, | ||
| float | c, | ||
| float | u, | ||
| float | v ) |
Returns a value that is barycentrically interpolated between a, b, and c using the given barycentric coordinates, u and v.
| bool shz_quadratic_roots | ( | float | a, |
| float | b, | ||
| float | c, | ||
| float * | root1, | ||
| float * | root2 ) |
Uses the quadratic formula with the given coefficients to solve for the two roots, returning true if any real roots exist, and false if the roots are only imaginary.
| float shz_randf | ( | int * | seed | ) |
Returns a random floating-point number between 0.0f and 1.0f, using and updating the given seed.
| float shz_randf_range | ( | int * | seed, |
| float | min, | ||
| float | max ) |
Returns a random floating-point number between min and max, using and updating the given seed.
| float shz_stepf | ( | float | x, |
| float | edge ) |
returns 0.0f if x < edge, otherwise 1.0f
| float shz_smoothstepf | ( | float | x, |
| float | edge0, | ||
| float | edge1 ) |
Returns 0.0f at/below edge0, 1.0f at/above edge1, smoothly varying in-between. edge0 must be less than edge1 or result is undefined.
| float shz_smoothstepf_safe | ( | float | x, |
| float | edge0, | ||
| float | edge1 ) |
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 | ) |
Calculates 1.0f/sqrtf( x), using a fast approximation.
| float shz_inv_sqrtf | ( | float | x | ) |
Calculates 1.0f/sqrtf( x ), using a fast approximation, while safely protecting against division-by-zero.
| float shz_sqrtf_fsrra | ( | float | x | ) |
Returns the fast approximate square root of the given value, x.
| float shz_sqrtf | ( | float | x | ) |
Returns the fast approximate square root of the given value, x, safely returning 0.0f is x == 0.0f.
| float shz_invf_fsrra | ( | float | x | ) |
Takes the inverse of x using a very fast approximation, returning a positive result.
| float shz_invf | ( | float | x | ) |
Takes the inverse of x using a slighty faster approximation than doing a full division, safely handling negative values.
| float shz_divf_fsrra | ( | float | num, |
| float | denom ) |
Divides num by denom using a very fast approximation, which requires denom be a positive value.
| float shz_divf | ( | float | num, |
| float | denom ) |
Divides num by denom using a slightly faster approximation, allowing denom to be negative.
| float shz_dot6f | ( | float | x1, |
| float | y1, | ||
| float | z1, | ||
| float | x2, | ||
| float | y2, | ||
| float | z2 ) |
Takes two sets of 3D vectors as 3 floats and calculates their dot product using an approximation.
| float shz_dot8f | ( | float | x1, |
| float | y1, | ||
| float | z1, | ||
| float | w1, | ||
| float | x2, | ||
| float | y2, | ||
| float | z2, | ||
| float | w2 ) |
Takes two sets of 4D vectors as 4 floats and calculates their dot product using an approximation.
| float shz_mag_sqr3f | ( | float | x, |
| float | y, | ||
| float | z ) |
Takes a 3D vector as 3 floats and calculates its squared magnitude using a fast approximation.
| float shz_mag_sqr4f | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | w ) |
Takes a 4D vector as 4 floats and calculates its squared magnitude using a fast approximation.
| float shz_pow2f | ( | float | p | ) |
Fast approximation for raising 2 to a floating-point power.
| float shz_powf | ( | float | x, |
| float | p ) |
Fast approximation for C's powf().
| float shz_pow10f | ( | float | x | ) |
Fast approximation of POSIX's pow10f().
| float shz_log2f | ( | float | x | ) |
Fast approximation for C's log2f().
| float shz_logf | ( | float | x | ) |
Fast approximation for C's logf().
| float shz_log10f | ( | float | x | ) |
Fast approximation for C's log10f().
| float shz_expf | ( | float | p | ) |
Fast approximation for C's expf().