Большое переименование

This commit is contained in:
Andrey Pokidov 2024-11-20 16:53:12 +07:00
parent e354b2425c
commit e7616ae80c
30 changed files with 1356 additions and 1348 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <CodeBlocks_layout_file>
<FileVersion major="1" minor="0" /> <FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" /> <ActiveTarget name="Release" />
<File name="main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="3793" topLine="116" /> <Cursor1 position="3793" topLine="116" />

View file

@ -9,36 +9,36 @@
#include <time.h> #include <time.h>
#endif // _WINDOWS_ #endif // _WINDOWS_
SPVersor * allocate_versors(const unsigned int amount) BgFP32Versor * allocate_versors(const unsigned int amount)
{ {
return calloc(amount, sizeof(SPVersor)); return calloc(amount, sizeof(BgFP32Versor));
} }
SPVersor * make_zero_versors(const unsigned int amount) BgFP32Versor * make_zero_versors(const unsigned int amount)
{ {
SPVersor * list = allocate_versors(amount); BgFP32Versor * list = allocate_versors(amount);
if (list == 0) { if (list == 0) {
return 0; return 0;
} }
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
sp_versor_reset(&list[i]); bg_fp32_versor_reset(&list[i]);
} }
return list; return list;
} }
SPVersor * make_random_versors(const unsigned int amount) BgFP32Versor * make_random_versors(const unsigned int amount)
{ {
SPVersor * list = allocate_versors(amount); BgFP32Versor * list = allocate_versors(amount);
if (list == 0) { if (list == 0) {
return 0; return 0;
} }
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
sp_versor_set( bg_fp32_versor_set_values(
(2.0f * rand()) / RAND_MAX - 1.0f, (2.0f * rand()) / RAND_MAX - 1.0f,
(2.0f * rand()) / RAND_MAX - 1.0f, (2.0f * rand()) / RAND_MAX - 1.0f,
(2.0f * rand()) / RAND_MAX - 1.0f, (2.0f * rand()) / RAND_MAX - 1.0f,
@ -50,14 +50,14 @@ SPVersor * make_random_versors(const unsigned int amount)
return list; return list;
} }
void print_versor(const SPVersor* versor) void print_versor(const BgFP32Versor* versor)
{ {
printf("(%f, %f, %f, %f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); printf("(%f, %f, %f, %f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
} }
void print_vector(const SPVector3* vector) void print_vector(const BgFP32Vector3* vector)
{ {
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, sp_vector3_get_module(vector)); printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bg_fp32_vector3_get_module(vector));
} }
/* /*
int main() int main()
@ -74,17 +74,17 @@ int main()
srand((unsigned int)(now.tv_nsec & 0xfffffff)); srand((unsigned int)(now.tv_nsec & 0xfffffff));
#endif // _WIN64 #endif // _WIN64
SPVersor * versors = make_random_versors(amount); BgFP32Versor * versors = make_random_versors(amount);
if (versors == 0) { if (versors == 0) {
printf("Cannot allocate memory for versors"); printf("Cannot allocate memory for versors");
return 0; return 0;
} }
SPVector3 initial, result; BgFP32Vector3 initial, result;
sp_vector3_set_values(1, 2, 3, &initial); bg_fp32_vector3_set_values(1, 2, 3, &initial);
sp_vector3_copy(&initial, &result); bg_fp32_vector3_copy(&initial, &result);
#ifdef _WIN64 #ifdef _WIN64
ULONGLONG start, end; ULONGLONG start, end;
@ -94,11 +94,11 @@ int main()
clock_gettime(CLOCK_REALTIME, &start); clock_gettime(CLOCK_REALTIME, &start);
#endif // _WIN64 #endif // _WIN64
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
sp_versor_turn2(&versors[i], &result, &result); bg_fp32_versor_turn2(&versors[i], &result, &result);
} }
for (unsigned int i = amount; i > 0; i--) { for (unsigned int i = amount; i > 0; i--) {
sp_versor_turn_back2(&versors[i - 1], &result, &result); bg_fp32_versor_turn_back2(&versors[i - 1], &result, &result);
} }
#ifdef _WIN64 #ifdef _WIN64
@ -135,14 +135,14 @@ int main()
srand((unsigned int)(now.tv_nsec & 0xfffffff)); srand((unsigned int)(now.tv_nsec & 0xfffffff));
#endif // _WIN64 #endif // _WIN64
SPVersor * versors1 = make_random_versors(amount); BgFP32Versor * versors1 = make_random_versors(amount);
if (versors1 == 0) { if (versors1 == 0) {
printf("Cannot allocate memory for versors1"); printf("Cannot allocate memory for versors1");
return 0; return 0;
} }
SPVersor * versors2 = make_random_versors(amount); BgFP32Versor * versors2 = make_random_versors(amount);
if (versors2 == 0) { if (versors2 == 0) {
printf("Cannot allocate memory for versors2"); printf("Cannot allocate memory for versors2");
@ -150,7 +150,7 @@ int main()
return 0; return 0;
} }
SPVersor * results = make_zero_versors(amount); BgFP32Versor * results = make_zero_versors(amount);
if (results == 0) { if (results == 0) {
printf("Cannot allocate memory for results"); printf("Cannot allocate memory for results");
@ -168,7 +168,7 @@ int main()
#endif // _WIN64 #endif // _WIN64
for (int j = 0; j < 1000; j++) { for (int j = 0; j < 1000; j++) {
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
sp_versor_combine(&versors1[i], &versors2[i], &results[i]); bg_fp32_versor_combine(&versors1[i], &versors2[i], &results[i]);
} }
} }

View file

@ -4,34 +4,34 @@
#include <math.h> #include <math.h>
#include "basis.h" #include "basis.h"
#define SP_PI 3.1415926536f #define BG_FP32_PI 3.1415926536f
#define SP_TWO_PI 6.2831853072f #define BG_FP32_TWO_PI 6.2831853072f
#define SP_HALF_OF_PI 1.5707963268f #define BG_FP32_HALF_OF_PI 1.5707963268f
#define SP_THIRD_OF_PI 1.0471975512f #define BG_FP32_THIRD_OF_PI 1.0471975512f
#define SP_FOURTH_OF_PI 0.7853981634f #define BG_FP32_FOURTH_OF_PI 0.7853981634f
#define SP_SIXTH_OF_PI 0.5235987756f #define BG_FP32_SIXTH_OF_PI 0.5235987756f
#define SP_DEGREES_IN_RADIAN 57.295779513f #define BG_FP32_DEGREES_IN_RADIAN 57.295779513f
#define SP_TURNS_IN_RADIAN 0.1591549431f #define BG_FP32_TURNS_IN_RADIAN 0.1591549431f
#define SP_RADIANS_IN_DEGREE 1.745329252E-2f #define BG_FP32_RADIANS_IN_DEGREE 1.745329252E-2f
#define SP_TURNS_IN_DEGREE 2.7777777778E-3f #define BG_FP32_TURNS_IN_DEGREE 2.7777777778E-3f
#define DP_PI 3.14159265358979324 #define BG_FP64_PI 3.14159265358979324
#define DP_TWO_PI 6.28318530717958648 #define BG_FP64_TWO_PI 6.28318530717958648
#define DP_HALF_OF_PI 1.57079632679489662 #define BG_FP64_HALF_OF_PI 1.57079632679489662
#define DP_THIRD_OF_PI 1.04719755119659775 #define BG_FP64_THIRD_OF_PI 1.04719755119659775
#define DP_FOURTH_OF_PI 0.78539816339744831 #define BG_FP64_FOURTH_OF_PI 0.78539816339744831
#define DP_SIXTH_OF_PI 0.523598775598298873 #define BG_FP64_SIXTH_OF_PI 0.523598775598298873
#define DP_DEGREES_IN_RADIAN 57.2957795130823209 #define BG_FP64_DEGREES_IN_RADIAN 57.2957795130823209
#define DP_TURNS_IN_RADIAN 0.159154943091895336 #define BG_FP64_TURNS_IN_RADIAN 0.159154943091895336
#define DP_RADIANS_IN_DEGREE 1.74532925199432958E-2 #define BG_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
#define DP_TURNS_IN_DEGREE 2.77777777777777778E-3 #define BG_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
typedef enum { typedef enum {
ANGLE_UNIT_RADIANS = 1, BG_ANGLE_UNIT_RADIANS = 1,
ANGLE_UNIT_DEGREES = 2, BG_ANGLE_UNIT_DEGREES = 2,
ANGLE_UNIT_TURNS = 3 BG_ANGLE_UNIT_TURNS = 3
} angle_unit_t; } angle_unit_t;
typedef enum { typedef enum {
@ -39,394 +39,178 @@ typedef enum {
* The measure of an angle with a range of: * The measure of an angle with a range of:
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians * [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
*/ */
ANGLE_RANGE_UNSIGNED = 1, BG_ANGLE_RANGE_UNSIGNED = 1,
/** /**
* The measure of an angle with a range of: * The measure of an angle with a range of:
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians * (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
*/ */
ANGLE_RANGE_SIGNED = 2 BG_ANGLE_RANGE_SIGNED = 2
} angle_range_t; } angle_range_t;
// !================= Radians ==================! //
// ========= Convert radians to degrees ========= // // ========= Convert radians to degrees ========= //
static inline float sp_radians_to_degrees(const float radians) static inline float bg_fp32_radians_to_degrees(const float radians)
{ {
return radians * SP_DEGREES_IN_RADIAN; return radians * BG_FP32_DEGREES_IN_RADIAN;
} }
static inline double dp_radians_to_degrees(const double radians) static inline double bg_fp64_radians_to_degrees(const double radians)
{ {
return radians * DP_DEGREES_IN_RADIAN; return radians * BG_FP64_DEGREES_IN_RADIAN;
} }
// ========== Convert radians to turns ========== // // ========== Convert radians to turns ========== //
static inline float sp_radians_to_turns(const float radians) static inline float bg_fp32_radians_to_turns(const float radians)
{ {
return radians * SP_TURNS_IN_RADIAN; return radians * BG_FP32_TURNS_IN_RADIAN;
} }
static inline double dp_radians_to_turns(const double radians) static inline double bg_fp64_radians_to_turns(const double radians)
{ {
return radians * DP_TURNS_IN_RADIAN; return radians * BG_FP64_TURNS_IN_RADIAN;
}
// ========= Convert degrees to radians ========= //
static inline float sp_degrees_to_radians(const float degrees)
{
return degrees * SP_RADIANS_IN_DEGREE;
}
static inline double dp_degrees_to_radians(const double degrees)
{
return degrees * DP_RADIANS_IN_DEGREE;
}
// ========== Convert degrees to turns ========== //
static inline float sp_degrees_to_turns(const float radians)
{
return radians * SP_TURNS_IN_DEGREE;
}
static inline double dp_degrees_to_turns(const double radians)
{
return radians * DP_TURNS_IN_DEGREE;
}
// ========== Convert turns to radians ========== //
static inline float sp_turns_to_radians(const float turns)
{
return turns * SP_TWO_PI;
}
static inline double dp_turns_to_radians(const double turns)
{
return turns * DP_TWO_PI;
}
// ========== Convert turns to degrees ========== //
static inline float sp_turns_to_degrees(const float turns)
{
return turns * 360.0f;
}
static inline double dp_turns_to_degrees(const double turns)
{
return turns * 360.0;
} }
// ========= Convert radians to any unit ======== // // ========= Convert radians to any unit ======== //
static inline float sp_convert_from_radians(const float radians, const angle_unit_t to_unit) static inline float bg_fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
{ {
if (to_unit == ANGLE_UNIT_DEGREES) { if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return radians * SP_DEGREES_IN_RADIAN; return radians * BG_FP32_DEGREES_IN_RADIAN;
} }
if (to_unit == ANGLE_UNIT_TURNS) { if (to_unit == BG_ANGLE_UNIT_TURNS) {
return radians * SP_TURNS_IN_RADIAN; return radians * BG_FP32_TURNS_IN_RADIAN;
} }
return radians; return radians;
} }
static inline double dp_convert_from_radians(const double radians, const angle_unit_t to_unit) static inline double bg_fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
{ {
if (to_unit == ANGLE_UNIT_DEGREES) { if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return radians * DP_DEGREES_IN_RADIAN; return radians * BG_FP64_DEGREES_IN_RADIAN;
} }
if (to_unit == ANGLE_UNIT_TURNS) { if (to_unit == BG_ANGLE_UNIT_TURNS) {
return radians * DP_TURNS_IN_RADIAN; return radians * BG_FP64_TURNS_IN_RADIAN;
} }
return radians; return radians;
} }
// ========= Convert degreess to any unit ======== //
static inline float sp_convert_from_degrees(const float degrees, const angle_unit_t to_unit)
{
if (to_unit == ANGLE_UNIT_RADIANS) {
return degrees * SP_RADIANS_IN_DEGREE;
}
if (to_unit == ANGLE_UNIT_TURNS) {
return degrees * SP_TURNS_IN_DEGREE;
}
return degrees;
}
static inline double dp_convert_from_degrees(const double degrees, const angle_unit_t to_unit)
{
if (to_unit == ANGLE_UNIT_RADIANS) {
return degrees * DP_RADIANS_IN_DEGREE;
}
if (to_unit == ANGLE_UNIT_TURNS) {
return degrees * DP_TURNS_IN_DEGREE;
}
return degrees;
}
// ========= Convert turns to any unit ======== //
static inline float sp_convert_from_turns(const float turns, const angle_unit_t to_unit)
{
if (to_unit == ANGLE_UNIT_RADIANS) {
return turns * SP_TWO_PI;
}
if (to_unit == ANGLE_UNIT_DEGREES) {
return turns * 360.0f;
}
return turns;
}
static inline double dp_convert_from_turns(const double turns, const angle_unit_t to_unit)
{
if (to_unit == ANGLE_UNIT_RADIANS) {
return turns * DP_TWO_PI;
}
if (to_unit == ANGLE_UNIT_DEGREES) {
return turns * 360.0;
}
return turns;
}
// ========= Convert any unit to radians ======== //
static inline float sp_convert_to_radians(const float angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_DEGREES) {
return angle * SP_RADIANS_IN_DEGREE;
}
if (unit == ANGLE_UNIT_TURNS) {
return angle * SP_TWO_PI;
}
return angle;
}
static inline double dp_convert_to_radians(const double angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_DEGREES) {
return angle * DP_RADIANS_IN_DEGREE;
}
if (unit == ANGLE_UNIT_TURNS) {
return angle * DP_TWO_PI;
}
return angle;
}
// ========= Convert any unit to degreess ======== //
static inline float sp_convert_to_degrees(const float angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_DEGREES) {
return angle * SP_DEGREES_IN_RADIAN;
}
if (unit == ANGLE_UNIT_TURNS) {
return angle * 360.0f;
}
return angle;
}
static inline double dp_convert_to_degrees(const double angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return angle * DP_DEGREES_IN_RADIAN;
}
if (unit == ANGLE_UNIT_TURNS) {
return angle * 360.0;
}
return angle;
}
// ========= Convert any unit to turns ======== //
static inline float sp_convert_to_turns(const float angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return angle * SP_TURNS_IN_RADIAN;
}
if (unit == ANGLE_UNIT_DEGREES) {
return angle * SP_TURNS_IN_DEGREE;
}
return angle;
}
static inline double dp_convert_to_turns(const double angle, const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return angle * DP_TURNS_IN_RADIAN;
}
if (unit == ANGLE_UNIT_DEGREES) {
return angle * DP_TURNS_IN_DEGREE;
}
return angle;
}
// ============= Get Full Circle ============== //
static inline float sp_get_full_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return SP_TWO_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 360.0f;
}
return 1.0f;
}
static inline double dp_get_full_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return DP_TWO_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 360.0;
}
return 1.0;
}
// ============= Get Half Circle ============== //
static inline float sp_get_half_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return SP_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 180.0f;
}
return 0.5f;
}
static inline double dp_get_half_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return DP_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 180.0;
}
return 0.5;
}
// ============= Get Half Circle ============== //
static inline float sp_get_quater_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return SP_HALF_OF_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 90.0f;
}
return 0.25f;
}
static inline double dp_get_quater_circle(const angle_unit_t unit)
{
if (unit == ANGLE_UNIT_RADIANS) {
return DP_HALF_OF_PI;
}
if (unit == ANGLE_UNIT_DEGREES) {
return 90.0;
}
return 0.25;
}
// ============ Normalize radians ============= // // ============ Normalize radians ============= //
static inline float sp_normalize_radians(const float radians, const angle_range_t range) static inline float bg_fp32_radians_normalize(const float radians, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < SP_TWO_PI) { if (0.0f <= radians && radians < BG_FP32_TWO_PI) {
return radians; return radians;
} }
} }
else { else {
if (-SP_PI < radians && radians <= SP_PI) { if (-BG_FP32_PI < radians && radians <= BG_FP32_PI) {
return radians; return radians;
} }
} }
float turns = radians * SP_TURNS_IN_RADIAN; float turns = radians * BG_FP32_TURNS_IN_RADIAN;
turns -= floorf(turns); turns -= floorf(turns);
if (range == ANGLE_RANGE_SIGNED && turns > 0.5f) { if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f; turns -= 1.0f;
} }
return turns * SP_TWO_PI; return turns * BG_FP32_TWO_PI;
} }
static inline double dp_normalize_radians(const double radians, const angle_range_t range) static inline double bg_fp64_radians_normalize(const double radians, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < DP_TWO_PI) { if (0.0 <= radians && radians < BG_FP64_TWO_PI) {
return radians; return radians;
} }
} }
else { else {
if (-DP_PI < radians && radians <= DP_PI) { if (-BG_FP64_PI < radians && radians <= BG_FP64_PI) {
return radians; return radians;
} }
} }
double turns = radians * DP_TURNS_IN_RADIAN; double turns = radians * BG_FP64_TURNS_IN_RADIAN;
turns -= floor(turns); turns -= floor(turns);
if (range == ANGLE_RANGE_SIGNED && turns > 0.5) { if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0; turns -= 1.0;
} }
return turns * DP_TWO_PI; return turns * BG_FP64_TWO_PI;
}
// !================= Degrees ==================! //
// ========= Convert degrees to radians ========= //
static inline float bg_fp32_degrees_to_radians(const float degrees)
{
return degrees * BG_FP32_RADIANS_IN_DEGREE;
}
static inline double bg_fp64_degrees_to_radians(const double degrees)
{
return degrees * BG_FP64_RADIANS_IN_DEGREE;
}
// ========== Convert degrees to turns ========== //
static inline float bg_fp32_degrees_to_turns(const float radians)
{
return radians * BG_FP32_TURNS_IN_DEGREE;
}
static inline double bg_fp64_degrees_to_turns(const double radians)
{
return radians * BG_FP64_TURNS_IN_DEGREE;
}
// ========= Convert degreess to any unit ======== //
static inline float bg_fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return degrees * BG_FP32_RADIANS_IN_DEGREE;
}
if (to_unit == BG_ANGLE_UNIT_TURNS) {
return degrees * BG_FP32_TURNS_IN_DEGREE;
}
return degrees;
}
static inline double bg_fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return degrees * BG_FP64_RADIANS_IN_DEGREE;
}
if (to_unit == BG_ANGLE_UNIT_TURNS) {
return degrees * BG_FP64_TURNS_IN_DEGREE;
}
return degrees;
} }
// ============ Normalize degrees ============= // // ============ Normalize degrees ============= //
static inline float sp_normalize_degrees(const float degrees, const angle_range_t range) static inline float bg_fp32_degrees_normalize(const float degrees, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= degrees && degrees < 360.0f) { if (0.0f <= degrees && degrees < 360.0f) {
return degrees; return degrees;
} }
@ -437,20 +221,20 @@ static inline float sp_normalize_degrees(const float degrees, const angle_range_
} }
} }
float turns = degrees * SP_TURNS_IN_DEGREE; float turns = degrees * BG_FP32_TURNS_IN_DEGREE;
turns -= floorf(turns); turns -= floorf(turns);
if (range == ANGLE_RANGE_SIGNED && turns > 0.5f) { if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f; turns -= 1.0f;
} }
return turns * 360.0f; return turns * 360.0f;
} }
static inline double dp_normalize_degrees(const double degrees, const angle_range_t range) static inline double bg_fp64_degrees_normalize(const double degrees, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= degrees && degrees < 360.0) { if (0.0 <= degrees && degrees < 360.0) {
return degrees; return degrees;
} }
@ -461,22 +245,76 @@ static inline double dp_normalize_degrees(const double degrees, const angle_rang
} }
} }
double turns = degrees * DP_TURNS_IN_DEGREE; double turns = degrees * BG_FP64_TURNS_IN_DEGREE;
turns -= floor(turns); turns -= floor(turns);
if (range == ANGLE_RANGE_SIGNED && turns > 0.5) { if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0; turns -= 1.0;
} }
return turns * 360.0; return turns * 360.0;
} }
// !================== Turns ===================! //
// ========== Convert turns to radians ========== //
static inline float bg_fp32_turns_to_radians(const float turns)
{
return turns * BG_FP32_TWO_PI;
}
static inline double bg_fp64_turns_to_radians(const double turns)
{
return turns * BG_FP64_TWO_PI;
}
// ========== Convert turns to degrees ========== //
static inline float bg_fp32_turns_to_degrees(const float turns)
{
return turns * 360.0f;
}
static inline double bg_fp64_turns_to_degrees(const double turns)
{
return turns * 360.0;
}
// ========= Convert turns to any unit ======== //
static inline float bg_fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return turns * BG_FP32_TWO_PI;
}
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return turns * 360.0f;
}
return turns;
}
static inline double bg_fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
{
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
return turns * BG_FP64_TWO_PI;
}
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
return turns * 360.0;
}
return turns;
}
// ============= Normalize turns ============== // // ============= Normalize turns ============== //
static inline float sp_normalize_turns(const float turns, const angle_range_t range) static inline float bg_fp32_turns_normalize(const float turns, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= turns && turns < 1.0f) { if (0.0f <= turns && turns < 1.0f) {
return turns; return turns;
} }
@ -489,16 +327,16 @@ static inline float sp_normalize_turns(const float turns, const angle_range_t ra
float rest = turns - floorf(turns); float rest = turns - floorf(turns);
if (range == ANGLE_RANGE_SIGNED && rest > 0.5f) { if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5f) {
return rest - 1.0f; return rest - 1.0f;
} }
return rest; return rest;
} }
static inline double dp_normalize_turns(const double turns, const angle_range_t range) static inline double bg_fp64_turns_normalize(const double turns, const angle_range_t range)
{ {
if (range == ANGLE_RANGE_UNSIGNED) { if (range == BG_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= turns && turns < 1.0) { if (0.0 <= turns && turns < 1.0) {
return turns; return turns;
} }
@ -511,39 +349,209 @@ static inline double dp_normalize_turns(const double turns, const angle_range_t
double rest = turns - floor(turns); double rest = turns - floor(turns);
if (range == ANGLE_RANGE_SIGNED && rest > 0.5) { if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5) {
return rest - 1.0; return rest - 1.0;
} }
return rest; return rest;
} }
// !================== Angle ===================! //
// ========= Convert any unit to radians ======== //
static inline float bg_fp32_angle_to_radians(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * BG_FP32_RADIANS_IN_DEGREE;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return angle * BG_FP32_TWO_PI;
}
return angle;
}
static inline double bg_fp64_angle_to_radians(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * BG_FP64_RADIANS_IN_DEGREE;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return angle * BG_FP64_TWO_PI;
}
return angle;
}
// ========= Convert any unit to degreess ======== //
static inline float bg_fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * BG_FP32_DEGREES_IN_RADIAN;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return angle * 360.0f;
}
return angle;
}
static inline double bg_fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * BG_FP64_DEGREES_IN_RADIAN;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return angle * 360.0;
}
return angle;
}
// ========= Convert any unit to turns ======== //
static inline float bg_fp32_angle_to_turns(const float angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * BG_FP32_TURNS_IN_RADIAN;
}
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * BG_FP32_TURNS_IN_DEGREE;
}
return angle;
}
static inline double bg_fp64_angle_to_turns(const double angle, const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_RADIANS) {
return angle * BG_FP64_TURNS_IN_RADIAN;
}
if (unit == BG_ANGLE_UNIT_DEGREES) {
return angle * BG_FP64_TURNS_IN_DEGREE;
}
return angle;
}
// ============= Get Full Circle ============== //
static inline float bg_fp32_angle_get_full_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 360.0f;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 1.0f;
}
return BG_FP32_TWO_PI;
}
static inline double bg_fp64_angle_get_full_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 360.0;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 1.0;
}
return BG_FP64_TWO_PI;
}
// ============= Get Half Circle ============== //
static inline float bg_fp32_angle_get_half_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 180.0f;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 0.5f;
}
return BG_FP32_PI;
}
static inline double bg_fp64_angle_get_half_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 180.0;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 0.5;
}
return BG_FP64_PI;
}
// ============= Get Half Circle ============== //
static inline float bg_fp32_angle_get_quater_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 90.0f;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 0.25f;
}
return BG_FP32_HALF_OF_PI;
}
static inline double bg_fp64_angle_get_quater_circle(const angle_unit_t unit)
{
if (unit == BG_ANGLE_UNIT_DEGREES) {
return 90.0;
}
if (unit == BG_ANGLE_UNIT_TURNS) {
return 0.25;
}
return BG_FP64_HALF_OF_PI;
}
// ================ Normalize ================= // // ================ Normalize ================= //
static inline float sp_normalize_angle(const float angle, const angle_unit_t unit, const angle_range_t range) static inline float bg_fp32_angle_normalize(const float angle, const angle_unit_t unit, const angle_range_t range)
{ {
if (unit == ANGLE_UNIT_DEGREES) { if (unit == BG_ANGLE_UNIT_DEGREES) {
return sp_normalize_degrees(angle, range); return bg_fp32_degrees_normalize(angle, range);
} }
if (unit == ANGLE_UNIT_TURNS) { if (unit == BG_ANGLE_UNIT_TURNS) {
return sp_normalize_turns(angle, range); return bg_fp32_turns_normalize(angle, range);
} }
return sp_normalize_radians(angle, range); return bg_fp32_radians_normalize(angle, range);
} }
static inline double dp_normalize_angle(const double angle, const angle_unit_t unit, const angle_range_t range) static inline double bg_fp64_angle_normalize(const double angle, const angle_unit_t unit, const angle_range_t range)
{ {
if (unit == ANGLE_UNIT_DEGREES) { if (unit == BG_ANGLE_UNIT_DEGREES) {
return dp_normalize_degrees(angle, range); return bg_fp64_degrees_normalize(angle, range);
} }
if (unit == ANGLE_UNIT_TURNS) { if (unit == BG_ANGLE_UNIT_TURNS) {
return dp_normalize_turns(angle, range); return bg_fp64_turns_normalize(angle, range);
} }
return dp_normalize_radians(angle, range); return bg_fp64_radians_normalize(angle, range);
} }
#endif #endif

