Добавление функций среднего от 2 и от 3 для матриц, добавление функций альтернативного двойного векторного произведения векторов.

This commit is contained in:
Andrey Pokidov 2026-02-23 22:30:22 +07:00
parent 3b7aa5088b
commit bba8a65c1a
10 changed files with 258 additions and 1 deletions

View file

@ -505,6 +505,7 @@ inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* product, const
// ============ Double Cross Product ============ //
// [a x [b x c]] = b * (a, c) - c * (a, b)
inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
{
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
@ -515,6 +516,7 @@ inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const B
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
}
// [a x [b x c]] = b * (a, c) - c * (a, b)
inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
{
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
@ -525,6 +527,30 @@ inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const B
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
}
// ====== Alternative Double Cross Product ====== //
// [[a x b] x c] = - [c x [a x b]] = -(a * (c, b) - b * (c, a)) = b * (a, c) - a * (b, c)
inline void bgc_fp32_vector3_get_alternative_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
{
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
const float bc = bgc_fp32_vector3_get_dot_product(vector2, vector3);
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
}
// [[a x b] x c] = - [c x [a x b]] = -(a * (b, c) - b * (a, c)) = b * (a, c) - a * (b, c)
inline void bgc_fp64_vector3_get_alternative_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
{
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
const double bc = bgc_fp64_vector3_get_dot_product(vector2, vector3);
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
}
// =================== Angle ==================== //
float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const int angle_unit);