Go to the documentation of this file.
51 #ifndef HAL_GFX_MATH_H__
52 #define HAL_GFX_MATH_H__
62 #define HAL_GFX_E 2.71828182845904523536f
63 #define HAL_GFX_LOG2E 1.44269504088896340736f
64 #define HAL_GFX_LOG10E 0.434294481903251827651f
65 #define HAL_GFX_LN2 0.693147180559945309417f
66 #define HAL_GFX_LN10 2.30258509299404568402f
67 #define HAL_GFX_PI 3.14159265358979323846f
68 #define HAL_GFX_PI_2 1.57079632679489661923f
69 #define HAL_GFX_PI_4 0.785398163397448309616f
70 #define HAL_GFX_1_PI 0.318309886183790671538f
71 #define HAL_GFX_2_PI 0.636619772367581343076f
72 #define HAL_GFX_2_SQRTPI 1.12837916709551257390f
73 #define HAL_GFX_SQRT2 1.41421356237309504880f
74 #define HAL_GFX_SQRT1_2 0.707106781186547524401f
76 #define hal_gfx_min2(a,b) (((a)<(b))?( a):(b))
77 #define hal_gfx_max2(a,b) (((a)>(b))?( a):(b))
78 #define hal_gfx_clamp(val, min, max) hal_gfx_min2((max), hal_gfx_max2((min), (val)))
79 #define hal_gfx_abs(a) (((a)< 0 )?(-(a)):(a))
80 #define hal_gfx_absf(a) (((a)< 0.f )?(-(a)):(a))
81 #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)))
82 #define hal_gfx_float_is_zero(x) (hal_gfx_absf(x) <= 0.00001f)
83 #define hal_gfx_deg_to_rad(d) (0.0174532925199f * (d))
84 #define hal_gfx_rad_to_deg(r) (57.295779513f * (r))
85 #define hal_gfx_i2fx(a) ((a)*0x10000)
86 #define hal_gfx_floor(f) ((int)(f) - ( (int)(f) > (f) ))
87 #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.
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.