Продолжение переименования типов и функций
This commit is contained in:
parent
605afabd94
commit
3b6efaafa9
25 changed files with 768 additions and 916 deletions
|
@ -13,12 +13,12 @@
|
|||
typedef struct
|
||||
{
|
||||
const float cos, sin;
|
||||
} fp32_tangent_t;
|
||||
} tangent_fp32_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const double cos, sin;
|
||||
} fp64_tangent_t;
|
||||
} tangent_fp64_t;
|
||||
|
||||
// ================= Dark Twins ================= //
|
||||
|
||||
|
@ -32,12 +32,12 @@ typedef struct {
|
|||
|
||||
// ================= Constants ================== //
|
||||
|
||||
extern const fp32_tangent_t FP32_IDLE_TANGENT;
|
||||
extern const fp64_tangent_t FP64_IDLE_TANGENT;
|
||||
extern const tangent_fp32_t FP32_IDLE_TANGENT;
|
||||
extern const tangent_fp64_t FP64_IDLE_TANGENT;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
static inline void fp32_tangent_reset(fp32_tangent_t* tangent)
|
||||
inline void tangent_reset_fp32(tangent_fp32_t* tangent)
|
||||
{
|
||||
__BgFP32DarkTwinTangent* twin = (__BgFP32DarkTwinTangent*)tangent;
|
||||
|
||||
|
@ -45,7 +45,7 @@ static inline void fp32_tangent_reset(fp32_tangent_t* tangent)
|
|||
twin->sin = 0.0f;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_reset(fp64_tangent_t* tangent)
|
||||
inline void tangent_reset_fp64(tangent_fp64_t* tangent)
|
||||
{
|
||||
__BgFP64DarkTwinTangent* twin = (__BgFP64DarkTwinTangent*)tangent;
|
||||
|
||||
|
@ -55,7 +55,7 @@ static inline void fp64_tangent_reset(fp64_tangent_t* tangent)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
static inline void fp32_tangent_set_values(const float x1, const float x2, fp32_tangent_t* tangent)
|
||||
inline void tangent_fp32_set_values(const float x1, const float x2, tangent_fp32_t* tangent)
|
||||
{
|
||||
const float square_module = x1 * x1 + x2 * x2;
|
||||
|
||||
|
@ -80,7 +80,7 @@ static inline void fp32_tangent_set_values(const float x1, const float x2, fp32_
|
|||
twin->sin = x2 * multiplier;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_set_values(const double x1, const double x2, fp64_tangent_t* tangent)
|
||||
inline void tangent_fp64_set_values(const double x1, const double x2, tangent_fp64_t* tangent)
|
||||
{
|
||||
const double square_module = x1 * x1 + x2 * x2;
|
||||
|
||||
|
@ -107,7 +107,7 @@ static inline void fp64_tangent_set_values(const double x1, const double x2, fp6
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
static inline void fp32_tangent_copy(const fp32_tangent_t* from, fp32_tangent_t* to)
|
||||
inline void tangent_copy_fp32(const tangent_fp32_t* from, tangent_fp32_t* to)
|
||||
{
|
||||
__BgFP32DarkTwinTangent* twin = (__BgFP32DarkTwinTangent*)to;
|
||||
|
||||
|
@ -115,7 +115,7 @@ static inline void fp32_tangent_copy(const fp32_tangent_t* from, fp32_tangent_t*
|
|||
twin->sin = from->sin;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_copy(const fp64_tangent_t* from, fp64_tangent_t* to)
|
||||
inline void tangent_copy_fp64(const tangent_fp64_t* from, tangent_fp64_t* to)
|
||||
{
|
||||
__BgFP64DarkTwinTangent* twin = (__BgFP64DarkTwinTangent*)to;
|
||||
|
||||
|
@ -125,7 +125,7 @@ static inline void fp64_tangent_copy(const fp64_tangent_t* from, fp64_tangent_t*
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void fp32_tangent_swap(fp32_tangent_t* tangent1, fp32_tangent_t* tangent2)
|
||||
inline void tangent_swap_fp32(tangent_fp32_t* tangent1, tangent_fp32_t* tangent2)
|
||||
{
|
||||
const float cos = tangent1->cos;
|
||||
const float sin = tangent1->sin;
|
||||
|
@ -141,7 +141,7 @@ static inline void fp32_tangent_swap(fp32_tangent_t* tangent1, fp32_tangent_t* t
|
|||
twin2->sin = sin;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_swap(fp64_tangent_t* tangent1, fp64_tangent_t* tangent2)
|
||||
inline void tangent_swap_fp64(tangent_fp64_t* tangent1, tangent_fp64_t* tangent2)
|
||||
{
|
||||
const double cos = tangent1->cos;
|
||||
const double sin = tangent1->sin;
|
||||
|
@ -159,7 +159,7 @@ static inline void fp64_tangent_swap(fp64_tangent_t* tangent1, fp64_tangent_t* t
|
|||
|
||||
// ================== Set Turn ================== //
|
||||
|
||||
static inline void fp32_tangent_set_turn(const float angle, const angle_unit_t unit, fp32_tangent_t* tangent)
|
||||
inline void tangent_fp32_set_turn(const float angle, const angle_unit_t unit, tangent_fp32_t* tangent)
|
||||
{
|
||||
const float radians = fp32_angle_to_radians(angle, unit);
|
||||
|
||||
|
@ -169,7 +169,7 @@ static inline void fp32_tangent_set_turn(const float angle, const angle_unit_t u
|
|||
twin->sin = sinf(radians);
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_set_turn(const double angle, const angle_unit_t unit, fp64_tangent_t* tangent)
|
||||
inline void tangent_fp64_set_turn(const double angle, const angle_unit_t unit, tangent_fp64_t* tangent)
|
||||
{
|
||||
const double radians = fp64_angle_to_radians(angle, unit);
|
||||
|
||||
|
@ -181,31 +181,31 @@ static inline void fp64_tangent_set_turn(const double angle, const angle_unit_t
|
|||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
static inline void fp32_tangent_set_from_fp64(const fp64_tangent_t* from, fp32_tangent_t* to)
|
||||
inline void tangent_fp32_set_from_fp64(const tangent_fp64_t* from, tangent_fp32_t* to)
|
||||
{
|
||||
fp32_tangent_set_values((float)from->cos, (float)from->sin, to);
|
||||
tangent_fp32_set_values((float)from->cos, (float)from->sin, to);
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_set_from_fp32(const fp32_tangent_t* from, fp64_tangent_t* to)
|
||||
inline void tangent_fp64_set_from_fp32(const tangent_fp32_t* from, tangent_fp64_t* to)
|
||||
{
|
||||
fp64_tangent_set_values((double)from->cos, (double)from->sin, to);
|
||||
tangent_fp64_set_values((double)from->cos, (double)from->sin, to);
|
||||
}
|
||||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
static inline void fp32_tangent_invert(fp32_tangent_t* tangent)
|
||||
inline void tangent_invert_fp32(tangent_fp32_t* tangent)
|
||||
{
|
||||
((__BgFP32DarkTwinTangent*)tangent)->sin = -tangent->sin;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_invert(fp64_tangent_t* tangent)
|
||||
inline void tangent_invert_fp64(tangent_fp64_t* tangent)
|
||||
{
|
||||
((__BgFP64DarkTwinTangent*)tangent)->sin = -tangent->sin;
|
||||
}
|
||||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
static inline void fp32_tangent_set_inverted(const fp32_tangent_t* tangent, fp32_tangent_t* result)
|
||||
inline void tangent_fp32_set_inverted(const tangent_fp32_t* tangent, tangent_fp32_t* result)
|
||||
{
|
||||
__BgFP32DarkTwinTangent* twin = (__BgFP32DarkTwinTangent*)result;
|
||||
|
||||
|
@ -213,7 +213,7 @@ static inline void fp32_tangent_set_inverted(const fp32_tangent_t* tangent, fp32
|
|||
twin->sin = -tangent->sin;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_set_inverted(const fp64_tangent_t* tangent, fp64_tangent_t* result)
|
||||
inline void tangent_fp64_set_inverted(const tangent_fp64_t* tangent, tangent_fp64_t* result)
|
||||
{
|
||||
__BgFP64DarkTwinTangent* twin = (__BgFP64DarkTwinTangent*)result;
|
||||
|
||||
|
@ -223,7 +223,7 @@ static inline void fp64_tangent_set_inverted(const fp64_tangent_t* tangent, fp64
|
|||
|
||||
// ============== Rotation Matrix =============== //
|
||||
|
||||
static inline void fp32_tangent_make_rotation_matrix(const fp32_tangent_t* tangent, fp32_matrix2x2_t* matrix)
|
||||
inline void tangent_fp32_make_rotation_matrix(const tangent_fp32_t* tangent, matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = tangent->cos;
|
||||
matrix->r1c2 = -tangent->sin;
|
||||
|
@ -231,7 +231,7 @@ static inline void fp32_tangent_make_rotation_matrix(const fp32_tangent_t* tange
|
|||
matrix->r2c2 = tangent->cos;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_make_rotation_matrix(const fp64_tangent_t* tangent, fp64_matrix2x2_t* matrix)
|
||||
inline void tangent_fp64_make_rotation_matrix(const tangent_fp64_t* tangent, matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = tangent->cos;
|
||||
matrix->r1c2 = -tangent->sin;
|
||||
|
@ -241,7 +241,7 @@ static inline void fp64_tangent_make_rotation_matrix(const fp64_tangent_t* tange
|
|||
|
||||
// ============== Reverse Matrix ================ //
|
||||
|
||||
static inline void fp32_tangent_make_reverse_matrix(const fp32_tangent_t* tangent, fp32_matrix2x2_t* matrix)
|
||||
inline void tangent_fp32_make_reverse_matrix(const tangent_fp32_t* tangent, matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = tangent->cos;
|
||||
matrix->r1c2 = tangent->sin;
|
||||
|
@ -249,7 +249,7 @@ static inline void fp32_tangent_make_reverse_matrix(const fp32_tangent_t* tangen
|
|||
matrix->r2c2 = tangent->cos;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_make_reverse_matrix(const fp64_tangent_t* tangent, fp64_matrix2x2_t* matrix)
|
||||
inline void tangent_fp64_make_reverse_matrix(const tangent_fp64_t* tangent, matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = tangent->cos;
|
||||
matrix->r1c2 = tangent->sin;
|
||||
|
@ -259,7 +259,7 @@ static inline void fp64_tangent_make_reverse_matrix(const fp64_tangent_t* tangen
|
|||
|
||||
// =================== Angle =================== //
|
||||
|
||||
static inline float fp32_tangent_get_angle(const fp32_tangent_t* tangent, const angle_unit_t unit)
|
||||
inline float tangent_fp32_get_angle(const tangent_fp32_t* tangent, const angle_unit_t unit)
|
||||
{
|
||||
if (tangent->cos >= 1.0f - FP32_TWO_EPSYLON) {
|
||||
return 0.0f;
|
||||
|
@ -280,7 +280,7 @@ static inline float fp32_tangent_get_angle(const fp32_tangent_t* tangent, const
|
|||
return fp32_radians_to_units(atan2f(tangent->cos, tangent->sin), unit);
|
||||
}
|
||||
|
||||
static inline double fp64_tangent_get_angle(const fp64_tangent_t* tangent, const angle_unit_t unit)
|
||||
inline double tangent_fp64_get_angle(const tangent_fp64_t* tangent, const angle_unit_t unit)
|
||||
{
|
||||
if (tangent->cos >= 1.0 - FP64_TWO_EPSYLON) {
|
||||
return 0.0;
|
||||
|
@ -303,18 +303,18 @@ static inline double fp64_tangent_get_angle(const fp64_tangent_t* tangent, const
|
|||
|
||||
// ================ Combination ================= //
|
||||
|
||||
static inline void fp32_tangent_combine(const fp32_tangent_t* tangent1, const fp32_tangent_t* tangent2, fp32_tangent_t* result)
|
||||
inline void tangent_fp32_combine(const tangent_fp32_t* tangent1, const tangent_fp32_t* tangent2, tangent_fp32_t* result)
|
||||
{
|
||||
fp32_tangent_set_values(
|
||||
tangent_fp32_set_values(
|
||||
tangent1->cos * tangent2->cos - tangent1->sin * tangent2->sin,
|
||||
tangent1->cos * tangent2->sin + tangent1->sin * tangent2->cos,
|
||||
result
|
||||
);
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_combine(const fp64_tangent_t* tangent1, const fp64_tangent_t* tangent2, fp64_tangent_t* result)
|
||||
inline void tangent_fp64_combine(const tangent_fp64_t* tangent1, const tangent_fp64_t* tangent2, tangent_fp64_t* result)
|
||||
{
|
||||
fp64_tangent_set_values(
|
||||
tangent_fp64_set_values(
|
||||
tangent1->cos * tangent2->cos - tangent1->sin * tangent2->sin,
|
||||
tangent1->cos * tangent2->sin + tangent1->sin * tangent2->cos,
|
||||
result
|
||||
|
@ -323,7 +323,7 @@ static inline void fp64_tangent_combine(const fp64_tangent_t* tangent1, const fp
|
|||
|
||||
// ================ Turn Vector ================= //
|
||||
|
||||
static inline void fp32_tangent_turn(const fp32_tangent_t* tangent, const fp32_vector2_t* vector, fp32_vector2_t* result)
|
||||
inline void tangent_fp32_turn(const tangent_fp32_t* tangent, const vector2_fp32_t* vector, vector2_fp32_t* result)
|
||||
{
|
||||
const float x1 = tangent->cos * vector->x1 - tangent->sin * vector->x2;
|
||||
const float x2 = tangent->sin * vector->x1 + tangent->cos * vector->x2;
|
||||
|
@ -332,7 +332,7 @@ static inline void fp32_tangent_turn(const fp32_tangent_t* tangent, const fp32_v
|
|||
result->x2 = x2;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_turn(const fp64_tangent_t* tangent, const fp64_vector2_t* vector, fp64_vector2_t* result)
|
||||
inline void tangent_fp64_turn(const tangent_fp64_t* tangent, const vector2_fp64_t* vector, vector2_fp64_t* result)
|
||||
{
|
||||
const double x1 = tangent->cos * vector->x1 - tangent->sin * vector->x2;
|
||||
const double x2 = tangent->sin * vector->x1 + tangent->cos * vector->x2;
|
||||
|
@ -343,7 +343,7 @@ static inline void fp64_tangent_turn(const fp64_tangent_t* tangent, const fp64_v
|
|||
|
||||
// ============ Turn Vector Backward ============ //
|
||||
|
||||
static inline void fp32_tangent_turn_back(const fp32_tangent_t* tangent, const fp32_vector2_t* vector, fp32_vector2_t* result)
|
||||
inline void tangent_fp32_turn_back(const tangent_fp32_t* tangent, const vector2_fp32_t* vector, vector2_fp32_t* result)
|
||||
{
|
||||
const float x1 = tangent->sin * vector->x2 + tangent->cos * vector->x1;
|
||||
const float x2 = tangent->cos * vector->x2 - tangent->sin * vector->x1;
|
||||
|
@ -352,7 +352,7 @@ static inline void fp32_tangent_turn_back(const fp32_tangent_t* tangent, const f
|
|||
result->x2 = x2;
|
||||
}
|
||||
|
||||
static inline void fp64_tangent_turn_back(const fp64_tangent_t* tangent, const fp64_vector2_t* vector, fp64_vector2_t* result)
|
||||
inline void tangent_fp64_turn_back(const tangent_fp64_t* tangent, const vector2_fp64_t* vector, vector2_fp64_t* result)
|
||||
{
|
||||
const double x1 = tangent->sin * vector->x2 + tangent->cos * vector->x1;
|
||||
const double x2 = tangent->cos * vector->x2 - tangent->sin * vector->x1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue