Go to the documentation of this file.
12 #ifndef HAL_GFX_MATH_H__
13 #define HAL_GFX_MATH_H__
23 #define HAL_GFX_E 2.71828182845904523536f
24 #define HAL_GFX_LOG2E 1.44269504088896340736f
25 #define HAL_GFX_LOG10E 0.434294481903251827651f
26 #define HAL_GFX_LN2 0.693147180559945309417f
27 #define HAL_GFX_LN10 2.30258509299404568402f
28 #define HAL_GFX_PI 3.14159265358979323846f
29 #define HAL_GFX_PI_2 1.57079632679489661923f
30 #define HAL_GFX_PI_4 0.785398163397448309616f
31 #define HAL_GFX_1_PI 0.318309886183790671538f
32 #define HAL_GFX_2_PI 0.636619772367581343076f
33 #define HAL_GFX_2_SQRTPI 1.12837916709551257390f
34 #define HAL_GFX_SQRT2 1.41421356237309504880f
35 #define HAL_GFX_SQRT1_2 0.707106781186547524401f
37 #define hal_gfx_min2(a,b) (((a)<(b))?( a):(b))
38 #define hal_gfx_max2(a,b) (((a)>(b))?( a):(b))
39 #define hal_gfx_clamp(val, min, max) hal_gfx_min2((max), hal_gfx_max2((min), (val)))
40 #define hal_gfx_abs(a) (((a)< 0 )?(-(a)):(a))
41 #define hal_gfx_absf(a) (((a)< 0.f )?(-(a)):(a))
42 #define hal_gfx_floats_equal(x, y) (hal_gfx_absf((x) - (y)) <= 0.00001f * hal_gfx_min2(hal_gfx_absf(x), hal_gfx_absf(y)))
43 #define hal_gfx_float_is_zero(x) (hal_gfx_absf(x) <= 0.00001f)
44 #define hal_gfx_deg_to_rad(d) (0.0174532925199f * (d))
45 #define hal_gfx_rad_to_deg(r) (57.295779513f * (r))
46 #define hal_gfx_i2fx(a) ((a)*0x10000)
47 #define hal_gfx_floor(f) ((int)(f) - ( (int)(f) > (f) ))
48 #define hal_gfx_ceil(f) ((int)(f) + ( (int)(f) < (f) ))
float hal_gfx_cos(float angle_degrees)
Fast cosine approximation of a given angle.
float hal_gfx_sqrt(float x)
A rough approximation of the square root of x. USE WITH CAUTION!
float hal_gfx_tan(float angle_degrees)
Fast tangent approximation of a given angle.
float hal_gfx_atan(float x)
A floating-point approximation of the inverse tangent of x.
float hal_gfx_sin(float angle_degrees)
Fast sine approximation of a given angle.
int hal_gfx_f2fx(float f)
Convert float to 16.16 fixed point.
float hal_gfx_pow(float x, float y)
A rough approximation of x raised to the power of y. USE WITH CAUTION!