utils / helpersΒΆ
Header: cglm/util.h
Table of contents (click to go):ΒΆ
Functions:
Functions documentationΒΆ
-
int
glm_sign
(int val)ΒΆ - returns sign of 32 bit integer as +1, -1, 0Important: It returns 0 for zero input
- Parameters:
- [in] val an integer
- Returns:
- sign of given number
-
float
glm_signf
(float val)ΒΆ - returns sign of 32 bit integer as +1.0, -1.0, 0.0Important: It returns 0.0f for zero input
- Parameters:
- [in] val a float
- Returns:
- sign of given number
-
float
glm_rad
(float deg)ΒΆ - convert degree to radians
- Parameters:
- [in] deg angle in degrees
-
float
glm_deg
(float rad)ΒΆ - convert radians to degree
- Parameters:
- [in] rad angle in radians
-
void
glm_make_rad
(float *degm)ΒΆ - convert exsisting degree to radians. this will override degrees value
- Parameters:
- [in, out] deg pointer to angle in degrees
-
void
glm_make_deg
(float *rad)ΒΆ - convert exsisting radians to degree. this will override radians value
- Parameters:
- [in, out] rad pointer to angle in radians
-
float
glm_pow2
(float x)ΒΆ - multiplies given parameter with itself = x * x or powf(x, 2)
- Parameters:
- [in] x value
- Returns:
- square of a given number
-
float
glm_min
(float a, float b)ΒΆ - returns minimum of given two values
- Parameters:
- [in] a number 1[in] b number 2
- Returns:
- minimum value
-
float
glm_max
(float a, float b)ΒΆ - returns maximum of given two values
- Parameters:
- [in] a number 1[in] b number 2
- Returns:
- maximum value
-
void
glm_clamp
(float val, float minVal, float maxVal)ΒΆ constrain a value to lie between two further values
- Parameters:
- [in] val input value[in] minVal minimum value[in] maxVal maximum value
- Returns:
- clamped value
-
float
glm_lerp
(float from, float to, float t)ΒΆ linear interpolation between two number
formula: from + s * (to - from)- Parameters:
- [in] from from value[in] to to value[in] t interpolant (amount) clamped between 0 and 1
- Returns:
- interpolated value
-
bool
glm_eq
(float a, float b)ΒΆ check if two float equal with using EPSILON
- Parameters:
- [in] a a[in] b b
- Returns:
- true if a and b are equal
-
float
glm_percent
(float from, float to, float current)ΒΆ percentage of current value between start and end value
- Parameters:
- [in] from from value[in] to to value[in] current value between from and to values
- Returns:
- percentage of current value
-
float
glm_percentc
(float from, float to, float current)ΒΆ clamped percentage of current value between start and end value
- Parameters:
- [in] from from value[in] to to value[in] current value between from and to values
- Returns:
- clamped normalized percent (0-100 in 0-1)
-
void
glm_swapf
(float *a, float *b)ΒΆ swap two float values
- Parameters:
- [in] a float 1[in] b float 2