Переименование типов на на общепринятый формат, отказ от суффикса _t, так как он зарезервирован POSIX

This commit is contained in:
Andrey Pokidov 2025-01-15 23:56:17 +07:00
parent 3805354611
commit 0027924f86
26 changed files with 574 additions and 571 deletions

View file

@ -98,6 +98,7 @@
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs> <CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -114,6 +115,7 @@
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs> <CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -130,6 +132,7 @@
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<CompileAs>CompileAsC</CompileAs> <CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)basic-geometry;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>

View file

@ -10,9 +10,9 @@
#endif // _WINDOWS_ #endif // _WINDOWS_
typedef struct { typedef struct {
bgc_versor_fp32_t versor1, versor2, result; BgcVersorFP32 versor1, versor2, result;
//matrix3x3_fp32_t matrix; //BgcMatrix3x3FP32 matrix;
bgc_vector3_fp32_t vector1, vector2; BgcVector3FP32 vector1, vector2;
} structure_fp32_t; } structure_fp32_t;
structure_fp32_t* allocate_structures(const unsigned int amount) structure_fp32_t* allocate_structures(const unsigned int amount)
@ -49,7 +49,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
bgc_versor_reset_fp32(&list[i].result); bgc_versor_reset_fp32(&list[i].result);
//matrix3x3_set_to_identity_fp32(&list[i].matrix); //bgc_matrix3x3_set_to_identity_fp32(&list[i].matrix);
bgc_vector3_set_values_fp32( bgc_vector3_set_values_fp32(
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
@ -64,32 +64,32 @@ structure_fp32_t* make_structures(const unsigned int amount)
return list; return list;
} }
void print_versor_fp32(const bgc_versor_fp32_t* versor) void print_versor_fp32(const BgcVersorFP32* versor)
{ {
printf("Versor (%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3); printf("Versor (%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
} }
void print_versor_fp64(const bgc_versor_fp64_t* versor) void print_versor_fp64(const BgcVersorFP64* versor)
{ {
printf("Versor (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3); printf("Versor (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3);
} }
void print_vector_fp32(const bgc_vector3_fp32_t* vector) void print_vector_fp32(const BgcVector3FP32* vector)
{ {
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector)); printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector));
} }
void print_vector_fp64(const bgc_vector3_fp64_t* vector) void print_vector_fp64(const BgcVector3FP64* vector)
{ {
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(vector)); printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(vector));
} }
void item_work(structure_fp32_t* item) void item_work(structure_fp32_t* item)
{ {
//for (int j = 0; j < 1000; j++) { for (unsigned int j = 0; j < 1000; j++) {
bgc_versor_combine_fp32(&item->versor1, &item->versor2, &item->result); bgc_versor_combine_fp32(&item->versor1, &item->versor2, &item->result);
bgc_versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2); //bgc_versor_turn_vector_fp32(&item->result, &item->vector1, &item->vector2);
//} }
} }
int main() int main()

View file

