Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -11,23 +11,23 @@
|
|||
typedef struct
|
||||
{
|
||||
float x1, x2, x3;
|
||||
} BgcVector3FP32;
|
||||
} BGC_FP32_Vector3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x1, x2, x3;
|
||||
} BgcVector3FP64;
|
||||
} BGC_FP64_Vector3;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector)
|
||||
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector)
|
||||
{
|
||||
vector->x1 = 0.0f;
|
||||
vector->x2 = 0.0f;
|
||||
vector->x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector)
|
||||
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector)
|
||||
{
|
||||
vector->x1 = 0.0;
|
||||
vector->x2 = 0.0;
|
||||
|
|
@ -36,14 +36,14 @@ inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* destination)
|
||||
inline void bgc_fp32_vector3_make(const float x1, const float x2, const float x3, BGC_FP32_Vector3* destination)
|
||||
{
|
||||
destination->x1 = x1;
|
||||
destination->x2 = x2;
|
||||
destination->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* destination)
|
||||
inline void bgc_fp64_vector3_make(const double x1, const double x2, const double x3, BGC_FP64_Vector3* destination)
|
||||
{
|
||||
destination->x1 = x1;
|
||||
destination->x2 = x2;
|
||||
|
|
@ -52,58 +52,58 @@ inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const
|
|||
|
||||
// ================== Modulus =================== //
|
||||
|
||||
inline float bgc_vector3_get_square_modulus_fp32(const BgcVector3FP32* vector)
|
||||
inline float bgc_fp32_vector3_get_square_modulus(const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_square_modulus_fp64(const BgcVector3FP64* vector)
|
||||
inline double bgc_fp64_vector3_get_square_modulus(const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
|
||||
}
|
||||
|
||||
inline float bgc_vector3_get_modulus_fp32(const BgcVector3FP32* vector)
|
||||
inline float bgc_fp32_vector3_get_modulus(const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
return sqrtf(bgc_vector3_get_square_modulus_fp32(vector));
|
||||
return sqrtf(bgc_fp32_vector3_get_square_modulus(vector));
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_modulus_fp64(const BgcVector3FP64* vector)
|
||||
inline double bgc_fp64_vector3_get_modulus(const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
return sqrt(bgc_vector3_get_square_modulus_fp64(vector));
|
||||
return sqrt(bgc_fp64_vector3_get_square_modulus(vector));
|
||||
}
|
||||
|
||||
// ================= Comparison ================= //
|
||||
|
||||
inline int bgc_vector3_is_zero_fp32(const BgcVector3FP32* vector)
|
||||
inline int bgc_fp32_vector3_is_zero(const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
return bgc_vector3_get_square_modulus_fp32(vector) <= BGC_SQUARE_EPSYLON_FP32;
|
||||
return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_is_zero_fp64(const BgcVector3FP64* vector)
|
||||
inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
return bgc_vector3_get_square_modulus_fp64(vector) <= BGC_SQUARE_EPSYLON_FP64;
|
||||
return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_is_unit_fp32(const BgcVector3FP32* vector)
|
||||
inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector)
|
||||
{
|
||||
return bgc_is_sqare_unit_fp32(bgc_vector3_get_square_modulus_fp32(vector));
|
||||
return bgc_fp32_is_square_unit(bgc_fp32_vector3_get_square_modulus(vector));
|
||||
}
|
||||
|
||||
inline int bgc_vector3_is_unit_fp64(const BgcVector3FP64* vector)
|
||||
inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* vector)
|
||||
{
|
||||
return bgc_is_sqare_unit_fp64(bgc_vector3_get_square_modulus_fp64(vector));
|
||||
return bgc_fp64_is_square_unit(bgc_fp64_vector3_get_square_modulus(vector));
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* source, BgcVector3FP32* destination)
|
||||
inline void bgc_fp32_vector3_copy(const BGC_FP32_Vector3* source, BGC_FP32_Vector3* destination)
|
||||
{
|
||||
destination->x1 = source->x1;
|
||||
destination->x2 = source->x2;
|
||||
destination->x3 = source->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* source, BgcVector3FP64* destination)
|
||||
inline void bgc_fp64_vector3_copy(const BGC_FP64_Vector3* source, BGC_FP64_Vector3* destination)
|
||||
{
|
||||
destination->x1 = source->x1;
|
||||
destination->x2 = source->x2;
|
||||
|
|
@ -112,7 +112,7 @@ inline void bgc_vector3_copy_fp64(const BgcVector3FP64* source, BgcVector3FP64*
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2)
|
||||
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* vector1, BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float x1 = vector2->x1;
|
||||
const float x2 = vector2->x2;
|
||||
|
|
@ -127,7 +127,7 @@ inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vecto
|
|||
vector1->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2)
|
||||
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* vector1, BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double x1 = vector2->x1;
|
||||
const double x2 = vector2->x2;
|
||||
|
|
@ -144,14 +144,14 @@ inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vecto
|
|||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_vector3_convert_fp64_to_fp32(const BgcVector3FP64* source, BgcVector3FP32* destination)
|
||||
inline void bgc_fp64_vector3_convert_to_fp32(const BGC_FP64_Vector3* source, BGC_FP32_Vector3* destination)
|
||||
{
|
||||
destination->x1 = (float)source->x1;
|
||||
destination->x2 = (float)source->x2;
|
||||
destination->x3 = (float)source->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_convert_fp32_to_fp64(const BgcVector3FP32* source, BgcVector3FP64* destination)
|
||||
inline void bgc_fp32_vector3_convert_to_fp64(const BGC_FP32_Vector3* source, BGC_FP64_Vector3* destination)
|
||||
{
|
||||
destination->x1 = source->x1;
|
||||
destination->x2 = source->x2;
|
||||
|
|
@ -160,14 +160,14 @@ inline void bgc_vector3_convert_fp32_to_fp64(const BgcVector3FP32* source, BgcVe
|
|||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
inline void bgc_vector3_add_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* sum)
|
||||
inline void bgc_fp32_vector3_add(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* sum)
|
||||
{
|
||||
sum->x1 = vector1->x1 + vector2->x1;
|
||||
sum->x2 = vector1->x2 + vector2->x2;
|
||||
sum->x3 = vector1->x3 + vector2->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_add_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* sum)
|
||||
inline void bgc_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* sum)
|
||||
{
|
||||
sum->x1 = vector1->x1 + vector2->x1;
|
||||
sum->x2 = vector1->x2 + vector2->x2;
|
||||
|
|
@ -176,14 +176,14 @@ inline void bgc_vector3_add_fp64(const BgcVector3FP64* vector1, const BgcVector3
|
|||
|
||||
// ================= Add scaled ================= //
|
||||
|
||||
inline void bgc_vector3_add_scaled_fp32(const BgcVector3FP32* basic_vector, const BgcVector3FP32* scalable_vector, const float scale, BgcVector3FP32* sum)
|
||||
inline void bgc_fp32_vector3_add_scaled(const BGC_FP32_Vector3* basic_vector, const BGC_FP32_Vector3* scalable_vector, const float scale, BGC_FP32_Vector3* sum)
|
||||
{
|
||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
||||
sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_add_scaled_fp64(const BgcVector3FP64* basic_vector, const BgcVector3FP64* scalable_vector, const double scale, BgcVector3FP64* sum)
|
||||
inline void bgc_fp64_vector3_add_scaled(const BGC_FP64_Vector3* basic_vector, const BGC_FP64_Vector3* scalable_vector, const double scale, BGC_FP64_Vector3* sum)
|
||||
{
|
||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
||||
|
|
@ -192,14 +192,14 @@ inline void bgc_vector3_add_scaled_fp64(const BgcVector3FP64* basic_vector, cons
|
|||
|
||||
// ================== Subtract ================== //
|
||||
|
||||
inline void bgc_vector3_subtract_fp32(const BgcVector3FP32* minuend, const BgcVector3FP32* subtrahend, BgcVector3FP32* difference)
|
||||
inline void bgc_fp32_vector3_subtract(const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend, BGC_FP32_Vector3* difference)
|
||||
{
|
||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
||||
difference->x3 = minuend->x3 - subtrahend->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_subtract_fp64(const BgcVector3FP64* minuend, const BgcVector3FP64* subtrahend, BgcVector3FP64* difference)
|
||||
inline void bgc_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend, BGC_FP64_Vector3* difference)
|
||||
{
|
||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
||||
|
|
@ -208,14 +208,14 @@ inline void bgc_vector3_subtract_fp64(const BgcVector3FP64* minuend, const BgcVe
|
|||
|
||||
// ================== Multiply ================== //
|
||||
|
||||
inline void bgc_vector3_multiply_fp32(const BgcVector3FP32* multiplicand, const float multiplier, BgcVector3FP32* product)
|
||||
inline void bgc_fp32_vector3_multiply(const BGC_FP32_Vector3* multiplicand, const float multiplier, BGC_FP32_Vector3* product)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
product->x3 = multiplicand->x3 * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_multiply_fp64(const BgcVector3FP64* multiplicand, const double multiplier, BgcVector3FP64* product)
|
||||
inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, const double multiplier, BGC_FP64_Vector3* product)
|
||||
{
|
||||
product->x1 = multiplicand->x1 * multiplier;
|
||||
product->x2 = multiplicand->x2 * multiplier;
|
||||
|
|
@ -224,109 +224,109 @@ inline void bgc_vector3_multiply_fp64(const BgcVector3FP64* multiplicand, const
|
|||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline void bgc_vector3_divide_fp32(const BgcVector3FP32* dividend, const float divisor, BgcVector3FP32* quotient)
|
||||
inline void bgc_fp32_vector3_divide(const BGC_FP32_Vector3* dividend, const float divisor, BGC_FP32_Vector3* quotient)
|
||||
{
|
||||
bgc_vector3_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||
bgc_fp32_vector3_multiply(dividend, 1.0f / divisor, quotient);
|
||||
}
|
||||
|
||||
inline void bgc_vector3_divide_fp64(const BgcVector3FP64* dividend, const double divisor, BgcVector3FP64* quotient)
|
||||
inline void bgc_fp64_vector3_divide(const BGC_FP64_Vector3* dividend, const double divisor, BGC_FP64_Vector3* quotient)
|
||||
{
|
||||
bgc_vector3_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||
bgc_fp64_vector3_multiply(dividend, 1.0 / divisor, quotient);
|
||||
}
|
||||
|
||||
// ================== Average2 ================== //
|
||||
|
||||
inline void bgc_vector3_get_mean_of_two_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* mean)
|
||||
inline void bgc_fp32_vector3_get_middle2(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* middle)
|
||||
{
|
||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
|
||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f;
|
||||
mean->x3 = (vector1->x3 + vector2->x3) * 0.5f;
|
||||
middle->x1 = (vector1->x1 + vector2->x1) * 0.5f;
|
||||
middle->x2 = (vector1->x2 + vector2->x2) * 0.5f;
|
||||
middle->x3 = (vector1->x3 + vector2->x3) * 0.5f;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_mean_of_two_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* mean)
|
||||
inline void bgc_fp64_vector3_get_middle2(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* middle)
|
||||
{
|
||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5;
|
||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5;
|
||||
mean->x3 = (vector1->x3 + vector2->x3) * 0.5;
|
||||
middle->x1 = (vector1->x1 + vector2->x1) * 0.5;
|
||||
middle->x2 = (vector1->x2 + vector2->x2) * 0.5;
|
||||
middle->x3 = (vector1->x3 + vector2->x3) * 0.5;
|
||||
}
|
||||
|
||||
// ================== Average3 ================== //
|
||||
|
||||
inline void bgc_vector3_get_mean_of_three_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* mean)
|
||||
inline void bgc_fp32_vector3_get_middle3(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* middle)
|
||||
{
|
||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP32;
|
||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP32;
|
||||
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP32;
|
||||
middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
|
||||
middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
|
||||
middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_mean_of_three_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* mean)
|
||||
inline void bgc_fp64_vector3_get_middle3(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* middle)
|
||||
{
|
||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP64;
|
||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP64;
|
||||
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP64;
|
||||
middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
|
||||
middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
|
||||
middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD;
|
||||
}
|
||||
|
||||
// =================== Linear =================== //
|
||||
|
||||
inline void bgc_vector3_interpolate_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float phase, BgcVector3FP32* interpolation)
|
||||
inline void bgc_fp32_vector3_interpolate(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase, BGC_FP32_Vector3* interpolation)
|
||||
{
|
||||
const float counterphase = 1.0f - phase;
|
||||
const float counter_phase = 1.0f - phase;
|
||||
|
||||
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase;
|
||||
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase;
|
||||
interpolation->x3 = vector1->x3 * counterphase + vector2->x3 * phase;
|
||||
interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
|
||||
interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
|
||||
interpolation->x3 = vector1->x3 * counter_phase + vector2->x3 * phase;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_interpolate_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double phase, BgcVector3FP64* interpolation)
|
||||
inline void bgc_fp64_vector3_interpolate(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase, BGC_FP64_Vector3* interpolation)
|
||||
{
|
||||
const double counterphase = 1.0 - phase;
|
||||
const double counter_phase = 1.0 - phase;
|
||||
|
||||
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase;
|
||||
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase;
|
||||
interpolation->x3 = vector1->x3 * counterphase + vector2->x3 * phase;
|
||||
interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
|
||||
interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
|
||||
interpolation->x3 = vector1->x3 * counter_phase + vector2->x3 * phase;
|
||||
}
|
||||
|
||||
// ================== Negative ================== //
|
||||
|
||||
inline void bgc_vector3_make_opposite_fp32(BgcVector3FP32* vector)
|
||||
inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* vector)
|
||||
{
|
||||
vector->x1 = -vector->x1;
|
||||
vector->x2 = -vector->x2;
|
||||
vector->x3 = -vector->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_make_opposite_fp64(BgcVector3FP64* vector)
|
||||
inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* vector)
|
||||
{
|
||||
vector->x1 = -vector->x1;
|
||||
vector->x2 = -vector->x2;
|
||||
vector->x3 = -vector->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_opposite_fp32(const BgcVector3FP32* vector, BgcVector3FP32* opposite)
|
||||
inline void bgc_fp32_vector3_get_reverse(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* reverse)
|
||||
{
|
||||
opposite->x1 = -vector->x1;
|
||||
opposite->x2 = -vector->x2;
|
||||
opposite->x3 = -vector->x3;
|
||||
reverse->x1 = -vector->x1;
|
||||
reverse->x2 = -vector->x2;
|
||||
reverse->x3 = -vector->x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_opposite_fp64(const BgcVector3FP64* vector, BgcVector3FP64* opposite)
|
||||
inline void bgc_fp64_vector3_get_reverse(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* reverse)
|
||||
{
|
||||
opposite->x1 = -vector->x1;
|
||||
opposite->x2 = -vector->x2;
|
||||
opposite->x3 = -vector->x3;
|
||||
reverse->x1 = -vector->x1;
|
||||
reverse->x2 = -vector->x2;
|
||||
reverse->x3 = -vector->x3;
|
||||
}
|
||||
|
||||
// ================= Normalize ================== //
|
||||
|
||||
inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector)
|
||||
inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* vector)
|
||||
{
|
||||
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector);
|
||||
const float square_modulus = bgc_fp32_vector3_get_square_modulus(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
if (bgc_fp32_is_square_unit(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -339,15 +339,15 @@ inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector)
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector)
|
||||
inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector)
|
||||
{
|
||||
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector);
|
||||
const double square_modulus = bgc_fp64_vector3_get_square_modulus(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
if (bgc_fp64_is_square_unit(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -360,64 +360,64 @@ inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector)
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_get_normalized_fp32(const BgcVector3FP32* vector, BgcVector3FP32* normalized)
|
||||
inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* normalized)
|
||||
{
|
||||
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector);
|
||||
const float square_modulus = bgc_fp32_vector3_get_square_modulus(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
bgc_vector3_copy_fp32(vector, normalized);
|
||||
if (bgc_fp32_is_square_unit(square_modulus)) {
|
||||
bgc_fp32_vector3_copy(vector, normalized);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
bgc_vector3_reset_fp32(normalized);
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
bgc_fp32_vector3_reset(normalized);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_vector3_multiply_fp32(vector, sqrtf(1.0f / square_modulus), normalized);
|
||||
bgc_fp32_vector3_multiply(vector, sqrtf(1.0f / square_modulus), normalized);
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_get_normalized_fp64(const BgcVector3FP64* vector, BgcVector3FP64* normalized)
|
||||
inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* normalized)
|
||||
{
|
||||
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector);
|
||||
const double square_modulus = bgc_fp64_vector3_get_square_modulus(vector);
|
||||
|
||||
if (bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
bgc_vector3_copy_fp64(vector, normalized);
|
||||
if (bgc_fp64_is_square_unit(square_modulus)) {
|
||||
bgc_fp64_vector3_copy(vector, normalized);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
bgc_vector3_reset_fp64(normalized);
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
bgc_fp64_vector3_reset(normalized);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bgc_vector3_multiply_fp64(vector, sqrt(1.0 / square_modulus), normalized);
|
||||
bgc_fp64_vector3_multiply(vector, sqrt(1.0 / square_modulus), normalized);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// =============== Scalar Product =============== //
|
||||
|
||||
inline float bgc_vector3_get_scalar_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_scalar_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
|
||||
}
|
||||
|
||||
// =============== Triple Product =============== //
|
||||
|
||||
inline float bgc_vector3_get_triple_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3)
|
||||
inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
|
||||
{
|
||||
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
|
||||
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
|
||||
+ vector1->x3 * (vector2->x1 * vector3->x2 - vector2->x2 * vector3->x1);
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_triple_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3)
|
||||
inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
|
||||
{
|
||||
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
|
||||
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
|
||||
|
|
@ -426,7 +426,7 @@ inline double bgc_vector3_get_triple_product_fp64(const BgcVector3FP64* vector1,
|
|||
|
||||
// =============== Cross Product ================ //
|
||||
|
||||
inline void bgc_vector3_get_cross_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* product)
|
||||
inline void bgc_fp32_vector3_get_cross_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* product)
|
||||
{
|
||||
const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
||||
const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
||||
|
|
@ -437,7 +437,7 @@ inline void bgc_vector3_get_cross_product_fp32(const BgcVector3FP32* vector1, co
|
|||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_cross_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* product)
|
||||
inline void bgc_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* product)
|
||||
{
|
||||
const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
||||
const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
||||
|
|
@ -450,20 +450,20 @@ inline void bgc_vector3_get_cross_product_fp64(const BgcVector3FP64* vector1, co
|
|||
|
||||
// ============ Double Cross Product ============ //
|
||||
|
||||
inline void bgc_vector3_get_double_cross_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* product)
|
||||
inline void bgc_fp32_vector3_get_double_cross(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* product)
|
||||
{
|
||||
const float ac = bgc_vector3_get_scalar_product_fp32(vector1, vector3);
|
||||
const float ab = bgc_vector3_get_scalar_product_fp32(vector1, vector2);
|
||||
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
|
||||
const float ab = bgc_fp32_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
product->x1 = vector2->x1 * ac - vector3->x1 * ab;
|
||||
product->x2 = vector2->x2 * ac - vector3->x2 * ab;
|
||||
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
|
||||
}
|
||||
|
||||
inline void bgc_vector3_get_double_cross_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* product)
|
||||
inline void bgc_fp64_vector3_get_double_cross(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* product)
|
||||
{
|
||||
const double ac = bgc_vector3_get_scalar_product_fp64(vector1, vector3);
|
||||
const double ab = bgc_vector3_get_scalar_product_fp64(vector1, vector2);
|
||||
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
|
||||
const double ab = bgc_fp64_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
product->x1 = vector2->x1 * ac - vector3->x1 * ab;
|
||||
product->x2 = vector2->x2 * ac - vector3->x2 * ab;
|
||||
|
|
@ -472,13 +472,13 @@ inline void bgc_vector3_get_double_cross_fp64(const BgcVector3FP64* vector1, con
|
|||
|
||||
// =================== Angle ==================== //
|
||||
|
||||
float bgc_vector3_get_angle_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcAngleUnitEnum angle_unit);
|
||||
float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const int angle_unit);
|
||||
|
||||
double bgc_vector3_get_angle_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcAngleUnitEnum angle_unit);
|
||||
double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const int angle_unit);
|
||||
|
||||
// =============== Square Distance ============== //
|
||||
|
||||
inline float bgc_vector3_get_square_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float dx1 = (vector1->x1 - vector2->x1);
|
||||
const float dx2 = (vector1->x2 - vector2->x2);
|
||||
|
|
@ -487,7 +487,7 @@ inline float bgc_vector3_get_square_distance_fp32(const BgcVector3FP32* vector1,
|
|||
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_square_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double dx1 = (vector1->x1 - vector2->x1);
|
||||
const double dx2 = (vector1->x2 - vector2->x2);
|
||||
|
|
@ -498,172 +498,172 @@ inline double bgc_vector3_get_square_distance_fp64(const BgcVector3FP64* vector1
|
|||
|
||||
// ================== Distance ================== //
|
||||
|
||||
inline float bgc_vector3_get_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline float bgc_fp32_vector3_get_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
return sqrtf(bgc_vector3_get_square_distance_fp32(vector1, vector2));
|
||||
return sqrtf(bgc_fp32_vector3_get_square_distance(vector1, vector2));
|
||||
}
|
||||
|
||||
inline double bgc_vector3_get_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline double bgc_fp64_vector3_get_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
return sqrt(bgc_vector3_get_square_distance_fp64(vector1, vector2));
|
||||
return sqrt(bgc_fp64_vector3_get_square_distance(vector1, vector2));
|
||||
}
|
||||
|
||||
// ============== Are Close Enough ============== //
|
||||
|
||||
inline int bgc_vector3_are_close_enough_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float distance_limit)
|
||||
inline int bgc_fp32_vector3_are_close_enough(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float distance_limit)
|
||||
{
|
||||
return bgc_vector3_get_square_distance_fp32(vector1, vector2) <= distance_limit * distance_limit;
|
||||
return bgc_fp32_vector3_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_are_close_enough_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double distance_limit)
|
||||
inline int bgc_fp64_vector3_are_close_enough(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double distance_limit)
|
||||
{
|
||||
return bgc_vector3_get_square_distance_fp64(vector1, vector2) <= distance_limit * distance_limit;
|
||||
return bgc_fp64_vector3_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
|
||||
}
|
||||
|
||||
// ================== Are Close ================= //
|
||||
|
||||
inline int bgc_vector3_are_close_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline int bgc_fp32_vector3_are_close(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1);
|
||||
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2);
|
||||
const float square_distance = bgc_vector3_get_square_distance_fp32(vector1, vector2);
|
||||
const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
|
||||
const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
|
||||
const float square_distance = bgc_fp32_vector3_get_square_distance(vector1, vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) {
|
||||
return square_distance <= BGC_SQUARE_EPSYLON_FP32;
|
||||
if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2;
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_are_close_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1);
|
||||
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2);
|
||||
const double square_distance = bgc_vector3_get_square_distance_fp64(vector1, vector2);
|
||||
const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
|
||||
const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
|
||||
const double square_distance = bgc_fp64_vector3_get_square_distance(vector1, vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) {
|
||||
return square_distance <= BGC_SQUARE_EPSYLON_FP64;
|
||||
if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2;
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
|
||||
}
|
||||
|
||||
// ================== Parallel ================== //
|
||||
|
||||
inline int bgc_vector3_are_parallel_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1);
|
||||
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2);
|
||||
const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
|
||||
const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
BgcVector3FP32 product;
|
||||
BGC_FP32_Vector3 product;
|
||||
|
||||
bgc_vector3_get_cross_product_fp32(vector1, vector2, &product);
|
||||
bgc_fp32_vector3_get_cross_product(vector1, vector2, &product);
|
||||
|
||||
return bgc_vector3_get_square_modulus_fp32(&product) <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2;
|
||||
return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_are_parallel_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1);
|
||||
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2);
|
||||
const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
|
||||
const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
BgcVector3FP64 product;
|
||||
BGC_FP64_Vector3 product;
|
||||
|
||||
bgc_vector3_get_cross_product_fp64(vector1, vector2, &product);
|
||||
bgc_fp64_vector3_get_cross_product(vector1, vector2, &product);
|
||||
|
||||
return bgc_vector3_get_square_modulus_fp64(&product) <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2;
|
||||
return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
}
|
||||
|
||||
// ================= Orthogonal ================= //
|
||||
|
||||
inline int bgc_vector3_are_orthogonal_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline int bgc_fp32_vector3_are_orthogonal(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1);
|
||||
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2);
|
||||
const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
|
||||
const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const float scalar_product = bgc_vector3_get_scalar_product_fp32(vector1, vector2);
|
||||
const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2;
|
||||
return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_are_orthogonal_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1);
|
||||
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2);
|
||||
const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
|
||||
const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const double scalar_product = bgc_vector3_get_scalar_product_fp64(vector1, vector2);
|
||||
const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2;
|
||||
return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
}
|
||||
|
||||
// ================== Attitude ================== //
|
||||
|
||||
inline int bgc_vector3_get_attitude_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
|
||||
{
|
||||
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1);
|
||||
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2);
|
||||
const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
|
||||
const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
return BGC_ATTITUDE_ZERO;
|
||||
}
|
||||
|
||||
const float square_limit = BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2;
|
||||
const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
|
||||
const float scalar_product = bgc_vector3_get_scalar_product_fp32(vector1, vector2);
|
||||
const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
if (scalar_product * scalar_product <= square_limit) {
|
||||
return BGC_ATTITUDE_ORTHOGONAL;
|
||||
}
|
||||
|
||||
BgcVector3FP32 product;
|
||||
BGC_FP32_Vector3 product;
|
||||
|
||||
bgc_vector3_get_cross_product_fp32(vector1, vector2, &product);
|
||||
bgc_fp32_vector3_get_cross_product(vector1, vector2, &product);
|
||||
|
||||
if (bgc_vector3_get_square_modulus_fp32(&product) > square_limit) {
|
||||
if (bgc_fp32_vector3_get_square_modulus(&product) > square_limit) {
|
||||
return BGC_ATTITUDE_ANY;
|
||||
}
|
||||
|
||||
return scalar_product > 0.0f ? BGC_ATTITUDE_CO_DIRECTIONAL : BGC_ATTITUDE_COUNTER_DIRECTIONAL;
|
||||
}
|
||||
|
||||
inline int bgc_vector3_get_attitude_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2)
|
||||
inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
|
||||
{
|
||||
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1);
|
||||
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2);
|
||||
const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
|
||||
const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
|
||||
|
||||
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
return BGC_ATTITUDE_ZERO;
|
||||
}
|
||||
|
||||
const double square_limit = BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2;
|
||||
const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
|
||||
|
||||
const double scalar_product = bgc_vector3_get_scalar_product_fp64(vector1, vector2);
|
||||
const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2);
|
||||
|
||||
if (scalar_product * scalar_product <= square_limit) {
|
||||
return BGC_ATTITUDE_ORTHOGONAL;
|
||||
}
|
||||
|
||||
BgcVector3FP64 product;
|
||||
BGC_FP64_Vector3 product;
|
||||
|
||||
bgc_vector3_get_cross_product_fp64(vector1, vector2, &product);
|
||||
bgc_fp64_vector3_get_cross_product(vector1, vector2, &product);
|
||||
|
||||
if (bgc_vector3_get_square_modulus_fp64(&product) > square_limit) {
|
||||
if (bgc_fp64_vector3_get_square_modulus(&product) > square_limit) {
|
||||
return BGC_ATTITUDE_ANY;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue