hal_gfx_math.h File Reference

Go to the source code of this file.

Macros

#define HAL_GFX_E   2.71828182845904523536f
 
#define HAL_GFX_LOG2E   1.44269504088896340736f
 
#define HAL_GFX_LOG10E   0.434294481903251827651f
 
#define HAL_GFX_LN2   0.693147180559945309417f
 
#define HAL_GFX_LN10   2.30258509299404568402f
 
#define HAL_GFX_PI   3.14159265358979323846f
 
#define HAL_GFX_PI_2   1.57079632679489661923f
 
#define HAL_GFX_PI_4   0.785398163397448309616f
 
#define HAL_GFX_1_PI   0.318309886183790671538f
 
#define HAL_GFX_2_PI   0.636619772367581343076f
 
#define HAL_GFX_2_SQRTPI   1.12837916709551257390f
 
#define HAL_GFX_SQRT2   1.41421356237309504880f
 
#define HAL_GFX_SQRT1_2   0.707106781186547524401f
 
#define hal_gfx_min2(a, b)   (((a)<(b))?( a):(b))
 
#define hal_gfx_max2(a, b)   (((a)>(b))?( a):(b))
 
#define hal_gfx_clamp(val, min, max)   hal_gfx_min2((max), hal_gfx_max2((min), (val)))
 
#define hal_gfx_abs(a)   (((a)< 0 )?(-(a)):(a))
 
#define hal_gfx_absf(a)   (((a)< 0.f )?(-(a)):(a))
 
#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)))
 
#define hal_gfx_float_is_zero(x)   (hal_gfx_absf(x) <= 0.00001f)
 
#define hal_gfx_deg_to_rad(d)   (0.0174532925199f * (d))
 
#define hal_gfx_rad_to_deg(r)   (57.295779513f * (r))
 
#define hal_gfx_i2fx(a)   ((a)*0x10000)
 
#define hal_gfx_floor(f)   ((int)(f) - ( (int)(f) > (f) ))
 
#define hal_gfx_ceil(f)   ((int)(f) + ( (int)(f) < (f) ))
 

Functions

float hal_gfx_sin (float angle_degrees)
 Fast sine approximation of a given angle. More...
 
float hal_gfx_cos (float angle_degrees)
 Fast cosine approximation of a given angle. More...
 
float hal_gfx_tan (float angle_degrees)
 Fast tangent approximation of a given angle. More...
 
float hal_gfx_pow (float x, float y)
 A rough approximation of x raised to the power of y. USE WITH CAUTION! More...
 
float hal_gfx_sqrt (float x)
 A rough approximation of the square root of x. USE WITH CAUTION! More...
 
float hal_gfx_atan (float x)
 A floating-point approximation of the inverse tangent of x. More...
 
int hal_gfx_f2fx (float f)
 Convert float to 16.16 fixed point. More...