View file

@ -1,56 +1,56 @@
#ifndef __GEOMETRY__TYPES_H_ #ifndef __GEOMETRY__TYPES_H_
#define __GEOMETRY__TYPES_H_ #define __GEOMETRY__TYPES_H_
#define SP_EPSYLON_EFFECTIVENESS_LIMIT 10.0f #define BG_FP32_EPSYLON_EFFECTIVENESS_LIMIT 10.0f
#define SP_EPSYLON 5E-7f #define BG_FP32_EPSYLON 5E-7f
#define SP_TWO_EPSYLON 1E-6f #define BG_FP32_TWO_EPSYLON 1E-6f
#define SP_SQUARE_EPSYLON 2.5E-13f #define BG_FP32_SQUARE_EPSYLON 2.5E-13f
#define SP_ONE_THIRD 0.333333333f #define BG_FP32_ONE_THIRD 0.333333333f
#define SP_ONE_SIXTH 0.166666667f #define BG_FP32_ONE_SIXTH 0.166666667f
#define SP_ONE_NINETH 0.111111111f #define BG_FP32_ONE_NINETH 0.111111111f
#define SP_GOLDEN_RATIO_HIGH 1.618034f #define BG_FP32_GOLDEN_RATIO_HIGH 1.618034f
#define SP_GOLDEN_RATIO_LOW 0.618034f #define BG_FP32_GOLDEN_RATIO_LOW 0.618034f
#define DP_EPSYLON_EFFECTIVENESS_LIMIT 10.0 #define BG_FP64_EPSYLON_EFFECTIVENESS_LIMIT 10.0
#define DP_EPSYLON 5E-14 #define BG_FP64_EPSYLON 5E-14
#define DP_TWO_EPSYLON 1E-13 #define BG_FP64_TWO_EPSYLON 1E-13
#define DP_SQUARE_EPSYLON 2.5E-27 #define BG_FP64_SQUARE_EPSYLON 2.5E-27
#define DP_ONE_THIRD 0.333333333333333333 #define BG_FP64_ONE_THIRD 0.333333333333333333
#define DP_ONE_SIXTH 0.166666666666666667 #define BG_FP64_ONE_SIXTH 0.166666666666666667
#define DP_ONE_NINETH 0.111111111111111111 #define BG_FP64_ONE_NINETH 0.111111111111111111
#define DP_GOLDEN_RATIO_HIGH 1.61803398874989485 #define BG_FP64_GOLDEN_RATIO_HIGH 1.61803398874989485
#define DP_GOLDEN_RATIO_LOW 0.61803398874989485 #define BG_FP64_GOLDEN_RATIO_LOW 0.61803398874989485
static inline int sp_are_equal(const float value1, const float value2) static inline int bg_fp32_are_equal(const float value1, const float value2)
{ {
if (-SP_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < SP_EPSYLON_EFFECTIVENESS_LIMIT) { if (-BG_FP32_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < BG_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return -SP_EPSYLON <= (value1 - value2) && (value1 - value2) <= SP_EPSYLON; return -BG_FP32_EPSYLON <= (value1 - value2) && (value1 - value2) <= BG_FP32_EPSYLON;
} }
if (value1 < 0.0f) { if (value1 < 0.0f) {
return (1.0f + SP_EPSYLON) * value2 <= value1 && (1.0f + SP_EPSYLON) * value1 <= value2; return (1.0f + BG_FP32_EPSYLON) * value2 <= value1 && (1.0f + BG_FP32_EPSYLON) * value1 <= value2;
} }
return value2 <= value1 * (1.0f + SP_EPSYLON) && value1 <= value2 * (1.0f + SP_EPSYLON); return value2 <= value1 * (1.0f + BG_FP32_EPSYLON) && value1 <= value2 * (1.0f + BG_FP32_EPSYLON);
} }
static inline int dp_are_equal(const double value1, const double value2) static inline int bg_fp64_are_equal(const double value1, const double value2)
{ {
if (-DP_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < DP_EPSYLON_EFFECTIVENESS_LIMIT) { if (-BG_FP64_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < BG_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return -DP_EPSYLON <= (value1 - value2) && (value1 - value2) <= DP_EPSYLON; return -BG_FP64_EPSYLON <= (value1 - value2) && (value1 - value2) <= BG_FP64_EPSYLON;
} }
if (value1 < 0.0) { if (value1 < 0.0) {
return (1.0 + DP_EPSYLON) * value2 <= value1 && (1.0 + DP_EPSYLON) * value1 <= value2; return (1.0 + BG_FP64_EPSYLON) * value2 <= value1 && (1.0 + BG_FP64_EPSYLON) * value1 <= value2;
} }
return value2 <= value1 * (1.0 + DP_EPSYLON) && value1 <= value2 * (1.0 + DP_EPSYLON); return value2 <= value1 * (1.0 + BG_FP64_EPSYLON) && value1 <= value2 * (1.0 + BG_FP64_EPSYLON);
} }
#endif #endif

