Переименование типов в соответствии со стилем POSIX, отказ от префикса bg_
This commit is contained in:
parent
d2a25823a5
commit
605afabd94
25 changed files with 1109 additions and 1035 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _GEOMETRY_MATRIX2X2_H_
|
||||
#define _GEOMETRY_MATRIX2X2_H_
|
||||
#ifndef _BASIC_GEOMETRY_MATRIX2X2_H_
|
||||
#define _BASIC_GEOMETRY_MATRIX2X2_H_
|
||||
|
||||
#include "angle.h"
|
||||
#include "vector2.h"
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_reset(BgFP32Matrix2x2* matrix)
|
||||
static inline void fp32_matrix2x2_reset(fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 0.0f;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -15,7 +15,7 @@ static inline void bg_fp32_matrix2x2_reset(BgFP32Matrix2x2* matrix)
|
|||
matrix->r2c2 = 0.0f;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_reset(BgFP64Matrix2x2* matrix)
|
||||
static inline void fp64_matrix2x2_reset(fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 0.0;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -25,7 +25,7 @@ static inline void bg_fp64_matrix2x2_reset(BgFP64Matrix2x2* matrix)
|
|||
|
||||
// ================== Identity ================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_set_to_identity(BgFP32Matrix2x2* matrix)
|
||||
static inline void fp32_matrix2x2_set_to_identity(fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 1.0f;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -33,7 +33,7 @@ static inline void bg_fp32_matrix2x2_set_to_identity(BgFP32Matrix2x2* matrix)
|
|||
matrix->r2c2 = 1.0f;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_set_to_identity(BgFP64Matrix2x2* matrix)
|
||||
static inline void fp64_matrix2x2_set_to_identity(fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 1.0;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -43,7 +43,7 @@ static inline void bg_fp64_matrix2x2_set_to_identity(BgFP64Matrix2x2* matrix)
|
|||
|
||||
// ================ Make Diagonal =============== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_set_to_diagonal(const float d1, const float d2, BgFP32Matrix2x2* matrix)
|
||||
static inline void fp32_matrix2x2_set_to_diagonal(const float d1, const float d2, fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = d1;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -51,7 +51,7 @@ static inline void bg_fp32_matrix2x2_set_to_diagonal(const float d1, const float
|
|||
matrix->r2c2 = d2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_set_to_diagonal(const double d1, const double d2, BgFP64Matrix2x2* matrix)
|
||||
static inline void fp64_matrix2x2_set_to_diagonal(const double d1, const double d2, fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = d1;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -61,9 +61,9 @@ static inline void bg_fp64_matrix2x2_set_to_diagonal(const double d1, const doub
|
|||
|
||||
// ============== Rotation Matrix =============== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_make_turn(const float angle, const angle_unit_t unit, BgFP32Matrix2x2* matrix)
|
||||
static inline void fp32_matrix2x2_make_turn(const float angle, const angle_unit_t unit, fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
const float radians = bg_fp32_angle_to_radians(angle, unit);
|
||||
const float radians = fp32_angle_to_radians(angle, unit);
|
||||
const float cosine = cosf(radians);
|
||||
const float sine = sinf(radians);
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ static inline void bg_fp32_matrix2x2_make_turn(const float angle, const angle_un
|
|||
matrix->r2c2 = cosine;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_make_turn(const double angle, const angle_unit_t unit, BgFP64Matrix2x2* matrix)
|
||||
static inline void fp64_matrix2x2_make_turn(const double angle, const angle_unit_t unit, fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
const double radians = bg_fp64_angle_to_radians(angle, unit);
|
||||
const double radians = fp64_angle_to_radians(angle, unit);
|
||||
const double cosine = cos(radians);
|
||||
const double sine = sin(radians);
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ static inline void bg_fp64_matrix2x2_make_turn(const double angle, const angle_u
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_copy(const BgFP32Matrix2x2* from, BgFP32Matrix2x2* to)
|
||||
static inline void fp32_matrix2x2_copy(const fp32_matrix2x2_t* from, fp32_matrix2x2_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -96,7 +96,7 @@ static inline void bg_fp32_matrix2x2_copy(const BgFP32Matrix2x2* from, BgFP32Mat
|
|||
to->r2c2 = from->r2c2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_copy(const BgFP64Matrix2x2* from, BgFP64Matrix2x2* to)
|
||||
static inline void fp64_matrix2x2_copy(const fp64_matrix2x2_t* from, fp64_matrix2x2_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -107,7 +107,7 @@ static inline void bg_fp64_matrix2x2_copy(const BgFP64Matrix2x2* from, BgFP64Mat
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_swap(BgFP32Matrix2x2* matrix1, BgFP32Matrix2x2* matrix2)
|
||||
static inline void fp32_matrix2x2_swap(fp32_matrix2x2_t* matrix1, fp32_matrix2x2_t* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
|
|
@ -128,7 +128,7 @@ static inline void bg_fp32_matrix2x2_swap(BgFP32Matrix2x2* matrix1, BgFP32Matrix
|
|||
matrix1->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_swap(BgFP64Matrix2x2* matrix1, BgFP64Matrix2x2* matrix2)
|
||||
static inline void fp64_matrix2x2_swap(fp64_matrix2x2_t* matrix1, fp64_matrix2x2_t* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
|
|
@ -151,7 +151,7 @@ static inline void bg_fp64_matrix2x2_swap(BgFP64Matrix2x2* matrix1, BgFP64Matrix
|
|||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_set_from_fp64(const BgFP64Matrix2x2* from, BgFP32Matrix2x2* to)
|
||||
static inline void fp32_matrix2x2_set_from_fp64(const fp64_matrix2x2_t* from, fp32_matrix2x2_t* to)
|
||||
{
|
||||
to->r1c1 = (float)from->r1c1;
|
||||
to->r1c2 = (float)from->r1c2;
|
||||
|
|
@ -160,7 +160,7 @@ static inline void bg_fp32_matrix2x2_set_from_fp64(const BgFP64Matrix2x2* from,
|
|||
to->r2c2 = (float)from->r2c2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_set_from_fp32(const BgFP32Matrix2x2* from, BgFP64Matrix2x2* to)
|
||||
static inline void fp64_matrix2x2_set_from_fp32(const fp32_matrix2x2_t* from, fp64_matrix2x2_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -171,42 +171,42 @@ static inline void bg_fp64_matrix2x2_set_from_fp32(const BgFP32Matrix2x2* from,
|
|||
|
||||
// ================ Determinant ================= //
|
||||
|
||||
static inline float bg_fp32_matrix2x2_get_determinant(const BgFP32Matrix2x2* matrix)
|
||||
static inline float fp32_matrix2x2_get_determinant(const fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||
}
|
||||
|
||||
static inline double bg_fp64_matrix2x2_get_determinant(const BgFP64Matrix2x2* matrix)
|
||||
static inline double fp64_matrix2x2_get_determinant(const fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||
}
|
||||
|
||||
// ================== Singular ================== //
|
||||
|
||||
static inline int bg_fp32_matrix2x2_is_singular(const BgFP32Matrix2x2* matrix)
|
||||
static inline int fp32_matrix2x2_is_singular(const fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
const float determinant = bg_fp32_matrix2x2_get_determinant(matrix);
|
||||
const float determinant = fp32_matrix2x2_get_determinant(matrix);
|
||||
|
||||
return -BG_FP32_EPSYLON <= determinant && determinant <= BG_FP32_EPSYLON;
|
||||
return -FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON;
|
||||
}
|
||||
|
||||
static inline int bg_fp64_matrix2x2_is_singular(const BgFP64Matrix2x2* matrix)
|
||||
static inline int fp64_matrix2x2_is_singular(const fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
const double determinant = bg_fp64_matrix2x2_get_determinant(matrix);
|
||||
const double determinant = fp64_matrix2x2_get_determinant(matrix);
|
||||
|
||||
return -BG_FP64_EPSYLON <= determinant && determinant <= BG_FP64_EPSYLON;
|
||||
return -FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON;
|
||||
}
|
||||
|
||||
// =============== Transposition ================ //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_transpose(BgFP32Matrix2x2* matrix)
|
||||
static inline void fp32_matrix2x2_transpose(fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
const float tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
matrix->r2c1 = tmp;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_transpose(BgFP64Matrix2x2* matrix)
|
||||
static inline void fp64_matrix2x2_transpose(fp64_matrix2x2_t* matrix)
|
||||
{
|
||||
const double tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
|
|
@ -215,11 +215,11 @@ static inline void bg_fp64_matrix2x2_transpose(BgFP64Matrix2x2* matrix)
|
|||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
static inline int bg_fp32_matrix2x2_invert(BgFP32Matrix2x2* matrix)
|
||||
static inline int fp32_matrix2x2_invert(fp32_matrix2x2_t* matrix)
|
||||
{
|
||||
const float determinant = bg_fp32_matrix2x2_get_determinant(matrix);
|
||||
const float determinant = fp32_matrix2x2_get_determinant(matrix);
|
||||
|
||||
if (-BG_FP32_EPSYLON <= determinant && determinant <= BG_FP32_EPSYLON) {
|
||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -240,11 +240,11 @@ static inline int bg_fp32_matrix2x2_invert(BgFP32Matrix2x2* matrix)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static inline int bg_fp64_matrix2x2_invert(BgFP64Matrix2x2* matrix)
|
||||