Продолжение переименования типов и функций

This commit is contained in:
Andrey Pokidov 2025-01-14 19:25:04 +07:00
parent 605afabd94
commit 3b6efaafa9
25 changed files with 768 additions and 916 deletions

View file

@ -52,31 +52,31 @@ typedef enum {
// ========= Convert radians to degrees ========= //
static inline float fp32_radians_to_degrees(const float radians)
inline float fp32_radians_to_degrees(const float radians)
{
return radians * FP32_DEGREES_IN_RADIAN;
}
static inline double fp64_radians_to_degrees(const double radians)
inline double fp64_radians_to_degrees(const double radians)
{
return radians * FP64_DEGREES_IN_RADIAN;
}
// ========== Convert radians to turns ========== //
static inline float fp32_radians_to_turns(const float radians)
inline float fp32_radians_to_turns(const float radians)
{
return radians * FP32_TURNS_IN_RADIAN;
}
static inline double fp64_radians_to_turns(const double radians)
inline double fp64_radians_to_turns(const double radians)
{
return radians * FP64_TURNS_IN_RADIAN;
}
// ========= Convert radians to any unit ======== //
static inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return radians * FP32_DEGREES_IN_RADIAN;
@ -89,7 +89,7 @@ static inline float fp32_radians_to_units(const float radians, const angle_unit_
return radians;
}
static inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return radians * FP64_DEGREES_IN_RADIAN;
@ -104,7 +104,7 @@ static inline double fp64_radians_to_units(const double radians, const angle_uni
// ============ Normalize radians ============= //
static inline float fp32_radians_normalize(const float radians, const angle_range_t range)
inline float fp32_radians_normalize(const float radians, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < FP32_TWO_PI) {
@ -128,7 +128,7 @@ static inline float fp32_radians_normalize(const float radians, const angle_rang
return turns * FP32_TWO_PI;
}
static inline double fp64_radians_normalize(const double radians, const angle_range_t range)
inline double fp64_radians_normalize(const double radians, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < FP64_TWO_PI) {
@ -156,31 +156,31 @@ static inline double fp64_radians_normalize(const double radians, const angle_ra
// ========= Convert degrees to radians ========= //
static inline float fp32_degrees_to_radians(const float degrees)
inline float fp32_degrees_to_radians(const float degrees)
{
return degrees * FP32_RADIANS_IN_DEGREE;
}
static inline double fp64_degrees_to_radians(const double degrees)
inline double fp64_degrees_to_radians(const double degrees)
{
return degrees * FP64_RADIANS_IN_DEGREE;
}
// ========== Convert degrees to turns ========== //
static inline float fp32_degrees_to_turns(const float radians)
inline float fp32_degrees_to_turns(const float radians)
{
return radians * FP32_TURNS_IN_DEGREE;
}
static inline double fp64_degrees_to_turns(const double radians)
inline double fp64_degrees_to_turns(const double radians)
{
return radians * FP64_TURNS_IN_DEGREE;
}
// ========= Convert degreess to any unit ======== //
static inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return degrees * FP32_RADIANS_IN_DEGREE;
@ -193,7 +193,7 @@ static inline float fp32_degrees_to_units(const float degrees, const angle_unit_
return degrees;
}
static inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return degrees * FP64_RADIANS_IN_DEGREE;
@ -208,7 +208,7 @@ static inline double fp64_degrees_to_units(const double degrees, const angle_uni
// ============ Normalize degrees ============= //
static inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= degrees && degrees < 360.0f) {
@ -232,7 +232,7 @@ static inline float fp32_degrees_normalize(const float degrees, const angle_rang
return turns * 360.0f;
}
static inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= degrees && degrees < 360.0) {
@ -260,31 +260,31 @@ static inline double fp64_degrees_normalize(const double degrees, const angle_ra
// ========== Convert turns to radians ========== //
static inline float fp32_turns_to_radians(const float turns)
inline float fp32_turns_to_radians(const float turns)
{
return turns * FP32_TWO_PI;
}
static inline double fp64_turns_to_radians(const double turns)
inline double fp64_turns_to_radians(const double turns)
{
return turns * FP64_TWO_PI;
}
// ========== Convert turns to degrees ========== //
static inline float fp32_turns_to_degrees(const float turns)
inline float fp32_turns_to_degrees(const float turns)
{
return turns * 360.0f;
}
static inline double fp64_turns_to_degrees(const double turns)
inline double fp64_turns_to_degrees(const double turns)
{
return turns * 360.0;
}
// ========= Convert turns to any unit ======== //
static inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return turns * FP32_TWO_PI;
@ -297,7 +297,7 @@ static inline float fp32_turns_to_units(const float turns, const angle_unit_t to
return turns;
}
static inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return turns * FP64_TWO_PI;
@ -312,7 +312,7 @@ static inline double fp64_turns_to_units(const double turns, const angle_unit_t
// ============= Normalize turns ============== //
static inline float fp32_turns_normalize(const float turns, const angle_range_t range)
inline float fp32_turns_normalize(const float turns, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= turns && turns < 1.0f) {
@ -334,7 +334,7 @@ static inline float fp32_turns_normalize(const float turns, const angle_range_t
return rest;
}
static inline double fp64_turns_normalize(const double turns, const angle_range_t range)
inline double fp64_turns_normalize(const double turns, const angle_range_t range)
{
if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= turns && turns < 1.0) {
@ -360,7 +360,7 @@ static inline double fp64_turns_normalize(const double turns, const angle_range_
// ========= Convert any unit to radians ======== //
static inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * FP32_RADIANS_IN_DEGREE;
@ -373,7 +373,7 @@ static inline float fp32_angle_to_radians(const float angle, const angle_unit_t
return angle;
}
static inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * FP64_RADIANS_IN_DEGREE;
@ -388,7 +388,7 @@ static inline double fp64_angle_to_radians(const double angle, const angle_unit_
// ========= Convert any unit to degreess ======== //
static inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * FP32_DEGREES_IN_RADIAN;
@ -401,7 +401,7 @@ static inline float fp32_angle_to_degrees(const float angle, const angle_unit_t
return angle;
}
static inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * FP64_DEGREES_IN_RADIAN;
@ -416,7 +416,7 @@ static inline double fp64_angle_to_degrees(const double angle, const angle_unit_
// ========= Convert any unit to turns ======== //
static inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * FP32_TURNS_IN_RADIAN;
@ -429,7 +429,7 @@ static inline float fp32_angle_to_turns(const float angle, const angle_unit_t un
return angle;
}
static inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * FP64_TURNS_IN_RADIAN;
@ -444,7 +444,7 @@ static inline double fp64_angle_to_turns(const double angle, const angle_unit_t
// ============= Get Full Circle ============== //
static inline float fp32_angle_get_full_circle(const angle_unit_t unit)
inline float fp32_angle_get_full_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 360.0f;
@ -457,7 +457,7 @@ static inline float fp32_angle_get_full_circle(const angle_unit_t unit)
return FP32_TWO_PI;
}
static inline double fp64_angle_get_full_circle(const angle_unit_t unit)
inline double fp64_angle_get_full_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 360.0;
@ -472,7 +472,7 @@ static inline double fp64_angle_get_full_circle(const angle_unit_t unit)
// ============= Get Half Circle ============== //
static inline float fp32_angle_get_half_circle(const angle_unit_t unit)
inline float fp32_angle_get_half_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 180.0f;
@ -485,7 +485,7 @@ static inline float fp32_angle_get_half_circle(const angle_unit_t unit)
return FP32_PI;
}
static inline double fp64_angle_get_half_circle(const angle_unit_t unit)
inline double fp64_angle_get_half_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 180.0;
@ -500,7 +500,7 @@ static inline double fp64_angle_get_half_circle(const angle_unit_t unit)
// ============= Get Half Circle ============== //
static inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 90.0f;
@ -513,7 +513,7 @@ static inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
return FP32_HALF_OF_PI;
}
static inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 90.0;
@ -528,7 +528,7 @@ static inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
// ================ Normalize ================= //
static inline float fp32_angle_normalize(const float angle, const angle_unit_t unit, const angle_range_t range)
inline float fp32_angle_normalize(const float angle, const angle_unit_t unit, const angle_range_t range)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return fp32_degrees_normalize(angle, range);
@ -541,7 +541,7 @@ static inline float fp32_angle_normalize(const float angle, const angle_unit_t u
return fp32_radians_normalize(angle, range);
}
static inline double fp64_angle_normalize(const double angle, const angle_unit_t unit, const angle_range_t range)
inline double fp64_angle_normalize(const double angle, const angle_unit_t unit, const angle_range_t range)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return fp64_degrees_normalize(angle, range);

View file

@ -1,5 +1,5 @@
#ifndef __GEOMETRY__TYPES_H_
#define __GEOMETRY__TYPES_H_
#ifndef _GEOMETRY_BASIS_H_
#define _GEOMETRY_BASIS_H_
#define FP32_EPSYLON_EFFECTIVENESS_LIMIT 10.0f
@ -27,7 +27,7 @@
#define FP64_GOLDEN_RATIO_HIGH 1.61803398874989485
#define FP64_GOLDEN_RATIO_LOW 0.61803398874989485
static inline int fp32_are_equal(const float value1, const float value2)
inline int fp32_are_equal(const float value1, const float value2)
{
if (-FP32_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return -FP32_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP32_EPSYLON;
@ -40,7 +40,7 @@ static inline int fp32_are_equal(const float value1, const float value2)
return value2 <= value1 * (1.0f + FP32_EPSYLON) && value1 <= value2 * (1.0f + FP32_EPSYLON);
}
static inline int fp64_are_equal(const double value1, const double value2)
inline int fp64_are_equal(const double value1, const double value2)
{
if (-FP64_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return -FP64_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP64_EPSYLON;

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -7,7 +7,7 @@
// =================== Reset ==================== //
static inline void fp32_matrix2x2_reset(fp32_matrix2x2_t* matrix)
inline void matrix2x2_reset_fp32(matrix2x2_fp32_t* matrix)
{
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
@ -15,7 +15,7 @@ static inline void fp32_matrix2x2_reset(fp32_matrix2x2_t* matrix)
matrix->r2c2 = 0.0f;
}
static inline void fp64_matrix2x2_reset(fp64_matrix2x2_t* matrix)
inline void matrix2x2_reset_fp64(matrix2x2_fp64_t* matrix)
{
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
@ -25,7 +25,7 @@ static inline void fp64_matrix2x2_reset(fp64_matrix2x2_t* matrix)
// ================== Identity ================== //
static inline void fp32_matrix2x2_set_to_identity(fp32_matrix2x2_t* matrix)
inline void matrix2x2_fp32_set_to_identity(matrix2x2_fp32_t* matrix)
{
matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f;
@ -33,7 +33,7 @@ static inline void fp32_matrix2x2_set_to_identity(fp32_matrix2x2_t* matrix)
matrix->r2c2 = 1.0f;
}
static inline void fp64_matrix2x2_set_to_identity(fp64_matrix2x2_t* matrix)
inline void matrix2x2_fp64_set_to_identity(matrix2x2_fp64_t* matrix)
{
matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0;
@ -43,7 +43,7 @@ static inline void fp64_matrix2x2_set_to_identity(fp64_matrix2x2_t* matrix)
// ================ Make Diagonal =============== //
static inline void fp32_matrix2x2_set_to_diagonal(const float d1, const float d2, fp32_matrix2x2_t* matrix)
inline void matrix2x2_fp32_set_to_diagonal(const float d1, const float d2, matrix2x2_fp32_t* matrix)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0f;
@ -51,7 +51,7 @@ static inline void fp32_matrix2x2_set_to_diagonal(const float d1, const float d2
matrix->r2c2 = d2;
}
static inline void fp64_matrix2x2_set_to_diagonal(const double d1, const double d2, fp64_matrix2x2_t* matrix)
inline void matrix2x2_fp64_set_to_diagonal(const double d1, const double d2, matrix2x2_fp64_t* matrix)
{
matrix->r1c1 = d1;
matrix->r1c2 = 0.0;
@ -61,7 +61,7 @@ static inline void fp64_matrix2x2_set_to_diagonal(const double d1, const double
// ============== Rotation Matrix =============== //
static inline void fp32_matrix2x2_make_turn(const float angle, const angle_unit_t unit, fp32_matrix2x2_t* matrix)
inline void matrix2x2_fp32_make_turn(const float angle, const angle_unit_t unit, matrix2x2_fp32_t* matrix)
{
const float radians = fp32_angle_to_radians(angle, unit);
const float cosine = cosf(radians);
@ -73,7 +73,7 @@ static inline void fp32_matrix2x2_make_turn(const float angle, const angle_unit_
matrix->r2c2 = cosine;
}
static inline void fp64_matrix2x2_make_turn(const double angle, const angle_unit_t unit, fp64_matrix2x2_t* matrix)
inline void matrix2x2_fp64_make_turn(const double angle, const angle_unit_t unit, matrix2x2_fp64_t* matrix)
{
const double radians = fp64_angle_to_radians(angle, unit);
const double cosine = cos(radians);
@ -87,7 +87,7 @@ static inline void fp64_matrix2x2_make_turn(const double angle, const angle_unit
// ==================== Copy ==================== //
static inline void fp32_matrix2x2_copy(const fp32_matrix2x2_t* from, fp32_matrix2x2_t* to)
inline void matrix2x2_copy_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
{
to->r1c1 = from->r1c1;
to->r1c2 = from->r1c2;
@ -96,7 +96,7 @@ static inline void fp32_matrix2x2_copy(const fp32_matrix2x2_t* from, fp32_matrix
to->r2c2 = from->r2c2;
}
static inline void fp64_matrix2x2_copy(const fp64_matrix2x2_t* from, fp64_matrix2x2_t* to)
inline void matrix2x2_copy_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
{
to->r1c1 = from->r1c1;
to->r1c2 = from->r1c2;
@ -107,7 +107,7 @@ static inline void fp64_matrix2x2_copy(const fp64_matrix2x2_t* from, fp64_matrix
// ==================== Swap ==================== //
static inline void fp32_matrix2x2_swap(fp32_matrix2x2_t* matrix1, fp32_matrix2x2_t* matrix2)
inline void matrix2x2_swap_fp32(matrix2x2_fp32_t* matrix1, matrix2x2_fp32_t* matrix2)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
@ -128,7 +128,7 @@ static inline void fp32_matrix2x2_swap(fp32_matrix2x2_t* matrix1, fp32_matrix2x2
matrix1->r2c2 = r2c2;
}
static inline void fp64_matrix2x2_swap(fp64_matrix2x2_t* matrix1, fp64_matrix2x2_t* matrix2)
inline void matrix2x2_swap_fp64(matrix2x2_fp64_t* matrix1, matrix2x2_fp64_t* matrix2)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
@ -151,7 +151,7 @@ static inline void fp64_matrix2x2_swap(fp64_matrix2x2_t* matrix1, fp64_matrix2x2
// ============= Copy to twin type ============== //
static inline void fp32_matrix2x2_set_from_fp64(const fp64_matrix2x2_t* from, fp32_matrix2x2_t* to)
inline void matrix2x2_fp32_set_from_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp32_t* to)
{
to->r1c1 = (float)from->r1c1;
to->r1c2 = (float)from->r1c2;
@ -160,7 +160,7 @@ static inline void fp32_matrix2x2_set_from_fp64(const fp64_matrix2x2_t* from, fp
to->r2c2 = (float)from->r2c2;
}