hal_gfx_math.h File Reference

Header file containing functions prototypes of Graphics library. More...

Go to the source code of this file.

Macros

#define HAL_GFX_E   2.71828182845904523536f
 e More...
 
#define HAL_GFX_LOG2E   1.44269504088896340736f
 log2(e) More...
 
#define HAL_GFX_LOG10E   0.434294481903251827651f
 log10(e) More...
 
#define HAL_GFX_LN2   0.693147180559945309417f
 ln(2) More...
 
#define HAL_GFX_LN10   2.30258509299404568402f
 ln(10) More...
 
#define HAL_GFX_PI   3.14159265358979323846f
 pi More...
 
#define HAL_GFX_PI_2   1.57079632679489661923f
 pi/2 More...
 
#define HAL_GFX_PI_4   0.785398163397448309616f
 pi/4 More...
 
#define HAL_GFX_1_PI   0.318309886183790671538f
 1/pi More...
 
#define HAL_GFX_2_PI   0.636619772367581343076f
 2/pi More...
 
#define HAL_GFX_2_SQRTPI   1.12837916709551257390f
 2/sqrt(pi) More...
 
#define HAL_GFX_SQRT2   1.41421356237309504880f
 sqrt(2) More...
 
#define HAL_GFX_SQRT1_2   0.707106781186547524401f
 1/sqrt(2) More...
 
#define hal_gfx_min2(a, b)   (((a)<(b))?( a):(b))
 Find the minimum of two values. More...
 
#define hal_gfx_max2(a, b)   (((a)>(b))?( a):(b))
 Find the maximum of two values. More...
 
#define hal_gfx_clamp(val, min, max)   hal_gfx_min2((max), hal_gfx_max2((min), (val)))
 Clamp value. More...
 
#define hal_gfx_abs(a)   (((a)< 0 )?(-(a)):(a))
 Calculate the absolute value of int. More...
 
#define hal_gfx_absf(a)   (((a)< 0.f )?(-(a)):(a))
 Calculate the absolute value of float. More...
 
#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)))
 Compare two floats. More...
 
#define hal_gfx_float_is_zero(x)   (hal_gfx_absf(x) <= 0.00001f)
 Checks if value x is zero. More...
 
#define hal_gfx_deg_to_rad(d)   (0.0174532925199f * (d))
 Convert degrees to radians. More...
 
#define hal_gfx_rad_to_deg(r)   (57.295779513f * (r))
 onvert radians to degries. More...
 
#define hal_gfx_i2fx(a)   ((a)*0x10000)
 Convert integer to 16.16 fixed point. More...
 
#define hal_gfx_floor(f)   ((int)(f) - ( (int)(f) > (f) ))
 Floor function. More...
 
#define hal_gfx_ceil(f)   ((int)(f) + ( (int)(f) < (f) ))
 Ceiling function. More...
 

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. More...
 
float hal_gfx_sqrt (float x)
 A rough approximation of the square root of x. 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...
 

Detailed Description

Header file containing functions prototypes of Graphics library.

Author
BLE Driver Team
Attention
Copyright (c) 2019 GOODIX

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file hal_gfx_math.h.