diff options
Diffstat (limited to 'include/bh/math.h')
| -rw-r--r-- | include/bh/math.h | 1295 |
1 files changed, 544 insertions, 751 deletions
diff --git a/include/bh/math.h b/include/bh/math.h index 3d3a53d..25aef35 100644 --- a/include/bh/math.h +++ b/include/bh/math.h @@ -103,7 +103,7 @@ typedef struct bh_point4i_s /** * 3x3 floating point matrix. - * + * * Each vector represent one column of the matrix. */ typedef struct bh_matrix3f_s @@ -121,7 +121,7 @@ typedef struct bh_matrix3f_s /** * 4x4 floating point matrix. - * + * * Each vector represent one column of the matrix. */ typedef struct bh_matrix4f_s @@ -154,6 +154,19 @@ typedef struct bh_line2f_s /** + * 3D floating point line. + */ +typedef struct bh_line3f_s +{ + /** Origin */ + bh_point3f_t origin; + + /** Normal vector */ + bh_point3f_t normal; +} bh_line3f_t; + + +/** * 3D floating point plane. */ typedef struct bh_plane3f_s @@ -182,15 +195,7 @@ typedef struct bh_ray2f_s /** * 3D floating point ray. */ -typedef struct bh_ray3f_s -{ - /** Origin */ - bh_point3f_t origin; - - /** Normal or direction */ - bh_point3f_t normal; -} bh_ray3f_t; - +typedef bh_line3f_t bh_ray3f_t; /** * 2D floating point AABB @@ -252,106 +257,94 @@ typedef bh_point4f_t bh_quat_t; /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_add(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_add(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_sub(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_sub(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_mul(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_mul(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_scale(const bh_point4f_t *a, - float b, - bh_point4f_t *result); +void bh_point4f_scale(const bh_point4f_t *a, + float b, + bh_point4f_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_madd(const bh_point4f_t *a, - const bh_point4f_t *b, - const bh_point4f_t *c, - bh_point4f_t *result); +void bh_point4f_madd(const bh_point4f_t *a, + const bh_point4f_t *b, + const bh_point4f_t *c, + bh_point4f_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_negate(const bh_point4f_t *in, - bh_point4f_t *result); +void bh_point4f_negate(const bh_point4f_t *in, + bh_point4f_t *result); /** * Calculates the dot product of two vectors. - * + * * \param a Value * \param b Value - * + * * \return Returns the dot product. */ float bh_point4f_dot(const bh_point4f_t *a, @@ -360,10 +353,10 @@ float bh_point4f_dot(const bh_point4f_t *a, /** * Calculates the dot product of two vectors with w component. - * + * * \param a Value * \param b Value - * + * * \return Returns the dot product. */ float bh_point4f_dot3(const bh_point4f_t *a, @@ -371,26 +364,24 @@ float bh_point4f_dot3(const bh_point4f_t *a, /** - * Calculates the cross product of two vectors without w component. - * + * Calculates the cross product of two vectors without w component. + * * result = a x b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_cross(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_cross(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Calculates the length of the vector. - * + * * \param in Value - * + * * \return Returns the length. */ float bh_point4f_length(const bh_point4f_t *in); @@ -398,186 +389,164 @@ float bh_point4f_length(const bh_point4f_t *in); /** * Normilizes the vector. - * + * * result = in / |in| - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_normal(const bh_point4f_t *in, - bh_point4f_t *result); +void bh_point4f_normal(const bh_point4f_t *in, + bh_point4f_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_min(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_min(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_max(const bh_point4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_point4f_max(const bh_point4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_lerp(const bh_point4f_t *a, - const bh_point4f_t *b, - float t, - bh_point4f_t *result); +void bh_point4f_lerp(const bh_point4f_t *a, + const bh_point4f_t *b, + float t, + bh_point4f_t *result); /** * Calculates spherical linear interpolation between two vectors. - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_point4f_slerp(const bh_point4f_t *a, - const bh_point4f_t *b, - float t, - bh_point4f_t *result); +void bh_point4f_slerp(const bh_point4f_t *a, + const bh_point4f_t *b, + float t, + bh_point4f_t *result); /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_add(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_add(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_sub(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_sub(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_mul(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_mul(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_scale(const bh_point3f_t *a, - float b, - bh_point3f_t *result); +void bh_point3f_scale(const bh_point3f_t *a, + float b, + bh_point3f_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_madd(const bh_point3f_t *a, - const bh_point3f_t *b, - const bh_point3f_t *c, - bh_point3f_t *result); +void bh_point3f_madd(const bh_point3f_t *a, + const bh_point3f_t *b, + const bh_point3f_t *c, + bh_point3f_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_negate(const bh_point3f_t *in, - bh_point3f_t *result); +void bh_point3f_negate(const bh_point3f_t *in, + bh_point3f_t *result); /** * Calculates the dot product of two vectors. - * + * * \param a Value * \param b Value - * + * * \return Returns the dot product. */ float bh_point3f_dot(const bh_point3f_t *a, @@ -585,26 +554,24 @@ float bh_point3f_dot(const bh_point3f_t *a, /** - * Calculates the cross product of two vectors. - * + * Calculates the cross product of two vectors. + * * result = a x b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_cross(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_cross(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Calculates the length of the vector. - * + * * \param in Value - * + * * \return Returns the length. */ float bh_point3f_length(const bh_point3f_t *in); @@ -612,186 +579,164 @@ float bh_point3f_length(const bh_point3f_t *in); /** * Normilizes the vector. - * + * * result = in / |in| - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_normal(const bh_point3f_t *in, - bh_point3f_t *result); +void bh_point3f_normal(const bh_point3f_t *in, + bh_point3f_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_min(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_min(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_max(const bh_point3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_point3f_max(const bh_point3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_lerp(const bh_point3f_t *a, - const bh_point3f_t *b, - float t, - bh_point3f_t *result); +void bh_point3f_lerp(const bh_point3f_t *a, + const bh_point3f_t *b, + float t, + bh_point3f_t *result); /** * Calculates spherical linear interpolation between two vectors. - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_point3f_slerp(const bh_point3f_t *a, - const bh_point3f_t *b, - float t, - bh_point3f_t *result); +void bh_point3f_slerp(const bh_point3f_t *a, + const bh_point3f_t *b, + float t, + bh_point3f_t *result); /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_add(const bh_point2f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_point2f_add(const bh_point2f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_sub(const bh_point2f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_point2f_sub(const bh_point2f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_mul(const bh_point2f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_point2f_mul(const bh_point2f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_scale(const bh_point2f_t *a, - float b, - bh_point2f_t *result); +void bh_point2f_scale(const bh_point2f_t *a, + float b, + bh_point2f_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_madd(const bh_point2f_t *a, - const bh_point2f_t *b, - const bh_point2f_t *c, - bh_point2f_t *result); +void bh_point2f_madd(const bh_point2f_t *a, + const bh_point2f_t *b, + const bh_point2f_t *c, + bh_point2f_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_negate(const bh_point2f_t *in, - bh_point2f_t *result); +void bh_point2f_negate(const bh_point2f_t *in, + bh_point2f_t *result); /** * Calculates the dot product of two vectors. - * + * * \param a Value * \param b Value - * + * * \return Returns the dot product. */ float bh_point2f_dot(const bh_point2f_t *a, @@ -799,13 +744,13 @@ float bh_point2f_dot(const bh_point2f_t *a, /** - * Calculates the cross product of two vectors and returns its z component. - * + * Calculates the cross product of two vectors and returns its z component. + * * result = a x b - * + * * \param a Value * \param b Value - * + * * \return Returns z component of the result vector. */ float bh_point2f_cross(const bh_point2f_t *a, @@ -814,9 +759,9 @@ float bh_point2f_cross(const bh_point2f_t *a, /** * Calculates the length of the vector. - * + * * \param in Value - * + * * \return Returns the length. */ float bh_point2f_length(const bh_point2f_t *in); @@ -824,583 +769,511 @@ float bh_point2f_length(const bh_point2f_t *in); /** * Normilizes the vector. - * + * * result = in / |in| - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_normal(const bh_point2f_t *in, - bh_point2f_t *result); +void bh_point2f_normal(const bh_point2f_t *in, + bh_point2f_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_min(const bh_point2f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_point2f_min(const bh_point2f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_max(const bh_point2f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_point2f_max(const bh_point2f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_lerp(const bh_point2f_t *a, - const bh_point2f_t *b, - float t, - bh_point2f_t *result); +void bh_point2f_lerp(const bh_point2f_t *a, + const bh_point2f_t *b, + float t, + bh_point2f_t *result); /** * Calculates spherical linear interpolation between two vectors. - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_point2f_slerp(const bh_point2f_t *a, - const bh_point2f_t *b, - float t, - bh_point2f_t *result); +void bh_point2f_slerp(const bh_point2f_t *a, + const bh_point2f_t *b, + float t, + bh_point2f_t *result); /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_add(const bh_point4i_t *a, - const bh_point4i_t *b, - bh_point4i_t *result); +void bh_point4i_add(const bh_point4i_t *a, + const bh_point4i_t *b, + bh_point4i_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_sub(const bh_point4i_t *a, - const bh_point4i_t *b, - bh_point4i_t *result); +void bh_point4i_sub(const bh_point4i_t *a, + const bh_point4i_t *b, + bh_point4i_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_mul(const bh_point4i_t *a, - const bh_point4i_t *b, - bh_point4i_t *result); +void bh_point4i_mul(const bh_point4i_t *a, + const bh_point4i_t *b, + bh_point4i_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_scale(const bh_point4i_t *a, - int b, - bh_point4i_t *result); +void bh_point4i_scale(const bh_point4i_t *a, + int b, + bh_point4i_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_madd(const bh_point4i_t *a, - const bh_point4i_t *b, - const bh_point4i_t *c, - bh_point4i_t *result); +void bh_point4i_madd(const bh_point4i_t *a, + const bh_point4i_t *b, + const bh_point4i_t *c, + bh_point4i_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_negate(const bh_point4i_t *in, - bh_point4i_t *result); +void bh_point4i_negate(const bh_point4i_t *in, + bh_point4i_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_min(const bh_point4i_t *a, - const bh_point4i_t *b, - bh_point4i_t *result); +void bh_point4i_min(const bh_point4i_t *a, + const bh_point4i_t *b, + bh_point4i_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_max(const bh_point4i_t *a, - const bh_point4i_t *b, - bh_point4i_t *result); +void bh_point4i_max(const bh_point4i_t *a, + const bh_point4i_t *b, + bh_point4i_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4i_t *bh_point4i_lerp(const bh_point4i_t *a, - const bh_point4i_t *b, - float t, - bh_point4i_t *result); +void bh_point4i_lerp(const bh_point4i_t *a, + const bh_point4i_t *b, + float t, + bh_point4i_t *result); /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_add(const bh_point3i_t *a, - const bh_point3i_t *b, - bh_point3i_t *result); +void bh_point3i_add(const bh_point3i_t *a, + const bh_point3i_t *b, + bh_point3i_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_sub(const bh_point3i_t *a, - const bh_point3i_t *b, - bh_point3i_t *result); +void bh_point3i_sub(const bh_point3i_t *a, + const bh_point3i_t *b, + bh_point3i_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_mul(const bh_point3i_t *a, - const bh_point3i_t *b, - bh_point3i_t *result); +void bh_point3i_mul(const bh_point3i_t *a, + const bh_point3i_t *b, + bh_point3i_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_scale(const bh_point3i_t *a, - int b, - bh_point3i_t *result); +void bh_point3i_scale(const bh_point3i_t *a, + int b, + bh_point3i_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_madd(const bh_point3i_t *a, - const bh_point3i_t *b, - const bh_point3i_t *c, - bh_point3i_t *result); +void bh_point3i_madd(const bh_point3i_t *a, + const bh_point3i_t *b, + const bh_point3i_t *c, + bh_point3i_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_negate(const bh_point3i_t *in, - bh_point3i_t *result); +void bh_point3i_negate(const bh_point3i_t *in, + bh_point3i_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_min(const bh_point3i_t *a, - const bh_point3i_t *b, - bh_point3i_t *result); +void bh_point3i_min(const bh_point3i_t *a, + const bh_point3i_t *b, + bh_point3i_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_max(const bh_point3i_t *a, - const bh_point3i_t *b, - bh_point3i_t *result); +void bh_point3i_max(const bh_point3i_t *a, + const bh_point3i_t *b, + bh_point3i_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3i_t *bh_point3i_lerp(const bh_point3i_t *a, - const bh_point3i_t *b, - float t, - bh_point3i_t *result); +void bh_point3i_lerp(const bh_point3i_t *a, + const bh_point3i_t *b, + float t, + bh_point3i_t *result); /** * Adds components of two vectors. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_add(const bh_point2i_t *a, - const bh_point2i_t *b, - bh_point2i_t *result); +void bh_point2i_add(const bh_point2i_t *a, + const bh_point2i_t *b, + bh_point2i_t *result); /** * Subtracts components of two vectors. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_sub(const bh_point2i_t *a, - const bh_point2i_t *b, - bh_point2i_t *result); +void bh_point2i_sub(const bh_point2i_t *a, + const bh_point2i_t *b, + bh_point2i_t *result); /** * Multiplies components of two vectors. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_mul(const bh_point2i_t *a, - const bh_point2i_t *b, - bh_point2i_t *result); +void bh_point2i_mul(const bh_point2i_t *a, + const bh_point2i_t *b, + bh_point2i_t *result); /** * Scales the vector. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_scale(const bh_point2i_t *a, - int b, - bh_point2i_t *result); +void bh_point2i_scale(const bh_point2i_t *a, + int b, + bh_point2i_t *result); /** * Multiplies and adds three vectors. - * + * * result = a * b + c - * + * * \param a Value * \param b Value * \param c Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_madd(const bh_point2i_t *a, - const bh_point2i_t *b, - const bh_point2i_t *c, - bh_point2i_t *result); +void bh_point2i_madd(const bh_point2i_t *a, + const bh_point2i_t *b, + const bh_point2i_t *c, + bh_point2i_t *result); /** * Negates the vector. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_negate(const bh_point2i_t *in, - bh_point2i_t *result); +void bh_point2i_negate(const bh_point2i_t *in, + bh_point2i_t *result); /** * Calculates vector, containing minimum components of two vectors. - * + * * result = min(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_min(const bh_point2i_t *a, - const bh_point2i_t *b, - bh_point2i_t *result); +void bh_point2i_min(const bh_point2i_t *a, + const bh_point2i_t *b, + bh_point2i_t *result); /** * Calculates vector, containing maximum components of two vectors. - * + * * result = max(a, b) - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_max(const bh_point2i_t *a, - const bh_point2i_t *b, - bh_point2i_t *result); +void bh_point2i_max(const bh_point2i_t *a, + const bh_point2i_t *b, + bh_point2i_t *result); /** * Calculates linear interpolation between two vectors. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2i_t *bh_point2i_lerp(const bh_point2i_t *a, - const bh_point2i_t *b, - float t, - bh_point2i_t *result); +void bh_point2i_lerp(const bh_point2i_t *a, + const bh_point2i_t *b, + float t, + bh_point2i_t *result); /** * Adds components of two quaternions. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_add bh_point4f_add /** * Subtracts components of two quaternions. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_sub bh_point4f_sub /** * Scales the quaternion. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_scale bh_point4f_scale /** * Negates the quaternion. - * + * * result = -in - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_negate bh_point4f_negate /** * Calculates the dot product of two quaternions. - * + * * \param a Value * \param b Value - * + * * \return Returns the dot product. */ #define bh_quat_dot bh_point4f_dot @@ -1408,9 +1281,9 @@ bh_point2i_t *bh_point2i_lerp(const bh_point2i_t *a, /** * Calculates the length of the quaternion. - * + * * \param in Value - * + * * \return Returns the length. */ #define bh_quat_length bh_point4f_length @@ -1418,134 +1291,116 @@ bh_point2i_t *bh_point2i_lerp(const bh_point2i_t *a, /** * Normilizes the quaternion. - * + * * result = in / |in| - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_normal bh_point4f_normal /** * Calculates linear interpolation between two quaternions. - * + * * result = a + (b - a) * t - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_lerp bh_point4f_lerp /** * Calculates spherical linear interpolation between two quaternions. - * + * * \param a Value * \param b Value * \param t Factor * \param result Result - * - * \return Returns pointer to the result. */ #define bh_quat_slerp bh_point4f_slerp /** * Sets quaternions to identity. - * + * * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_identity(bh_quat_t *result); +void bh_quat_identity(bh_quat_t *result); /** * Conjugates the quaternion. - * + * * result = (-in.x, -in.y, -in.z, in.w) - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_conjugate(const bh_quat_t *in, - bh_quat_t *result); +void bh_quat_conjugate(const bh_quat_t *in, + bh_quat_t *result); /** * Calculates the inverse of the quaternion. - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_inverse(const bh_quat_t *in, - bh_quat_t *result); +void bh_quat_inverse(const bh_quat_t *in, + bh_quat_t *result); /** * Multiplies two quaternions. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_mul(const bh_quat_t *a, - const bh_quat_t *b, - bh_quat_t *result); +void bh_quat_mul(const bh_quat_t *a, + const bh_quat_t *b, + bh_quat_t *result); /** * Sets quaternion from euler angles (roll, pitch, yaw). - * + * * Order of the rotation is ZYX (yaw, pitch, roll). - * + * * \param roll Roll * \param pitch Pitch * \param yaw Yaw * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_set_euler(float roll, - float pitch, - float yaw, - bh_quat_t *result); +void bh_quat_set_euler(float roll, + float pitch, + float yaw, + bh_quat_t *result); /** * Sets quaternion from axis of rotation and angle. - * + * * \param axis Axis * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_quat_t *bh_quat_set_rotation(const bh_point3f_t *axis, - float angle, - bh_quat_t *result); +void bh_quat_set_rotation(const bh_point3f_t *axis, + float angle, + bh_quat_t *result); /** * Calculates euler angles (roll, pitch, yaw) from quaternion. - * + * * Order of the rotation is ZYX (yaw, pitch, roll). - * + * * \param in Value * \param roll Roll * \param pitch Pitch @@ -1559,7 +1414,7 @@ void bh_quat_euler(const bh_quat_t *in, /** * Calculates axis of rotation and angle from quaternion. - * + * * \param in Value * \param axis Axis * \param angle Angle @@ -1571,109 +1426,95 @@ void bh_quat_rotation(const bh_quat_t *in, /** * Calculates rotation matrix from quaternion. - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_quat_matrix(const bh_quat_t *in, - bh_matrix4f_t *result); +void bh_quat_matrix(const bh_quat_t *in, + bh_matrix4f_t *result); /** * Sets matrix to identity. - * + * * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_identity(bh_matrix4f_t *result); +void bh_matrix4f_identity(bh_matrix4f_t *result); /** * Adds two matricies. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_add(const bh_matrix4f_t *a, - const bh_matrix4f_t *b, - bh_matrix4f_t *result); +void bh_matrix4f_add(const bh_matrix4f_t *a, + const bh_matrix4f_t *b, + bh_matrix4f_t *result); /** * Subtracts two matricies. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_sub(const bh_matrix4f_t *a, - const bh_matrix4f_t *b, - bh_matrix4f_t *result); +void bh_matrix4f_sub(const bh_matrix4f_t *a, + const bh_matrix4f_t *b, + bh_matrix4f_t *result); /** * Multiplies two matricies. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_mul(const bh_matrix4f_t *a, - const bh_matrix4f_t *b, - bh_matrix4f_t *result); +void bh_matrix4f_mul(const bh_matrix4f_t *a, + const bh_matrix4f_t *b, + bh_matrix4f_t *result); /** * Scales the matrix. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_scale(const bh_matrix4f_t *a, - float b, - bh_matrix4f_t *result); +void bh_matrix4f_scale(const bh_matrix4f_t *a, + float b, + bh_matrix4f_t *result); /** * Transposes the matrix. - * + * * result = a^T - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_transpose(const bh_matrix4f_t *in, - bh_matrix4f_t *result); +void bh_matrix4f_transpose(const bh_matrix4f_t *in, + bh_matrix4f_t *result); /** * Calculates the trace of the matrix. * * \param in Value - * + * * \return Returns trace value. */ float bh_matrix4f_trace(const bh_matrix4f_t *in); @@ -1681,9 +1522,9 @@ float bh_matrix4f_trace(const bh_matrix4f_t *in); /** * Calculates the determinant of the matrix. - * + * * \param in Value - * + * * \return Returns determinant value. */ float bh_matrix4f_determinant(const bh_matrix4f_t *in); @@ -1691,136 +1532,120 @@ float bh_matrix4f_determinant(const bh_matrix4f_t *in); /** * Calculates the inverse of the matrix. - * + * * If matrix has no inverse - identity matrix will be returned. - * + * * result = in^-1 - * + * * \param in Value * \param result Result - * + * * \return On success, returns inverse of the matrix. * \return On failure, returns identity matrix. */ -bh_matrix4f_t *bh_matrix4f_inverse(const bh_matrix4f_t *in, - bh_matrix4f_t *result); +int bh_matrix4f_inverse(const bh_matrix4f_t *in, + bh_matrix4f_t *result); /** * Calculates scaling matrix. - * + * * \param x X scale * \param y Y scale * \param z Z scale * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_scaling(float x, - float y, - float z, - bh_matrix4f_t *result); +void bh_matrix4f_scaling(float x, + float y, + float z, + bh_matrix4f_t *result); /** * Calculates translation matrix. - * + * * \param x X scale * \param y Y scale * \param z Z scale * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_translation(float x, - float y, - float z, - bh_matrix4f_t *result); +void bh_matrix4f_translation(float x, + float y, + float z, + bh_matrix4f_t *result); /** * Calculates x-rotation matrix (or rotation around x axis). - * + * * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation_x(float angle, - bh_matrix4f_t *result); +void bh_matrix4f_rotation_x(float angle, + bh_matrix4f_t *result); /** * Calculates y-rotation matrix (or rotation around y axis). - * + * * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation_y(float angle, - bh_matrix4f_t *result); +void bh_matrix4f_rotation_y(float angle, + bh_matrix4f_t *result); /** * Calculates z-rotation matrix (or rotation around z axis). - * + * * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation_z(float angle, - bh_matrix4f_t *result); +void bh_matrix4f_rotation_z(float angle, + bh_matrix4f_t *result); /** * Calculates rotation matrix around axis. - * + * * \param axis Axis * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation(const bh_point3f_t *axis, - float angle, - bh_matrix4f_t *result); +void bh_matrix4f_rotation(const bh_point3f_t *axis, + float angle, + bh_matrix4f_t *result); /** * Calculates rotation matrix from euler angles (roll, pitch, yaw). - * + * * Order of the rotation is ZYX (yaw, pitch, roll). - * + * * \param roll Roll * \param pitch Pitch * \param yaw Yaw * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation_euler(float roll, - float pitch, - float yaw, - bh_matrix4f_t *result); +void bh_matrix4f_rotation_euler(float roll, + float pitch, + float yaw, + bh_matrix4f_t *result); /** * Calculates rotation matrix from quaternion. - * + * * \param rotation Quaternion * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_rotation_quat(bh_quat_t *rotation, - bh_matrix4f_t *result); +void bh_matrix4f_rotation_quat(bh_quat_t *rotation, + bh_matrix4f_t *result); /** * Calculates orthographic projection matrix. - * + * * \param x_min Min x * \param x_max Max x * \param y_min Min y @@ -1828,173 +1653,151 @@ bh_matrix4f_t *bh_matrix4f_rotation_quat(bh_quat_t *rotation, * \param z_min Min z * \param z_max Max z * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_ortho(float x_min, - float x_max, - float y_min, - float y_max, - float z_min, - float z_max, - bh_matrix4f_t *result); +void bh_matrix4f_ortho(float x_min, + float x_max, + float y_min, + float y_max, + float z_min, + float z_max, + bh_matrix4f_t *result); /** * Calculates perspective projection matrix. - * + * * \param fov Field of view * \param aspect Aspect ratio * \param z_min Min z * \param z_max Max z * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_perspective(float fov, - float aspect, - float z_min, - float z_max, - bh_matrix4f_t *result); +void bh_matrix4f_perspective(float fov, + float aspect, + float z_min, + float z_max, + bh_matrix4f_t *result); /** * Calculates camera view matrix. - * + * * \param camera Position * \param at Target * \param up Up * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix4f_t *bh_matrix4f_lookat(const bh_point3f_t *camera, - const bh_point3f_t *at, - const bh_point3f_t *up, - bh_matrix4f_t *result); +void bh_matrix4f_lookat(const bh_point3f_t *camera, + const bh_point3f_t *at, + const bh_point3f_t *up, + bh_matrix4f_t *result); /** * Applies matrix to vector. - * + * * \param a Matrix * \param b Vector * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_matrix4f_transform_point3f(const bh_matrix4f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_matrix4f_transform_point3f(const bh_matrix4f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); /** * Applies matrix to vector. - * + * * \param a Matrix * \param b Vector * \param result Result - * - * \return Returns pointer to the result. */ -bh_point4f_t *bh_matrix4f_transform_point4f(const bh_matrix4f_t *a, - const bh_point4f_t *b, - bh_point4f_t *result); +void bh_matrix4f_transform_point4f(const bh_matrix4f_t *a, + const bh_point4f_t *b, + bh_point4f_t *result); /** * Sets matrix to identity. - * + * * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_identity(bh_matrix3f_t *result); +void bh_matrix3f_identity(bh_matrix3f_t *result); /** * Adds two matricies. - * + * * result = a + b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_add(const bh_matrix3f_t *a, - const bh_matrix3f_t *b, - bh_matrix3f_t *result); +void bh_matrix3f_add(const bh_matrix3f_t *a, + const bh_matrix3f_t *b, + bh_matrix3f_t *result); /** * Subtracts two matricies. - * + * * result = a - b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_sub(const bh_matrix3f_t *a, - const bh_matrix3f_t *b, - bh_matrix3f_t *result); +void bh_matrix3f_sub(const bh_matrix3f_t *a, + const bh_matrix3f_t *b, + bh_matrix3f_t *result); /** * Multiplies two matricies. - * + * * result = a * b - * + * * \param a Value * \param b Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_mul(const bh_matrix3f_t *a, - const bh_matrix3f_t *b, - bh_matrix3f_t *result); +void bh_matrix3f_mul(const bh_matrix3f_t *a, + const bh_matrix3f_t *b, + bh_matrix3f_t *result); /** * Scales the matrix. - * + * * result = a * b - * + * * \param a Value * \param b Factor * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_scale(const bh_matrix3f_t *a, - float b, - bh_matrix3f_t *result); +void bh_matrix3f_scale(const bh_matrix3f_t *a, + float b, + bh_matrix3f_t *result); /** * Transposes the matrix. - * + * * result = a^T - * + * * \param in Value * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_transpose(const bh_matrix3f_t *in, - bh_matrix3f_t *result); +void bh_matrix3f_transpose(const bh_matrix3f_t *in, + bh_matrix3f_t *result); /** * Calculates the trace of the matrix. * * \param in Value - * + * * \return Returns trace value. */ float bh_matrix3f_trace(const bh_matrix3f_t *in); @@ -2002,9 +1805,9 @@ float bh_matrix3f_trace(const bh_matrix3f_t *in); /** * Calculates the determinant of the matrix. - * + * * \param in Value - * + * * \return Returns determinant value. */ float bh_matrix3f_determinant(const bh_matrix3f_t *in); @@ -2012,89 +1815,79 @@ float bh_matrix3f_determinant(const bh_matrix3f_t *in); /** * Calculates the inverse of the matrix. - * + * * If matrix has no inverse - identity matrix will be returned. - * + * * result = in^-1 - * + * * \param in Value * \param result Result - * + * * \return On success, returns inverse of the matrix. * \return On failure, returns identity matrix. */ -bh_matrix3f_t *bh_matrix3f_inverse(const bh_matrix3f_t *in, - bh_matrix3f_t *result); +int bh_matrix3f_inverse(const bh_matrix3f_t *in, + bh_matrix3f_t *result); /** * Calculates scaling matrix. - * + * * \param x X scale * \param y Y scale * \param z Z scale * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_scaling(float x, - float y, - bh_matrix3f_t *result); +void bh_matrix3f_scaling(float x, + float y, + bh_matrix3f_t *result); /** * Calculates translation matrix. - * + * * \param x X scale * \param y Y scale * \param z Z scale * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_translation(float x, - float y, - bh_matrix3f_t *result); +void bh_matrix3f_translation(float x, + float y, + bh_matrix3f_t *result); /** * Calculates rotation matrix. - * + * * \param angle Angle * \param result Result - * - * \return Returns pointer to the result. */ -bh_matrix3f_t *bh_matrix3f_rotation(float angle, - bh_matrix3f_t *result); +void bh_matrix3f_rotation(float angle, + bh_matrix3f_t *result); /** * Applies matrix to vector. - * + * * \param a Matrix * \param b Vector * \param result Result - * - * \return Returns pointer to the result. */ -bh_point2f_t *bh_matrix3f_transform_point2f(const bh_matrix3f_t *a, - const bh_point2f_t *b, - bh_point2f_t *result); +void bh_matrix3f_transform_point2f(const bh_matrix3f_t *a, + const bh_point2f_t *b, + bh_point2f_t *result); /** * Applies matrix to vector. - * + * * \param a Matrix * \param b Vector * \param result Result - * - * \return Returns pointer to the result. */ -bh_point3f_t *bh_matrix3f_transform_point3f(const bh_matrix3f_t *a, - const bh_point3f_t *b, - bh_point3f_t *result); +void bh_matrix3f_transform_point3f(const bh_matrix3f_t *a, + const bh_point3f_t *b, + bh_point3f_t *result); #endif /* BH_MATH_H */ |