View file

@ -2,11 +2,76 @@
<CodeBlocks_layout_file> <CodeBlocks_layout_file>
<FileVersion major="1" minor="0" /> <FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" /> <ActiveTarget name="Debug" />
<File name="matrix2x3.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1596" topLine="0" />
</Cursor>
</File>
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="quaternion.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1849" topLine="187" />
</Cursor>
</File>
<File name="matrix2x2.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="matrix2x2.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="24" topLine="0" /> <Cursor1 position="24" topLine="0" />
</Cursor> </Cursor>
</File> </File>
<File name="matrix2x2.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13404" topLine="440" />
</Cursor>
</File>
<File name="vector2.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="556" topLine="12" />
</Cursor>
</File>
<File name="vector2.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="24" topLine="0" />
</Cursor>
</File>
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="504" topLine="0" />
</Cursor>
</File>
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="154" topLine="0" />
</Cursor>
</File>
<File name="versor.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="27" topLine="0" />
</Cursor>
</File>
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="103" topLine="0" />
</Cursor>
</File>
<File name="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20" topLine="0" />
</Cursor>
</File>
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1082" topLine="0" />
</Cursor>
</File>
<File name="matrix3x2.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="897" topLine="52" />
</Cursor>
</File>
<File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="6789" topLine="145" /> <Cursor1 position="6789" topLine="145" />
@ -14,67 +79,7 @@
</File> </File>
<File name="matrix3x3.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="matrix3x3.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="18608" topLine="582" /> <Cursor1 position="17612" topLine="537" />
</Cursor>
</File>
<File name="matrix3x2.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="897" topLine="52" />
</Cursor>
</File>
<File name="vector2.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="556" topLine="12" />
</Cursor>
</File>
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="305" topLine="29" />
</Cursor>
</File>
<File name="vector3.h" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16048" topLine="102" />
</Cursor>
</File>
<File name="quaternion.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1849" topLine="187" />
</Cursor>
</File>
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="103" topLine="0" />
</Cursor>
</File>
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="504" topLine="0" />
</Cursor>
</File>
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="23" topLine="72" />
</Cursor>
</File>
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1082" topLine="0" />
</Cursor>
</File>
<File name="versor.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="27" topLine="0" />
</Cursor>
</File>
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="154" topLine="0" />
</Cursor>
</File>
<File name="matrix2x3.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1596" topLine="0" />
</Cursor> </Cursor>
</File> </File>
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -82,29 +87,24 @@
<Cursor1 position="316" topLine="0" /> <Cursor1 position="316" topLine="0" />
</Cursor> </Cursor>
</File> </File>
<File name="vector3.h" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="15169" topLine="102" />
</Cursor>
</File>
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="305" topLine="29" />
</Cursor>
</File>
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="23" topLine="72" />
</Cursor>
</File>
<File name="vector3.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="vector3.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="24" topLine="0" /> <Cursor1 position="24" topLine="0" />
</Cursor> </Cursor>
</File> </File>
<File name="matrix2x2.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="18276" topLine="538" />
</Cursor>
</File>
<File name="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="20" topLine="0" />
</Cursor>
</File>
<File name="vector2.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="24" topLine="0" />
</Cursor>
</File>
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file> </CodeBlocks_layout_file>

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 ==================== // // =================== Reset ==================== //
static inline void sp_matrix2x2_reset(SPMatrix2x2* matrix) static inline void bg_fp32_matrix2x2_reset(BgFP32Matrix2x2* matrix)
{ {
matrix->r1c1 = 0.0f; matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -15,7 +15,7 @@ static inline void sp_matrix2x2_reset(SPMatrix2x2* matrix)
matrix->r2c2 = 0.0f; matrix->r2c2 = 0.0f;
} }
static inline void dp_matrix2x2_reset(DPMatrix2x2* matrix) static inline void bg_fp64_matrix2x2_reset(BgFP64Matrix2x2* matrix)
{ {
matrix->r1c1 = 0.0; matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -25,7 +25,7 @@ static inline void dp_matrix2x2_reset(DPMatrix2x2* matrix)
// ================== Identity ================== // // ================== Identity ================== //
static inline void sp_matrix2x2_make_identity(SPMatrix2x2* matrix) static inline void bg_fp32_matrix2x2_set_to_identity(BgFP32Matrix2x2* matrix)
{ {
matrix->r1c1 = 1.0f; matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -33,7 +33,7 @@ static inline void sp_matrix2x2_make_identity(SPMatrix2x2* matrix)
matrix->r2c2 = 1.0f; matrix->r2c2 = 1.0f;
} }
static inline void dp_matrix2x2_make_identity(DPMatrix2x2* matrix) static inline void bg_fp64_matrix2x2_set_to_identity(BgFP64Matrix2x2* matrix)
{ {
matrix->r1c1 = 1.0; matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -43,7 +43,7 @@ static inline void dp_matrix2x2_make_identity(DPMatrix2x2* matrix)
// ================ Make Diagonal =============== // // ================ Make Diagonal =============== //
static inline void sp_matrix2x2_make_diagonal(const float d1, const float d2, SPMatrix2x2* matrix) static inline void bg_fp32_matrix2x2_set_to_diagonal(const float d1, const float d2, BgFP32Matrix2x2* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -51,7 +51,7 @@ static inline void sp_matrix2x2_make_diagonal(const float d1, const float d2, SP
matrix->r2c2 = d2; matrix->r2c2 = d2;
} }
static inline void dp_matrix2x2_make_diagonal(const double d1, const double d2, DPMatrix2x2* matrix) static inline void bg_fp64_matrix2x2_set_to_diagonal(const double d1, const double d2, BgFP64Matrix2x2* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -61,9 +61,9 @@ static inline void dp_matrix2x2_make_diagonal(const double d1, const double d2,
// ============== Rotation Matrix =============== // // ============== Rotation Matrix =============== //
static inline void sp_matrix2x2_make_turn(const float angle, const angle_unit_t unit, SPMatrix2x2* matrix) static inline void bg_fp32_matrix2x2_make_turn(const float angle, const angle_unit_t unit, BgFP32Matrix2x2* matrix)
{ {
const float radians = sp_convert_to_radians(angle, unit); const float radians = bg_fp32_angle_to_radians(angle, unit);
const float cosine = cosf(radians); const float cosine = cosf(radians);
const float sine = sinf(radians); const float sine = sinf(radians);
@ -73,9 +73,9 @@ static inline void sp_matrix2x2_make_turn(const float angle, const angle_unit_t
matrix->r2c2 = cosine; matrix->r2c2 = cosine;
} }
static inline void dp_matrix2x2_make_turn(const double angle, const angle_unit_t unit, DPMatrix2x2* matrix) static inline void bg_fp64_matrix2x2_make_turn(const double angle, const angle_unit_t unit, BgFP64Matrix2x2* matrix)
{ {
const double radians = dp_convert_to_radians(angle, unit); const double radians = bg_fp64_angle_to_radians(angle, unit);
const double cosine = cos(radians); const double cosine = cos(radians);
const double sine = sin(radians); const double sine = sin(radians);
@ -87,7 +87,7 @@ static inline void dp_matrix2x2_make_turn(const double angle, const angle_unit_t
// ==================== Copy ==================== // // ==================== Copy ==================== //
static inline void sp_matrix2x2_copy(const SPMatrix2x2* from, SPMatrix2x2* to) static inline void bg_fp32_matrix2x2_copy(const BgFP32Matrix2x2* from, BgFP32Matrix2x2* to)
{ {
to->r1c1 = from->r1c1; to->r1c1 = from->r1c1;
to->r1c2 = from->r1c2; to->r1c2 = from->r1c2;
@ -96,7 +96,7 @@ static inline void sp_matrix2x2_copy(const SPMatrix2x2* from, SPMatrix2x2* to)
to->r2c2 = from->r2c2; to->r2c2 = from->r2c2;
} }
static inline void dp_matrix2x2_copy(const DPMatrix2x2* from, DPMatrix2x2* to) static inline void bg_fp64_matrix2x2_copy(const BgFP64Matrix2x2* from, BgFP64Matrix2x2* to)
{ {
to->r1c1 = from->r1c1; to->r1c1 = from->r1c1;
to->r1c2 = from->r1c2; to->r1c2 = from->r1c2;
@ -107,7 +107,7 @@ static inline void dp_matrix2x2_copy(const DPMatrix2x2* from, DPMatrix2x2* to)
// ============= Copy to twin type ============== // // ============= Copy to twin type ============== //
static inline void sp_matrix2x2_set_from_double(const DPMatrix2x2* from, SPMatrix2x2* to) static inline void bg_fp32_matrix2x2_set_from_fp64(const BgFP64Matrix2x2* from, BgFP32Matrix2x2* to)
{ {
to->r1c1 = (float)from->r1c1; to->r1c1 = (float)from->r1c1;
to->r1c2 = (float)from->r1c2; to->r1c2 = (float)from->r1c2;
@ -116,7 +116,7 @@ static inline void sp_matrix2x2_set_from_double(const DPMatrix2x2* from, SPMatri
to->r2c2 = (float)from->r2c2; to->r2c2 = (float)from->r2c2;
} }
static inline void dp_matrix2x2_set_from_single(const SPMatrix2x2* from, DPMatrix2x2* to) static inline void bg_fp64_matrix2x2_set_from_fp32(const BgFP32Matrix2x2* from, BgFP64Matrix2x2* to)
{ {
to->r1c1 = from->r1c1; to->r1c1 = from->r1c1;
to->r1c2 = from->r1c2; to->r1c2 = from->r1c2;
@ -127,42 +127,42 @@ static inline void dp_matrix2x2_set_from_single(const SPMatrix2x2* from, DPMatri
// ================ Determinant ================= // // ================ Determinant ================= //
static inline float sp_matrix2x2_get_determinant(const SPMatrix2x2* matrix) static inline float bg_fp32_matrix2x2_get_determinant(const BgFP32Matrix2x2* matrix)
{ {
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
} }
static inline double dp_matrix2x2_get_determinant(const DPMatrix2x2* matrix) static inline double bg_fp64_matrix2x2_get_determinant(const BgFP64Matrix2x2* matrix)
{ {
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
} }
// ================== Singular ================== // // ================== Singular ================== //
static inline int sp_matrix2x2_is_singular(const SPMatrix2x2* matrix) static inline int bg_fp32_matrix2x2_is_singular(const BgFP32Matrix2x2* matrix)
{ {
const float determinant = sp_matrix2x2_get_determinant(matrix); const float determinant = bg_fp32_matrix2x2_get_determinant(matrix);
return -SP_EPSYLON <= determinant && determinant <= SP_EPSYLON; return -BG_FP32_EPSYLON <= determinant && determinant <= BG_FP32_EPSYLON;
} }
static inline int dp_matrix2x2_is_singular(const DPMatrix2x2* matrix) static inline int bg_fp64_matrix2x2_is_singular(const BgFP64Matrix2x2* matrix)
{ {
const double determinant = dp_matrix2x2_get_determinant(matrix); const double determinant = bg_fp64_matrix2x2_get_determinant(matrix);
return -DP_EPSYLON <= determinant && determinant <= DP_EPSYLON; return -BG_FP64_EPSYLON <= determinant && determinant <= BG_FP64_EPSYLON;
} }
// =============== Transposition ================ // // =============== Transposition ================ //
static inline void sp_matrix2x2_transpose(SPMatrix2x2* matrix) static inline void bg_fp32_matrix2x2_transpose(BgFP32Matrix2x2* matrix)
{ {
const float tmp = matrix->r1c2; const float tmp = matrix->r1c2;
matrix->r1c2 = matrix->r2c1; matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = tmp; matrix->r2c1 = tmp;
} }
static inline void dp_matrix2x2_transpose(DPMatrix2x2* matrix) static inline void bg_fp64_matrix2x2_transpose(BgFP64Matrix2x2* matrix)
{ {
const double tmp = matrix->r1c2; const double tmp = matrix->r1c2;