Переименование типов на на общепринятый формат, отказ от суффикса _t, так как он зарезервирован POSIX
This commit is contained in:
parent
3805354611
commit
0027924f86
26 changed files with 574 additions and 571 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_to_degrees_fp64(const double angle, const bgc_angle_unit_t unit)
|
inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * BGC_DEGREES_IN_RADIAN_FP64;
|
return angle * BGC_DEGREES_IN_RADIAN_FP64;
|
||||||
|
|
@ -416,7 +416,7 @@ inline double bgc_angle_to_degrees_fp64(const double angle, const bgc_angle_unit
|
||||||
|
|
||||||
// ========= Convert any unit to turns ======== //
|
// ========= Convert any unit to turns ======== //
|
||||||
|
|
||||||
inline float bgc_angle_to_turns_fp32(const float angle, const bgc_angle_unit_t unit)
|
inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * BGC_TURNS_IN_RADIAN_FP32;
|
return angle * BGC_TURNS_IN_RADIAN_FP32;
|
||||||
|
|
@ -429,7 +429,7 @@ inline float bgc_angle_to_turns_fp32(const float angle, const bgc_angle_unit_t u
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_to_turns_fp64(const double angle, const bgc_angle_unit_t unit)
|
inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||||
return angle * BGC_TURNS_IN_RADIAN_FP64;
|
return angle * BGC_TURNS_IN_RADIAN_FP64;
|
||||||
|
|
@ -444,7 +444,7 @@ inline double bgc_angle_to_turns_fp64(const double angle, const bgc_angle_unit_t
|
||||||
|
|
||||||
// ============= Get Full Circle ============== //
|
// ============= Get Full Circle ============== //
|
||||||
|
|
||||||
inline float bgc_angle_get_full_circle_fp32(const bgc_angle_unit_t unit)
|
inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0f;
|
return 360.0f;
|
||||||
|
|
@ -457,7 +457,7 @@ inline float bgc_angle_get_full_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
return BGC_TWO_PI_FP32;
|
return BGC_TWO_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_get_full_circle_fp64(const bgc_angle_unit_t unit)
|
inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 360.0;
|
return 360.0;
|
||||||
|
|
@ -472,7 +472,7 @@ inline double bgc_angle_get_full_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
inline float bgc_angle_get_half_circle_fp32(const bgc_angle_unit_t unit)
|
inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0f;
|
return 180.0f;
|
||||||
|
|
@ -485,7 +485,7 @@ inline float bgc_angle_get_half_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
return BGC_PI_FP32;
|
return BGC_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_get_half_circle_fp64(const bgc_angle_unit_t unit)
|
inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 180.0;
|
return 180.0;
|
||||||
|
|
@ -500,7 +500,7 @@ inline double bgc_angle_get_half_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
|
|
||||||
// ============= Get Half Circle ============== //
|
// ============= Get Half Circle ============== //
|
||||||
|
|
||||||
inline float bgc_angle_get_quater_circle_fp32(const bgc_angle_unit_t unit)
|
inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0f;
|
return 90.0f;
|
||||||
|
|
@ -513,7 +513,7 @@ inline float bgc_angle_get_quater_circle_fp32(const bgc_angle_unit_t unit)
|
||||||
return BGC_HALF_OF_PI_FP32;
|
return BGC_HALF_OF_PI_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_get_quater_circle_fp64(const bgc_angle_unit_t unit)
|
inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return 90.0;
|
return 90.0;
|
||||||
|
|
@ -528,7 +528,7 @@ inline double bgc_angle_get_quater_circle_fp64(const bgc_angle_unit_t unit)
|
||||||
|
|
||||||
// ================ Normalize ================= //
|
// ================ Normalize ================= //
|
||||||
|
|
||||||
inline float bgc_angle_normalize_fp32(const float angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return bgc_degrees_normalize_fp32(angle, range);
|
return bgc_degrees_normalize_fp32(angle, range);
|
||||||
|
|
@ -541,7 +541,7 @@ inline float bgc_angle_normalize_fp32(const float angle, const bgc_angle_unit_t
|
||||||
return bgc_radians_normalize_fp32(angle, range);
|
return bgc_radians_normalize_fp32(angle, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_angle_normalize_fp64(const double angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
|
||||||
{
|
{
|
||||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||||
return bgc_degrees_normalize_fp64(angle, range);
|
return bgc_degrees_normalize_fp64(angle, range);
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,6 @@
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="angle.h" />
|
<Unit filename="angle.h" />
|
||||||
<Unit filename="basic-geometry.h" />
|
<Unit filename="basic-geometry.h" />
|
||||||
<Unit filename="basis.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="matrix2x2.c">
|
<Unit filename="matrix2x2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
@ -77,6 +74,9 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="tangent.h" />
|
<Unit filename="tangent.h" />
|
||||||
|
<Unit filename="utilities.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="utilities.h" />
|
<Unit filename="utilities.h" />
|
||||||
<Unit filename="vector2.c">
|
<Unit filename="vector2.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="angle.c" />
|
<ClCompile Include="angle.c" />
|
||||||
<ClCompile Include="basis.c" />
|
<ClCompile Include="utilities.c" />
|
||||||
<ClCompile Include="matrix2x2.c" />
|
<ClCompile Include="matrix2x2.c" />
|
||||||
<ClCompile Include="matrix2x3.c" />
|
<ClCompile Include="matrix2x3.c" />
|
||||||
<ClCompile Include="matrix3x2.c" />
|
<ClCompile Include="matrix3x2.c" />
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
<ClCompile Include="angle.c">
|
<ClCompile Include="angle.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="basis.c">
|
<ClCompile Include="utilities.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="matrix2x2.c">
|
<ClCompile Include="matrix2x2.c">
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_reset_fp32(bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
|
@ -15,7 +15,7 @@ inline void bgc_matrix2x2_reset_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
matrix->r2c2 = 0.0f;
|
matrix->r2c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_reset_fp64(bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
|
@ -25,7 +25,7 @@ inline void bgc_matrix2x2_reset_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================== Identity ================== //
|
// ================== Identity ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_to_identity_fp32(bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0f;
|
matrix->r1c1 = 1.0f;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
|
@ -33,7 +33,7 @@ inline void bgc_matrix2x2_set_to_identity_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
matrix->r2c2 = 1.0f;
|
matrix->r2c2 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_to_identity_fp64(bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = 1.0;
|
matrix->r1c1 = 1.0;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
|
@ -43,7 +43,7 @@ inline void bgc_matrix2x2_set_to_identity_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================ Make Diagonal =============== //
|
// ================ Make Diagonal =============== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
|
@ -51,7 +51,7 @@ inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, b
|
||||||
matrix->r2c2 = d2;
|
matrix->r2c2 = d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->r1c2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
|
@ -61,7 +61,7 @@ inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2,
|
||||||
|
|
||||||
// ============== Rotation Matrix =============== //
|
// ============== Rotation Matrix =============== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
||||||
const float cosine = cosf(radians);
|
const float cosine = cosf(radians);
|
||||||
|
|
@ -73,7 +73,7 @@ inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const bgc_angle_
|
||||||
matrix->r2c2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
||||||
const double cosine = cos(radians);
|
const double cosine = cos(radians);
|
||||||
|
|
@ -87,7 +87,7 @@ inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const bgc_angle
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_copy_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
|
@ -96,7 +96,7 @@ inline void bgc_matrix2x2_copy_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_copy_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
|
@ -107,7 +107,7 @@ inline void bgc_matrix2x2_copy_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_swap_fp32(bgc_matrix2x2_fp32_t* matrix1, bgc_matrix2x2_fp32_t* matrix2)
|
inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
|
@ -128,7 +128,7 @@ inline void bgc_matrix2x2_swap_fp32(bgc_matrix2x2_fp32_t* matrix1, bgc_matrix2x2
|
||||||
matrix1->r2c2 = r2c2;
|
matrix1->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_swap_fp64(bgc_matrix2x2_fp64_t* matrix1, bgc_matrix2x2_fp64_t* matrix2)
|
inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
|
@ -151,7 +151,7 @@ inline void bgc_matrix2x2_swap_fp64(bgc_matrix2x2_fp64_t* matrix1, bgc_matrix2x2
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ============= Copy to twin type ============== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_convert_fp64_to_fp32(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = (float)from->r1c1;
|
to->r1c1 = (float)from->r1c1;
|
||||||
to->r1c2 = (float)from->r1c2;
|
to->r1c2 = (float)from->r1c2;
|
||||||
|
|
@ -160,7 +160,7 @@ inline void bgc_matrix2x2_convert_fp64_to_fp32(const bgc_matrix2x2_fp64_t* from,
|
||||||
to->r2c2 = (float)from->r2c2;
|
to->r2c2 = (float)from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_convert_fp32_to_fp64(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP64* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
|
|
@ -171,26 +171,26 @@ inline void bgc_matrix2x2_convert_fp32_to_fp64(const bgc_matrix2x2_fp32_t* from,
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
inline float bgc_matrix2x2_get_determinant_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_matrix2x2_get_determinant_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Singular ================== //
|
// ================== Singular ================== //
|
||||||
|
|
||||||
inline int bgc_matrix2x2_is_singular_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_matrix2x2_is_singular_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
|
|
@ -199,14 +199,14 @@ inline int bgc_matrix2x2_is_singular_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// =============== Transposition ================ //
|
// =============== Transposition ================ //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_transpose_fp32(bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_transpose_fp64(bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
const double tmp = matrix->r1c2;
|
const double tmp = matrix->r1c2;
|
||||||
matrix->r1c2 = matrix->r2c1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
|
|
@ -215,7 +215,7 @@ inline void bgc_matrix2x2_transpose_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// ================= Inversion ================== //
|
// ================= Inversion ================== //
|
||||||
|
|
||||||
inline int bgc_matrix2x2_invert_fp32(bgc_matrix2x2_fp32_t* matrix)
|
inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
|
|
@ -240,7 +240,7 @@ inline int bgc_matrix2x2_invert_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_matrix2x2_invert_fp64(bgc_matrix2x2_fp64_t* matrix)
|
inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
|
|
@ -267,7 +267,7 @@ inline int bgc_matrix2x2_invert_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||||
|
|
||||||
// =============== Set Transposed =============== //
|
// =============== Set Transposed =============== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_transposed_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
inline void bgc_matrix2x2_set_transposed_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
||||||
{
|
{
|
||||||
float tmp = from->r1c2;
|
float tmp = from->r1c2;
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ inline void bgc_matrix2x2_set_transposed_fp32(const bgc_matrix2x2_fp32_t* from,
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_transposed_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
inline void bgc_matrix2x2_set_transposed_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
||||||
{
|
{
|
||||||
double tmp = from->r1c2;
|
double tmp = from->r1c2;
|
||||||
|
|
||||||
|
|
@ -291,7 +291,7 @@ inline void bgc_matrix2x2_set_transposed_fp64(const bgc_matrix2x2_fp64_t* from,
|
||||||
|
|
||||||
// ================ Set Inverted ================ //
|
// ================ Set Inverted ================ //
|
||||||
|
|
||||||
inline int bgc_matrix2x2_set_inverted_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
inline int bgc_matrix2x2_set_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
||||||
{
|
{
|
||||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
||||||
|
|
||||||
|
|
@ -316,7 +316,7 @@ inline int bgc_matrix2x2_set_inverted_fp32(const bgc_matrix2x2_fp32_t* from, bgc
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_matrix2x2_set_inverted_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
inline int bgc_matrix2x2_set_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
||||||
{
|
{
|
||||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
||||||
|
|
||||||
|
|
@ -343,13 +343,13 @@ inline int bgc_matrix2x2_set_inverted_fp64(const bgc_matrix2x2_fp64_t* from, bgc
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = c1;
|
matrix->r1c1 = c1;
|
||||||
matrix->r1c2 = c2;
|
matrix->r1c2 = c2;
|
||||||
|
|
@ -357,13 +357,13 @@ inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, bgc_ma
|
||||||
|
|
||||||
// ================= Set Row 2 ================== //
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = c1;
|
matrix->r2c1 = c1;
|
||||||
matrix->r2c2 = c2;
|
matrix->r2c2 = c2;
|
||||||
|
|
@ -371,13 +371,13 @@ inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, bgc_ma
|
||||||
|
|
||||||
// ================ Set Column 1 ================ //
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = r1;
|
matrix->r1c1 = r1;
|
||||||
matrix->r2c1 = r2;
|
matrix->r2c1 = r2;
|
||||||
|
|
@ -385,13 +385,13 @@ inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, bgc
|
||||||
|
|
||||||
// ================ Set Column 2 ================ //
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, bgc_matrix2x2_fp32_t* matrix)
|
inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, bgc_matrix2x2_fp64_t* matrix)
|
inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = r1;
|
matrix->r1c2 = r1;
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
|
|
@ -399,7 +399,7 @@ inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, bgc
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_add_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bgc_matrix2x2_fp32_t* matrix2, bgc_matrix2x2_fp32_t* sum)
|
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
@ -408,7 +408,7 @@ inline void bgc_matrix2x2_add_fp32(const bgc_matrix2x2_fp32_t* matrix1, const bg
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_add_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bgc_matrix2x2_fp64_t* matrix2, bgc_matrix2x2_fp64_t* sum)
|
inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
@ -419,7 +419,7 @@ inline void bgc_matrix2x2_add_fp64(const bgc_matrix2x2_fp64_t* matrix1, const bg
|
||||||
|
|
||||||
// ================= Add scaled ================= //
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_add_scaled_fp32(const bgc_matrix2x2_fp32_t* basic_matrix, const bgc_matrix2x2_fp32_t* scalable_matrix, const float scale, bgc_matrix2x2_fp32_t* sum)
|
inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
@ -428,7 +428,7 @@ inline void bgc_matrix2x2_add_scaled_fp32(const bgc_matrix2x2_fp32_t* basic_matr
|
||||||
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_add_scaled_fp64(const bgc_matrix2x2_fp64_t* basic_matrix, const bgc_matrix2x2_fp64_t* scalable_matrix, const double scale, bgc_matrix2x2_fp64_t* sum)
|
inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* sum)
|
||||||
{
|
{
|
||||||
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
@ -439,7 +439,7 @@ inline void bgc_matrix2x2_add_scaled_fp64(const bgc_matrix2x2_fp64_t* basic_matr
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||