Исправление существовавших и добавление новых функций сравнения
This commit is contained in:
parent
847c022533
commit
421ca77cb4
15 changed files with 174 additions and 74 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Basic Geometry
|
# Basic Geometry Computations
|
||||||
|
|
||||||
## Library of basic geometric computations
|
## Library of basic geometric computations for C
|
||||||
|
|
||||||
[Версия на русском языке / Russian version](./README.md)
|
[Версия на русском языке / Russian version](./README.md)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Basic Geometry
|
# Basic Geometry Computations
|
||||||
|
|
||||||
## Библиотека базовых геометрических вычислений
|
## Библиотека базовых геометрических вычислений для Си
|
||||||
|
|
||||||
(English: library of basic geometric computations)
|
(English: library of basic geometric computations)
|
||||||
|
|
||||||
|
|
@ -36,5 +36,5 @@
|
||||||
типа **float**, а другая - для данных типа **double**. Но между этими половинами
|
типа **float**, а другая - для данных типа **double**. Но между этими половинами
|
||||||
есть мостики - функции преобразования типа.
|
есть мостики - функции преобразования типа.
|
||||||
|
|
||||||
Однако в библиотеке нет функций, которые используют для вычисления данные разных
|
Однако в библиотеке мало функций, которые используют для вычисления данные разных
|
||||||
типов (**float** и *double* одновременно).
|
типов (**float** и **double** одновременно).
|
||||||
|
|
@ -59,3 +59,6 @@ extern inline void bgc_quaternion_divide_fp64(const BgcQuaternionFP64* dividend,
|
||||||
|
|
||||||
extern inline void bgc_quaternion_get_product_fp32(const BgcQuaternionFP32* left, const BgcQuaternionFP32* right, BgcQuaternionFP32* product);
|
extern inline void bgc_quaternion_get_product_fp32(const BgcQuaternionFP32* left, const BgcQuaternionFP32* right, BgcQuaternionFP32* product);
|
||||||
extern inline void bgc_quaternion_get_product_fp64(const BgcQuaternionFP64* left, const BgcQuaternionFP64* right, BgcQuaternionFP64* product);
|
extern inline void bgc_quaternion_get_product_fp64(const BgcQuaternionFP64* left, const BgcQuaternionFP64* right, BgcQuaternionFP64* product);
|
||||||
|
|
||||||
|
extern inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2);
|
||||||
|
extern inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2);
|
||||||
|
|
|
||||||
|
|
@ -535,4 +535,42 @@ inline void bgc_quaternion_get_product_fp64(const BgcQuaternionFP64* left, const
|
||||||
product->x3 = x3;
|
product->x3 = x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================== Are Close ================= //
|
||||||
|
|
||||||
|
inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2)
|
||||||
|
{
|
||||||
|
const float ds0 = quaternion1->s0 - quaternion2->s0;
|
||||||
|
const float dx1 = quaternion1->x1 - quaternion2->x1;
|
||||||
|
const float dx2 = quaternion1->x2 - quaternion2->x2;
|
||||||
|
const float dx3 = quaternion1->x3 - quaternion2->x3;
|
||||||
|
|
||||||
|
const float square_modulus1 = bgc_quaternion_get_square_modulus_fp32(quaternion1);
|
||||||
|
const float square_modulus2 = bgc_quaternion_get_square_modulus_fp32(quaternion2);
|
||||||
|
const float square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3);
|
||||||
|
|
||||||
|
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) {
|
||||||
|
return square_distance <= BGC_SQUARE_EPSYLON_FP32;
|
||||||
|
}
|
||||||
|
|
||||||