@ -2,7 +2,7 @@
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5; const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
const bgc_vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1[] = { const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = {
{ 3.0f, 4.0f }, { 3.0f, 4.0f },
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ 10000.0f, -20000.0f }, { 10000.0f, -20000.0f },
@ -10,7 +10,7 @@ const bgc_vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1[] = {
{ -123.5f, 3.7283f } { -123.5f, 3.7283f }
}; };
const bgc_vector2_fp32_t TEST_FP32_VECTOR2_COMMON_2[] = { const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_2[] = {
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ 0.002f, -0.05f }, { 0.002f, -0.05f },
@ -66,7 +66,7 @@ int test_vector2_fp32_modulus()
// ===================== Add ==================== // // ===================== Add ==================== //
const bgc_vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = { const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ -6.0f, -8.0f }, { -6.0f, -8.0f },
{ 10000.002f, -20000.05f }, { 10000.002f, -20000.05f },
@ -78,7 +78,7 @@ int test_vector2_add_fp32()
{ {
print_test_name("vector2_fp32_t add"); print_test_name("vector2_fp32_t add");
bgc_vector2_fp32_t vector; BgcVector2FP32 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector); bgc_vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
@ -96,7 +96,7 @@ int test_vector2_add_fp32()
// ================== Subtract ================== // // ================== Subtract ================== //
const bgc_vector2_fp32_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = { const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
{ 6.0f, 8.0f }, { 6.0f, 8.0f },
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 9999.998f, -19999.95f }, { 9999.998f, -19999.95f },
@ -108,7 +108,7 @@ int test_vector2_subtract_fp32()
{ {
print_test_name("vector2_fp32_t subtract"); print_test_name("vector2_fp32_t subtract");
bgc_vector2_fp32_t vector; BgcVector2FP32 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector); bgc_vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);

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

@ -32,7 +32,7 @@ typedef enum {
BGC_ANGLE_UNIT_RADIANS = 1, BGC_ANGLE_UNIT_RADIANS = 1,
BGC_ANGLE_UNIT_DEGREES = 2, BGC_ANGLE_UNIT_DEGREES = 2,
BGC_ANGLE_UNIT_TURNS = 3 BGC_ANGLE_UNIT_TURNS = 3
} bgc_angle_unit_t; } BgcAngleUnitEnum;
typedef enum { typedef enum {
/** /**
@ -46,7 +46,7 @@ typedef enum {
* (-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
*/ */
BGC_ANGLE_RANGE_SIGNED = 2 BGC_ANGLE_RANGE_SIGNED = 2
} bgc_angle_range_t; } BgcAngleRangeEnum;
// !================= Radians ==================! // // !================= Radians ==================! //
@ -76,7 +76,7 @@ inline double bgc_radians_to_turns_fp64(const double radians)
// ========= Convert radians to any unit ======== // // ========= Convert radians to any unit ======== //
inline float bgc_radians_to_units_fp32(const float radians, const bgc_angle_unit_t to_unit) inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP32; return radians * BGC_DEGREES_IN_RADIAN_FP32;
@ -89,7 +89,7 @@ inline float bgc_radians_to_units_fp32(const float radians, const bgc_angle_unit
return radians; return radians;
} }
inline double bgc_radians_to_units_fp64(const double radians, const bgc_angle_unit_t to_unit) inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP64; return radians * BGC_DEGREES_IN_RADIAN_FP64;
@ -104,7 +104,7 @@ inline double bgc_radians_to_units_fp64(const double radians, const bgc_angle_un
// ============ Normalize radians ============= // // ============ Normalize radians ============= //
inline float bgc_radians_normalize_fp32(const float radians, const bgc_angle_range_t range) inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) { if (0.0f <= radians && radians < BGC_TWO_PI_FP32) {
@ -128,7 +128,7 @@ inline float bgc_radians_normalize_fp32(const float radians, const bgc_angle_ran
return turns * BGC_TWO_PI_FP32; return turns * BGC_TWO_PI_FP32;
} }
inline double bgc_radians_normalize_fp64(const double radians, const bgc_angle_range_t range) inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) { if (0.0 <= radians && radians < BGC_TWO_PI_FP64) {
@ -180,7 +180,7 @@ inline double fp64_degrees_to_turns(const double radians)
// ========= Convert degreess to any unit ======== // // ========= Convert degreess to any unit ======== //
inline float bgc_degrees_to_units_fp32(const float degrees, const bgc_angle_unit_t to_unit) inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP32; return degrees * BGC_RADIANS_IN_DEGREE_FP32;
@ -193,7 +193,7 @@ inline float bgc_degrees_to_units_fp32(const float degrees, const bgc_angle_unit
return degrees; return degrees;
} }
inline double bgc_degrees_to_units_fp64(const double degrees, const bgc_angle_unit_t to_unit) inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP64; return degrees * BGC_RADIANS_IN_DEGREE_FP64;
@ -208,7 +208,7 @@ inline double bgc_degrees_to_units_fp64(const double degrees, const bgc_angle_un
// ============ Normalize degrees ============= // // ============ Normalize degrees ============= //
inline float bgc_degrees_normalize_fp32(const float degrees, const bgc_angle_range_t range) inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= degrees && degrees < 360.0f) { if (0.0f <= degrees && degrees < 360.0f) {
@ -232,7 +232,7 @@ inline float bgc_degrees_normalize_fp32(const float degrees, const bgc_angle_ran
return turns * 360.0f; return turns * 360.0f;
} }
inline double bgc_degrees_normalize_fp64(const double degrees, const bgc_angle_range_t range) inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= degrees && degrees < 360.0) { if (0.0 <= degrees && degrees < 360.0) {
@ -284,7 +284,7 @@ inline double bgc_turns_to_degrees_fp64(const double turns)
// ========= Convert turns to any unit ======== // // ========= Convert turns to any unit ======== //
inline float bgc_turns_to_units_fp32(const float turns, const bgc_angle_unit_t to_unit) inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP32; return turns * BGC_TWO_PI_FP32;
@ -297,7 +297,7 @@ inline float bgc_turns_to_units_fp32(const float turns, const bgc_angle_unit_t t
return turns; return turns;
} }
inline double bgc_turns_to_units_fp64(const double turns, const bgc_angle_unit_t to_unit) inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP64; return turns * BGC_TWO_PI_FP64;
@ -312,7 +312,7 @@ inline double bgc_turns_to_units_fp64(const double turns, const bgc_angle_unit_t
// ============= Normalize turns ============== // // ============= Normalize turns ============== //
inline float bgc_turns_normalize_fp32(const float turns, const bgc_angle_range_t range) inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= turns && turns < 1.0f) { if (0.0f <= turns && turns < 1.0f) {
@ -334,7 +334,7 @@ inline float bgc_turns_normalize_fp32(const float turns, const bgc_angle_range_t
return rest; return rest;
} }
inline double bgc_turns_normalize_fp64(const double turns, const bgc_angle_range_t range) inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= turns && turns < 1.0) { if (0.0 <= turns && turns < 1.0) {
@ -360,7 +360,7 @@ inline double bgc_turns_normalize_fp64(const double turns, const bgc_angle_range
// ========= Convert any unit to radians ======== // // ========= Convert any unit to radians ======== //
inline float bgc_angle_to_radians_fp32(const float angle, const bgc_angle_unit_t unit) inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP32; return angle * BGC_RADIANS_IN_DEGREE_FP32;
@ -373,7 +373,7 @@ inline float bgc_angle_to_radians_fp32(const float angle, const bgc_angle_unit_t
return angle; return angle;
} }
inline double bgc_angle_to_radians_fp64(const double angle, const bgc_angle_unit_t unit) inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP64; return angle * BGC_RADIANS_IN_DEGREE_FP64;
@ -388,7 +388,7 @@ inline double bgc_angle_to_radians_fp64(const double angle, const bgc_angle_unit
// ========= Convert any unit to degreess ======== // // ========= Convert any unit to degreess ======== //
inline float bgc_angle_to_degrees_fp32(const float angle, const bgc_angle_unit_t unit) inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit)
{ {
if (unit == BGC_ANGLE_UNIT_RADIANS) { if (unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_DEGREES_IN_RADIAN_FP32; return angle * BGC_DEGREES_IN_RADIAN_FP32;
@ -401,7 +401,7 @@ inline float bgc_angle_to_degrees_fp32(const float angle, const bgc_angle_unit_t
return angle; return angle;
} }