Небольшие исправления, а также добавление гомогенного трёхмерного вектора

This commit is contained in:
Andrey Pokidov 2026-02-02 20:44:10 +07:00
parent 03627f4401
commit 043cc72c81
25 changed files with 1686 additions and 1644 deletions

View file

@ -70,12 +70,12 @@ inline double bgc_fp64_vector2_get_modulus(const BGC_FP64_Vector2* vector)
inline int bgc_fp32_vector2_is_zero(const BGC_FP32_Vector2* vector)
{
return bgc_fp32_vector2_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON;
return bgc_fp32_vector2_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSILON;
}
inline int bgc_fp64_vector2_is_zero(const BGC_FP64_Vector2* vector)
{
return bgc_fp64_vector2_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON;
return bgc_fp64_vector2_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSILON;
}
inline int bgc_fp32_vector2_is_unit(const BGC_FP32_Vector2* vector)
@ -292,7 +292,7 @@ inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* vector)
return 1;
}
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -312,7 +312,7 @@ inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector)
return 1;
}
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
}
@ -333,7 +333,7 @@ inline int bgc_fp32_vector2_get_normalized(BGC_FP32_Vector2* normalized, const B
return 1;
}
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
bgc_fp32_vector2_reset(normalized);
return 0;
}
@ -351,7 +351,7 @@ inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* normalized, const B
return 1;
}
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
bgc_fp64_vector2_reset(normalized);
return 0;
}
@ -440,11 +440,11 @@ inline int bgc_fp32_vector2_are_close(const BGC_FP32_Vector2* vector1, const BGC
const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
const float square_distance = bgc_fp32_vector2_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP32_SQUARE_EPSYLON;
if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP32_SQUARE_EPSILON;
}
return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2;
}
inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
@ -453,11 +453,11 @@ inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC
const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
const double square_distance = bgc_fp64_vector2_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP64_SQUARE_EPSYLON;
if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP64_SQUARE_EPSILON;
}
return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2;
}
@ -467,38 +467,38 @@ inline int bgc_fp32_vector2_are_parallel(const BGC_FP32_Vector2* vector1, const
{
const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
const float cross_product = bgc_fp32_vector2_get_cross_product(vector1, vector2);
return cross_product * cross_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return cross_product * cross_product <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
inline int bgc_fp64_vector2_are_parallel(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{
const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
const double cross_product = bgc_fp64_vector2_get_cross_product(vector1, vector2);
return cross_product * cross_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return cross_product * cross_product <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
// ================= Orthogonal ================= //
@ -507,38 +507,38 @@ inline int bgc_fp32_vector2_are_orthogonal(const BGC_FP32_Vector2* vector1, cons
{
const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
inline int bgc_fp64_vector2_are_orthogonal(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{
const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
@ -549,11 +549,11 @@ inline int bgc_fp32_vector2_get_attitude(const BGC_FP32_Vector2* vector1, const
const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) {
return BGC_ATTITUDE_ZERO;
}
const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const float square_limit = BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2;
const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2);
@ -575,11 +575,11 @@ inline int bgc_fp64_vector2_get_attitude(const BGC_FP64_Vector2* vector1, const
const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) {
return BGC_ATTITUDE_ZERO;
}
const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const double square_limit = BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2;
const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2);