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

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

@ -76,12 +76,12 @@ inline double bgc_fp64_vector3_get_modulus(const BGC_FP64_Vector3* vector)
inline int bgc_fp32_vector3_is_zero(const BGC_FP32_Vector3* vector)
{
return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON;
return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSILON;
}
inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector)
{
return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON;
return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSILON;
}
inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector)
@ -326,7 +326,7 @@ inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* 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;
}
@ -347,7 +347,7 @@ inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* 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;
}
@ -369,7 +369,7 @@ inline int bgc_fp32_vector3_get_normalized(BGC_FP32_Vector3* 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_vector3_reset(normalized);
return 0;
}
@ -387,7 +387,7 @@ inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* 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_vector3_reset(normalized);
return 0;
}
@ -528,11 +528,11 @@ inline int bgc_fp32_vector3_are_close(const BGC_FP32_Vector3* vector1, const BGC
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_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_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
@ -541,11 +541,11 @@ inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC
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_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;
}
// ================== Parallel ================== //
@ -555,7 +555,7 @@ inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const
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_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
@ -563,7 +563,7 @@ inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const
bgc_fp32_vector3_get_cross_product(&product, vector1, vector2);
return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
@ -571,7 +571,7 @@ inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const
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_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
@ -579,7 +579,7 @@ inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const
bgc_fp64_vector3_get_cross_product(&product, vector1, vector2);
return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2;
}
// ================= Orthogonal ================= //
@ -589,13 +589,13 @@ inline int bgc_fp32_vector3_are_orthogonal(const BGC_FP32_Vector3* vector1, cons
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_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) {
return 1;
}
const float scalar_product = bgc_fp32_vector3_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_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
@ -603,13 +603,13 @@ inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, cons
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_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) {
return 1;
}
const double scalar_product = bgc_fp64_vector3_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;
}
// ================== Attitude ================== //
@ -619,11 +619,11 @@ inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const
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_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_vector3_get_dot_product(vector1, vector2);
@ -647,11 +647,11 @@ inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const
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_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_vector3_get_dot_product(vector1, vector2);