Переименование s0 -> s, x1 -> x, x2 -> y, x3 -> z, что должно упростить читаемость кода. Также обновление документации

This commit is contained in:
Andrey Pokidov 2026-03-29 22:06:01 +07:00
parent d83ab7160d
commit b8d383da33
38 changed files with 2104 additions and 2070 deletions

View file

@ -214,48 +214,48 @@ inline void bgc_fp64_dual_quaternion_get_dual_conjugate(BGC_FP64_DualQuaternion*
inline void bgc_fp32_dual_quaternion_fully_conjugate(BGC_FP32_DualQuaternion* const quaternion)
{
quaternion->real_part.x1 = -quaternion->real_part.x1;
quaternion->real_part.x2 = -quaternion->real_part.x2;
quaternion->real_part.x3 = -quaternion->real_part.x3;
quaternion->real_part.x = -quaternion->real_part.x;
quaternion->real_part.y = -quaternion->real_part.y;
quaternion->real_part.z = -quaternion->real_part.z;
quaternion->dual_part.s0 = -quaternion->dual_part.s0;
quaternion->dual_part.s = -quaternion->dual_part.s;
}
inline void bgc_fp64_dual_quaternion_fully_conjugate(BGC_FP64_DualQuaternion* const quaternion)
{
quaternion->real_part.x1 = -quaternion->real_part.x1;
quaternion->real_part.x2 = -quaternion->real_part.x2;
quaternion->real_part.x3 = -quaternion->real_part.x3;
quaternion->real_part.x = -quaternion->real_part.x;
quaternion->real_part.y = -quaternion->real_part.y;
quaternion->real_part.z = -quaternion->real_part.z;
quaternion->dual_part.s0 = -quaternion->dual_part.s0;
quaternion->dual_part.s = -quaternion->dual_part.s;
}
// ============ Get Fully Conjugate ============= //
inline void bgc_fp32_dual_quaternion_get_fully_conjugate(BGC_FP32_DualQuaternion* const conjugate, const BGC_FP32_DualQuaternion* const quaternion)
{
conjugate->real_part.s0 = quaternion->real_part.s0;
conjugate->real_part.x1 = -quaternion->real_part.x1;
conjugate->real_part.x2 = -quaternion->real_part.x2;
conjugate->real_part.x3 = -quaternion->real_part.x3;
conjugate->real_part.s = quaternion->real_part.s;
conjugate->real_part.x = -quaternion->real_part.x;
conjugate->real_part.y = -quaternion->real_part.y;
conjugate->real_part.z = -quaternion->real_part.z;
conjugate->dual_part.s0 = -quaternion->dual_part.s0;
conjugate->dual_part.x1 = quaternion->dual_part.x1;
conjugate->dual_part.x2 = quaternion->dual_part.x2;
conjugate->dual_part.x3 = quaternion->dual_part.x3;
conjugate->dual_part.s = -quaternion->dual_part.s;
conjugate->dual_part.x = quaternion->dual_part.x;
conjugate->dual_part.y = quaternion->dual_part.y;
conjugate->dual_part.z = quaternion->dual_part.z;
}
inline void bgc_fp64_dual_quaternion_get_fully_conjugate(BGC_FP64_DualQuaternion* const conjugate, const BGC_FP64_DualQuaternion* const quaternion)
{
conjugate->real_part.s0 = quaternion->real_part.s0;
conjugate->real_part.x1 = -quaternion->real_part.x1;
conjugate->real_part.x2 = -quaternion->real_part.x2;
conjugate->real_part.x3 = -quaternion->real_part.x3;
conjugate->real_part.s = quaternion->real_part.s;
conjugate->real_part.x = -quaternion->real_part.x;
conjugate->real_part.y = -quaternion->real_part.y;
conjugate->real_part.z = -quaternion->real_part.z;
conjugate->dual_part.s0 = -quaternion->dual_part.s0;
conjugate->dual_part.x1 = quaternion->dual_part.x1;
conjugate->dual_part.x2 = quaternion->dual_part.x2;
conjugate->dual_part.x3 = quaternion->dual_part.x3;
conjugate->dual_part.s = -quaternion->dual_part.s;
conjugate->dual_part.x = quaternion->dual_part.x;
conjugate->dual_part.y = quaternion->dual_part.y;
conjugate->dual_part.z = quaternion->dual_part.z;
}
// ================= Normalize ================== //

View file

@ -210,64 +210,64 @@ inline void bgc_fp64_dual_vector3_multiply_by_conjugate_dual_number(BGC_FP64_Dua
inline void bgc_fp32_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
{
const float real_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
const float real_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
const float real_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
const float real_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
const float real_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
const float real_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
const float dual_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
const float dual_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
const float dual_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
const float dual_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
const float dual_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
const float dual_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
}
inline void bgc_fp64_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
{
const double real_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
const double real_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
const double real_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
const double real_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
const double real_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
const double real_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
const double dual_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
const double dual_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
const double dual_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
const double dual_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
const double dual_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
const double dual_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
}
// ===== Restrict Left Dual Vector Product ====== //
inline void _bgc_fp32_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
{
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
}
inline void _bgc_fp64_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
{
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
}
// =================== Divide =================== //

View file

@ -27,8 +27,8 @@ extern inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* const
extern inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
extern inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix1, BGC_FP32_Matrix2x2* const matrix2);
extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix1, BGC_FP64_Matrix2x2* const matrix2);
extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix, BGC_FP32_Matrix2x2* const matriy);
extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix, BGC_FP64_Matrix2x2* const matriy);
extern inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
extern inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
@ -57,8 +57,8 @@ extern inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column,
extern inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
extern inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy);
extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy);
extern inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const basic_matrix, const BGC_FP32_Matrix2x2* const scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const basic_matrix, const BGC_FP64_Matrix2x2* const scalable_matrix, const double scale);
@ -78,11 +78,11 @@ extern inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* cons
extern inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector);
extern inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector);
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy);
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy);
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix3x2* const matriy);
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix3x2* const matriy);
extern inline int bgc_fp32_matrix2x2_divide_by_real_number(BGC_FP32_Matrix2x2* const quotient, const BGC_FP32_Matrix2x2* const dividend, const float divisor);
extern inline int bgc_fp64_matrix2x2_divide_by_real_number(BGC_FP64_Matrix2x2* const quotient, const BGC_FP64_Matrix2x2* const dividend, const double divisor);

View file

@ -175,46 +175,46 @@ inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* const destination, const
// ==================== Swap ==================== //
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix1, BGC_FP32_Matrix2x2* const matrix2)
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix, BGC_FP32_Matrix2x2* const matriy)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float r1c1 = matriy->r1c1;
const float r1c2 = matriy->r1c2;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float r2c1 = matriy->r2c1;
const float r2c2 = matriy->r2c2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
}
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix1, BGC_FP64_Matrix2x2* const matrix2)
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix, BGC_FP64_Matrix2x2* const matriy)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double r1c1 = matriy->r1c1;
const double r1c2 = matriy->r1c2;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double r2c1 = matriy->r2c1;
const double r2c2 = matriy->r2c2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
}
// ================== Convert =================== //
@ -346,37 +346,37 @@ inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* const transpos
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x2* const matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
}
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x2* const matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
return;
}
row->x1 = 0.0;
row->x2 = 0.0;
row->x = 0.0;
row->y = 0.0;
}
// ================== Set Row =================== //
@ -384,28 +384,28 @@ inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* const row, const BGC_FP
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
{
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
}
}
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
{
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
}
}
@ -414,37 +414,37 @@ inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* const matrix, const i
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* const column, const BGC_FP32_Matrix2x2* const matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
column->x = 0.0f;
column->y = 0.0f;
}
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix2x2* const matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
column->x = 0.0;
column->y = 0.0;
}
// ================= Set Column ================= //
@ -452,49 +452,49 @@ inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column, const
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
}
}
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
}
}
// ==================== Add ===================== //
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
}
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
}
// ================= Add Scaled ================= //
@ -581,45 +581,45 @@ inline void bgc_fp64_matrix2x2_multiply_by_real_number(BGC_FP64_Matrix2x2* const
inline void bgc_fp32_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
{
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
const float x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
const float y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
product->x1 = x1;
product->x2 = x2;
product->x = x;
product->y = y;
}
inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
{
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
const double x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
const double y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
product->x1 = x1;
product->x2 = x2;
product->x = x;
product->y = y;
}
// ======= Restrict Right Vector Product ======== //
inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
}
inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
}
// ========== Matrix Product 2x2 at 2x2 ========= //
// ========== Matrix Product 2y at 2y ========= //
inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -628,13 +628,13 @@ inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const p
product->r2c2 = r2c2;
}
inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -643,17 +643,17 @@ inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const p
product->r2c2 = r2c2;
}
// ========== Matrix Product 2x2 at 3x2 ========= //
// ========== Matrix Product 2y at 3y ========= //
inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix3x2* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -664,15 +664,15 @@ inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const p
product->r2c3 = r2c3;
}
inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix3x2* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;

View file

@ -6,8 +6,8 @@ extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* const matrix);
extern inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
extern inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix1, BGC_FP32_Matrix2x3* const matrix2);
extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix1, BGC_FP64_Matrix2x3* const matrix2);
extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix, BGC_FP32_Matrix2x3* const matriy);
extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix, BGC_FP64_Matrix2x3* const matriy);
extern inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
extern inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
@ -27,8 +27,8 @@ extern inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column,
extern inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int number, const BGC_FP32_Vector3* const column);
extern inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int number, const BGC_FP64_Vector3* const column);
extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x3* const matriy);
extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x3* const matriy);
extern inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const basic_matrix, const BGC_FP32_Matrix2x3* const scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const basic_matrix, const BGC_FP64_Matrix2x3* const scalable_matrix, const double scale);
@ -45,11 +45,11 @@ extern inline void bgc_fp64_matrix2x3_multiply_by_real_number(BGC_FP64_Matrix2x3
extern inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* const vector);
extern inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* const vector);
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x2* const matriy);
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x2* const matriy);
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix3x2* const matriy);
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix3x2* const matriy);
extern inline int bgc_fp32_matrix2x3_divide_by_real_number(BGC_FP32_Matrix2x3* const quotient, const BGC_FP32_Matrix2x3* const dividend, const float divisor);
extern inline int bgc_fp64_matrix2x3_divide_by_real_number(BGC_FP64_Matrix2x3* const quotient, const BGC_FP64_Matrix2x3* const dividend, const double divisor);

View file

@ -60,64 +60,64 @@ inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* const destination, const
// ==================== Swap ==================== //
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix1, BGC_FP32_Matrix2x3* const matrix2)
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix, BGC_FP32_Matrix2x3* const matriy)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float r1c1 = matriy->r1c1;
const float r1c2 = matriy->r1c2;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float r2c1 = matriy->r2c1;
const float r2c2 = matriy->r2c2;
const float r3c1 = matrix2->r3c1;
const float r3c2 = matrix2->r3c2;
const float r3c1 = matriy->r3c1;
const float r3c2 = matriy->r3c2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matriy->r3c1 = matrix->r3c1;
matriy->r3c2 = matrix->r3c2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
matrix->r3c1 = r3c1;
matrix->r3c2 = r3c2;
}
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix1, BGC_FP64_Matrix2x3* const matrix2)
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix, BGC_FP64_Matrix2x3* const matriy)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double r1c1 = matriy->r1c1;
const double r1c2 = matriy->r1c2;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double r2c1 = matriy->r2c1;
const double r2c2 = matriy->r2c2;
const double r3c1 = matrix2->r3c1;
const double r3c2 = matrix2->r3c2;
const double r3c1 = matriy->r3c1;
const double r3c2 = matriy->r3c2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matriy->r3c1 = matrix->r3c1;
matriy->r3c2 = matrix->r3c2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
matrix->r3c1 = r3c1;
matrix->r3c2 = r3c2;
}
// ================== Convert =================== //
@ -177,49 +177,49 @@ inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* const transpos
inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x3* const matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
return;
}
if (row_number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x = matrix->r3c1;
row->y = matrix->r3c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
}
inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x3* const matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
return;
}
if (row_number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x = matrix->r3c1;
row->y = matrix->r3c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
}
// ================== Set Row =================== //
@ -227,40 +227,40 @@ inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* const row, const BGC_FP
inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
{
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
return;
}
if (row_number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c1 = row->x;
matrix->r3c2 = row->y;
}
}
inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
{
if (row_number == 1) {
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
return;
}
if (row_number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
return;
}
if (row_number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c1 = row->x;
matrix->r3c2 = row->y;
}
}
@ -269,32 +269,32 @@ inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* const matrix, const i
inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* const column, const BGC_FP32_Matrix2x3* const matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
column->z = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
column->z = matrix->r3c2;
}
}
inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix2x3* const matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
column->z = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
column->z = matrix->r3c2;
}
}
@ -303,59 +303,59 @@ inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column, const
inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
matrix->r3c1 = column->z;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
matrix->r3c2 = column->z;
}
}
inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column)
{
if (column_number == 1) {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
matrix->r3c1 = column->z;
return;
}
if (column_number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
matrix->r3c2 = column->z;
}
}
// ==================== Add ===================== //
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x3* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
}
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x3* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
}
// ================= Add Scaled ================= //
@ -466,31 +466,31 @@ inline void bgc_fp64_matrix2x3_multiply_by_real_number(BGC_FP64_Matrix2x3* const
inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y;
}
inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y;
}
// ========== Matrix Product 2x3 at 2x2 ========= //
// ========== Matrix Product 2z at 2y ========= //
inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x2* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -502,16 +502,16 @@ inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const p
product->r3c2 = r3c2;
}
inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x2* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -523,36 +523,36 @@ inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const p
product->r3c2 = r3c2;
}
// ========== Matrix Product 2x3 at 3x2 ========= //
// ========== Matrix Product 2z at 3y ========= //
inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix3x2* const matriy)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
product->r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
product->r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
product->r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
product->r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
product->r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3;
}
inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix3x2* const matriy)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
product->r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
product->r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
product->r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
product->r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
product->r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3;
}
// =================== Divide =================== //

View file

@ -6,8 +6,8 @@ extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* const matrix);
extern inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
extern inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix1, BGC_FP32_Matrix3x2* const matrix2);
extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix1, BGC_FP64_Matrix3x2* const matrix2);
extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix, BGC_FP32_Matrix3x2* const matriy);
extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix, BGC_FP64_Matrix3x2* const matriy);
extern inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
extern inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
@ -27,8 +27,8 @@ extern inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* const column,
extern inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
extern inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x2* const matriy);
extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x2* const matriy);
extern inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const basic_matrix, const BGC_FP32_Matrix3x2* const scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const basic_matrix, const BGC_FP64_Matrix3x2* const scalable_matrix, const double scale);
@ -45,11 +45,11 @@ extern inline void bgc_fp64_matrix3x2_multiply_by_real_number(BGC_FP64_Matrix3x2
extern inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector);
extern inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector);
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix2x3* const matriy);
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix2x3* const matriy);
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x3* const matriy);
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x3* const matriy);
extern inline int bgc_fp32_matrix3x2_divide_by_real_number(BGC_FP32_Matrix3x2* const quotient, const BGC_FP32_Matrix3x2* const dividend, const float divisor);
extern inline int bgc_fp64_matrix3x2_divide_by_real_number(BGC_FP64_Matrix3x2* const quotient, const BGC_FP64_Matrix3x2* const dividend, const double divisor);

View file

@ -56,58 +56,58 @@ inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* const destination, const
// ==================== Swap ==================== //
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix1, BGC_FP32_Matrix3x2* const matrix2)
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix, BGC_FP32_Matrix3x2* const matriy)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float r1c3 = matrix2->r1c3;
const float r1c1 = matriy->r1c1;
const float r1c2 = matriy->r1c2;
const float r1c3 = matriy->r1c3;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float r2c3 = matrix2->r2c3;
const float r2c1 = matriy->r2c1;
const float r2c2 = matriy->r2c2;
const float r2c3 = matriy->r2c3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matriy->r1c3 = matrix->r1c3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matriy->r2c3 = matrix->r2c3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix->r1c3 = r1c3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix->r2c3 = r2c3;
}
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix1, BGC_FP64_Matrix3x2* const matrix2)
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix, BGC_FP64_Matrix3x2* const matriy)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double r1c3 = matrix2->r1c3;
const double r1c1 = matriy->r1c1;
const double r1c2 = matriy->r1c2;
const double r1c3 = matriy->r1c3;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double r2c3 = matrix2->r2c3;
const double r2c1 = matriy->r2c1;
const double r2c2 = matriy->r2c2;
const double r2c3 = matriy->r2c3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matriy->r1c3 = matrix->r1c3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matriy->r2c3 = matrix->r2c3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix->r1c3 = r1c3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix->r2c3 = r2c3;
}
// ================== Convert =================== //
@ -164,46 +164,46 @@ inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* const row, const BGC_FP
{
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
row->z = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
row->z = matrix->r2c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
row->z = 0.0f;
}
inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x2* const matrix, const int row_number)
{
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
row->z = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
row->z = matrix->r2c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
row->z = 0.0f;
}
// ================== Set Row =================== //
@ -212,17 +212,17 @@ inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* const matrix, const i
{
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
matrix->r1c3 = row->z;
return;
}
if (row_number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
matrix->r2c3 = row->z;
}
}
@ -230,17 +230,17 @@ inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* const matrix, const i
{
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
matrix->r1c3 = row->z;
return;
}
if (row_number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
matrix->r2c3 = row->z;
}
}
@ -250,54 +250,54 @@ inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* const column, const
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x = matrix->r1c3;
column->y = matrix->r2c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
column->x = 0.0f;
column->y = 0.0f;
}
inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix3x2* const matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x = matrix->r1c3;
column->y = matrix->r2c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
column->x = 0.0;
column->y = 0.0;
}
// ================= Set Column ================= //
@ -306,22 +306,22 @@ inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* const matrix, cons
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r1c3 = column->x;
matrix->r2c3 = column->y;
}
}
@ -329,47 +329,47 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* const matrix, cons
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r1c3 = column->x;
matrix->r2c3 = column->y;
}
}
// ==================== Add ===================== //
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x2* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
}
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x2* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
}
// ================= Add Scaled ================= //
@ -472,47 +472,47 @@ inline void bgc_fp64_matrix3x2_multiply_by_real_number(BGC_FP64_Matrix3x2* const
inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
}
inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
}
// ========== Matrix Product 3x2 at 2x3 ========= //
// ========== Matrix Product 3y at 2z ========= //
inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix2x3* const matriy)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
}
inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix2x3* const matriy)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
}
// ========== Matrix Product 3x2 at 3x2 ========= //
// ========== Matrix Product 3y at 3y ========= //
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x3* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -523,15 +523,15 @@ inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const p
product->r2c3 = r2c3;
}
inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x3* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;

View file

@ -12,8 +12,8 @@ extern inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* const ma
extern inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
extern inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix1, BGC_FP32_Matrix3x3* const matrix2);
extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix1, BGC_FP64_Matrix3x3* const matrix2);
extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix, BGC_FP32_Matrix3x3* const matriy);
extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix, BGC_FP64_Matrix3x3* const matriy);
extern inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
extern inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
@ -51,8 +51,8 @@ extern inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* const column,
extern inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column);
extern inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column);
extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy);
extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy);
extern inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const basic_matrix, const BGC_FP32_Matrix3x3* const scalable_matrix, const float scale);
extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const basic_matrix, const BGC_FP64_Matrix3x3* const scalable_matrix, const double scale);
@ -78,11 +78,11 @@ extern inline void _bgc_fp64_restrict_matrix3x3_multiply_by_vector3(BGC_FP64_Vec
extern inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector);
extern inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector);
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix2x3* const matriy);
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix2x3* const matriy);
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy);
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy);
extern inline int bgc_fp32_matrix3x3_divide_by_real_number(BGC_FP32_Matrix3x3* const quotient, const BGC_FP32_Matrix3x3* const dividend, const float divisor);
extern inline int bgc_fp64_matrix3x3_divide_by_real_number(BGC_FP64_Matrix3x3* const quotient, const BGC_FP64_Matrix3x3* const dividend, const double divisor);

View file

@ -136,82 +136,82 @@ inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* const destination, const
// ==================== Swap ==================== //
inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix1, BGC_FP32_Matrix3x3* const matrix2)
inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix, BGC_FP32_Matrix3x3* const matriy)
{
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float r1c3 = matrix2->r1c3;
const float r1c1 = matriy->r1c1;
const float r1c2 = matriy->r1c2;
const float r1c3 = matriy->r1c3;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float r2c3 = matrix2->r2c3;
const float r2c1 = matriy->r2c1;
const float r2c2 = matriy->r2c2;
const float r2c3 = matriy->r2c3;
const float r3c1 = matrix2->r3c1;
const float r3c2 = matrix2->r3c2;
const float r3c3 = matrix2->r3c3;
const float r3c1 = matriy->r3c1;
const float r3c2 = matriy->r3c2;
const float r3c3 = matriy->r3c3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matriy->r1c3 = matrix->r1c3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matriy->r2c3 = matrix->r2c3;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matrix2->r3c3 = matrix1->r3c3;
matriy->r3c1 = matrix->r3c1;
matriy->r3c2 = matrix->r3c2;
matriy->r3c3 = matrix->r3c3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix->r1c3 = r1c3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix->r2c3 = r2c3;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
matrix1->r3c3 = r3c3;
matrix->r3c1 = r3c1;
matrix->r3c2 = r3c2;
matrix->r3c3 = r3c3;
}
inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix1, BGC_FP64_Matrix3x3* const matrix2)
inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix, BGC_FP64_Matrix3x3* const matriy)
{
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double r1c3 = matrix2->r1c3;
const double r1c1 = matriy->r1c1;
const double r1c2 = matriy->r1c2;
const double r1c3 = matriy->r1c3;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double r2c3 = matrix2->r2c3;
const double r2c1 = matriy->r2c1;
const double r2c2 = matriy->r2c2;
const double r2c3 = matriy->r2c3;
const double r3c1 = matrix2->r3c1;
const double r3c2 = matrix2->r3c2;
const double r3c3 = matrix2->r3c3;
const double r3c1 = matriy->r3c1;
const double r3c2 = matriy->r3c2;
const double r3c3 = matriy->r3c3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matriy->r1c1 = matrix->r1c1;
matriy->r1c2 = matrix->r1c2;
matriy->r1c3 = matrix->r1c3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matriy->r2c1 = matrix->r2c1;
matriy->r2c2 = matrix->r2c2;
matriy->r2c3 = matrix->r2c3;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matrix2->r3c3 = matrix1->r3c3;
matriy->r3c1 = matrix->r3c1;
matriy->r3c2 = matrix->r3c2;
matriy->r3c3 = matrix->r3c3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix->r1c1 = r1c1;
matrix->r1c2 = r1c2;
matrix->r1c3 = r1c3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
matrix->r2c1 = r2c1;
matrix->r2c2 = r2c2;
matrix->r2c3 = r2c3;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
matrix1->r3c3 = r3c3;
matrix->r3c1 = r3c1;
matrix->r3c2 = r3c2;
matrix->r3c3 = r3c3;
}
// ================== Convert =================== //
@ -426,62 +426,62 @@ inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* const row, const BGC_FP
{
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
row->z = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
row->z = matrix->r2c3;
return;
}
if (row_number == 3)
{
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
row->x = matrix->r3c1;
row->y = matrix->r3c2;
row->z = matrix->r3c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
row->x = 0.0f;
row->y = 0.0f;
row->z = 0.0f;
}
inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x3* const matrix, const int row_number)
{
if (row_number == 1)
{
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
row->x = matrix->r1c1;
row->y = matrix->r1c2;
row->z = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
row->x = matrix->r2c1;
row->y = matrix->r2c2;
row->z = matrix->r2c3;
return;
}
if (row_number == 3)
{
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
row->x = matrix->r3c1;
row->y = matrix->r3c2;
row->z = matrix->r3c3;
return;
}
row->x1 = 0.0;
row->x2 = 0.0;
row->x3 = 0.0;
row->x = 0.0;
row->y = 0.0;
row->z = 0.0;
}
// ================== Set Row =================== //
@ -490,25 +490,25 @@ inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* const matrix, const i
{
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
matrix->r1c3 = row->z;
return;
}
if (row_number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
matrix->r2c3 = row->z;
return;
}
if (row_number == 3)
{
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
matrix->r3c1 = row->x;
matrix->r3c2 = row->y;
matrix->r3c3 = row->z;
}
}
@ -516,25 +516,25 @@ inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* const matrix, const i
{
if (row_number == 1)
{
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
matrix->r1c1 = row->x;
matrix->r1c2 = row->y;
matrix->r1c3 = row->z;
return;
}
if (row_number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
matrix->r2c1 = row->x;
matrix->r2c2 = row->y;
matrix->r2c3 = row->z;
return;
}
if (row_number == 3)
{
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
matrix->r3c1 = row->x;
matrix->r3c2 = row->y;
matrix->r3c3 = row->z;
}
}
@ -544,62 +544,62 @@ inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* const column, const
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
column->z = matrix->r3c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
column->z = matrix->r3c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
column->x = matrix->r1c3;
column->y = matrix->r2c3;
column->z = matrix->r3c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
column->x3 = 0.0f;
column->x = 0.0f;
column->y = 0.0f;
column->z = 0.0f;
}
inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix3x3* const matrix, const int column_number)
{
if (column_number == 1)
{
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
column->x = matrix->r1c1;
column->y = matrix->r2c1;
column->z = matrix->r3c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
column->x = matrix->r1c2;
column->y = matrix->r2c2;
column->z = matrix->r3c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
column->x = matrix->r1c3;
column->y = matrix->r2c3;
column->z = matrix->r3c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
column->x3 = 0.0;
column->x = 0.0;
column->y = 0.0;
column->z = 0.0;
}
// ================= Set Column ================= //
@ -608,25 +608,25 @@ inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* const matrix, cons
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
matrix->r3c1 = column->z;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
matrix->r3c2 = column->z;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r3c3 = column->x3;
matrix->r1c3 = column->x;
matrix->r2c3 = column->y;
matrix->r3c3 = column->z;
}
}
@ -634,58 +634,58 @@ inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* const matrix, cons
{
if (column_number == 1)
{
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
matrix->r1c1 = column->x;
matrix->r2c1 = column->y;
matrix->r3c1 = column->z;
return;
}
if (column_number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
matrix->r1c2 = column->x;
matrix->r2c2 = column->y;
matrix->r3c2 = column->z;
return;
}
if (column_number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r3c3 = column->x3;
matrix->r1c3 = column->x;
matrix->r2c3 = column->y;
matrix->r3c3 = column->z;
}
}
// ==================== Add ===================== //
inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
sum->r3c3 = matrix->r3c3 + matriy->r3c3;
}
inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy)
{
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
sum->r3c3 = matrix->r3c3 + matriy->r3c3;
}
// ================= Add Scaled ================= //
@ -820,118 +820,118 @@ inline void bgc_fp64_matrix3x3_multiply_by_real_number(BGC_FP64_Matrix3x3* const
inline void bgc_fp32_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
{
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
const float x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
const float y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
const float z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
inline void bgc_fp64_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
{
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
const double x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
const double y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
const double z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
// ========= Right Dual Vector Product ========== //
inline void bgc_fp32_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
{
const float real_x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
const float real_x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
const float real_x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
const float real_x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
const float real_y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
const float real_z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
const float dual_x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
const float dual_x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
const float dual_x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
const float dual_x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
const float dual_y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
const float dual_z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
}
inline void bgc_fp64_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
{
const double real_x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
const double real_x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
const double real_x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
const double real_x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
const double real_y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
const double real_z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
const double dual_x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
const double dual_x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
const double dual_x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
const double dual_x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
const double dual_y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
const double dual_z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
}
// ======= Restrict Right Vector Product ======== //
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
}
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
{
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
}
// ========= Right Dual Vector Product ========== //
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
{
product->real_part.x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
product->real_part.x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
product->real_part.x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
product->real_part.x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
product->real_part.y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
product->real_part.z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
product->real_part.x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
product->real_part.x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
product->real_part.x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
product->real_part.x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
product->real_part.y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
product->real_part.z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
}
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
{
product->real_part.x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
product->real_part.x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
product->real_part.x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
product->real_part.x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
product->real_part.y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
product->real_part.z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
product->real_part.x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
product->real_part.x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
product->real_part.x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
product->real_part.x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
product->real_part.y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
product->real_part.z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
}
// ========== Matrix Product 3x3 at 2x3 ========= //
// ========== Matrix Product 3z at 2z ========= //
inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix2x3* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -943,16 +943,16 @@ inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const p
product->r3c2 = r3c2;
}
inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix2x3* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -964,21 +964,21 @@ inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const p
product->r3c2 = r3c2;
}
// ========== Matrix Product 3x3 at 3x3 ========= //
// ========== Matrix Product 3z at 3z ========= //
inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
const float r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3 + matrix->r3c3 * matriy->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
@ -993,19 +993,19 @@ inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const p
product->r3c3 = r3c3;
}
inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
const double r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3 + matrix->r3c3 * matriy->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;

View file

@ -7,8 +7,8 @@ extern inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* const quaterni
extern inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* const quaternion);
extern inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* const quaternion);
extern inline void bgc_fp32_quaternion_set_values(BGC_FP32_Quaternion* const quaternion, const float s0, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_quaternion_set_values(BGC_FP64_Quaternion* const quaternion, const double s0, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_quaternion_set_values(BGC_FP32_Quaternion* const quaternion, const float s, const float x, const float y, const float z);
extern inline void bgc_fp64_quaternion_set_values(BGC_FP64_Quaternion* const quaternion, const double s, const double x, const double y, const double z);
extern inline float bgc_fp32_quaternion_get_square_magnitude(const BGC_FP32_Quaternion* const quaternion);
extern inline double bgc_fp64_quaternion_get_square_magnitude(const BGC_FP64_Quaternion* const quaternion);
@ -158,13 +158,13 @@ extern inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* const
int bgc_fp32_quaternion_get_power(BGC_FP32_Quaternion* const power, const BGC_FP32_Quaternion* const base, const float exponent)
{
const float s0s0 = base->s0 * base->s0;
const float x1x1 = base->x1 * base->x1;
const float x2x2 = base->x2 * base->x2;
const float x3x3 = base->x3 * base->x3;
const float ss = base->s * base->s;
const float xx = base->x * base->x;
const float yy = base->y * base->y;
const float zz = base->z * base->z;
const float square_vector = x1x1 + (x2x2 + x3x3);
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
const float square_vector = xx + (yy + zz);
const float square_modulus = (ss + xx) + (yy + zz);
// isnan(square_modulus) means checking for NaN value at square_modulus
if (isnan(square_modulus)) {
@ -172,40 +172,40 @@ int bgc_fp32_quaternion_get_power(BGC_FP32_Quaternion* const power, const BGC_FP
}
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
if (base->s0 < 0.0f) {
if (base->s < 0.0f) {
return BGC_FAILURE;
}
power->s0 = powf(base->s0, exponent);
power->x1 = 0.0f;
power->x2 = 0.0f;
power->x3 = 0.0f;
power->s = powf(base->s, exponent);
power->x = 0.0f;
power->y = 0.0f;
power->z = 0.0f;
return BGC_SUCCESS;
}
const float vector_modulus = sqrtf(square_vector);
const float power_angle = atan2f(vector_modulus, base->s0) * exponent;
const float power_angle = atan2f(vector_modulus, base->s) * exponent;
const float power_modulus = powf(square_modulus, 0.5f * exponent);
const float multiplier = power_modulus * sinf(power_angle) / vector_modulus;
power->s0 = power_modulus * cosf(power_angle);
power->x1 = base->x1 * multiplier;
power->x2 = base->x2 * multiplier;
power->x3 = base->x3 * multiplier;
power->s = power_modulus * cosf(power_angle);
power->x = base->x * multiplier;
power->y = base->y * multiplier;
power->z = base->z * multiplier;
return BGC_SUCCESS;
}
int bgc_fp64_quaternion_get_power(BGC_FP64_Quaternion* const power, const BGC_FP64_Quaternion* const base, const double exponent)
{
const double s0s0 = base->s0 * base->s0;
const double x1x1 = base->x1 * base->x1;
const double x2x2 = base->x2 * base->x2;
const double x3x3 = base->x3 * base->x3;
const double ss = base->s * base->s;
const double xx = base->x * base->x;
const double yy = base->y * base->y;
const double zz = base->z * base->z;
const double square_vector = x1x1 + (x2x2 + x3x3);
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
const double square_vector = xx + (yy + zz);
const double square_modulus = (ss + xx) + (yy + zz);
// isnan(square_modulus) means checking for NaN value at square_modulus
if (isnan(square_modulus)) {
@ -213,27 +213,27 @@ int bgc_fp64_quaternion_get_power(BGC_FP64_Quaternion* const power, const BGC_FP
}
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
if (base->s0 < 0.0) {
if (base->s < 0.0) {
return BGC_FAILURE;
}
power->s0 = pow(base->s0, exponent);
power->x1 = 0.0;
power->x2 = 0.0;
power->x3 = 0.0;
power->s = pow(base->s, exponent);
power->x = 0.0;
power->y = 0.0;
power->z = 0.0;
return BGC_SUCCESS;
}
const double vector_modulus = sqrt(square_vector);
const double power_angle = atan2(vector_modulus, base->s0) * exponent;
const double power_angle = atan2(vector_modulus, base->s) * exponent;
const double power_modulus = pow(square_modulus, 0.5 * exponent);
const double multiplier = power_modulus * sin(power_angle) / vector_modulus;
power->s0 = power_modulus * cos(power_angle);
power->x1 = base->x1 * multiplier;
power->x2 = base->x2 * multiplier;
power->x3 = base->x3 * multiplier;
power->s = power_modulus * cos(power_angle);
power->x = base->x * multiplier;
power->y = base->y * multiplier;
power->z = base->z * multiplier;
return BGC_SUCCESS;
}

File diff suppressed because it is too large Load diff

View file

@ -12,28 +12,28 @@
inline void bgc_fp32_rigid_pose3_reset(BGC_FP32_RigidPose3* const pose)
{
pose->_versor.real_part.s0 = 1.0f;
pose->_versor.real_part.x1 = 0.0f;
pose->_versor.real_part.x2 = 0.0f;
pose->_versor.real_part.x3 = 0.0f;
pose->_versor.real_part.s = 1.0f;
pose->_versor.real_part.x = 0.0f;
pose->_versor.real_part.y = 0.0f;
pose->_versor.real_part.z = 0.0f;
pose->_versor.dual_part.s0 = 0.0f;
pose->_versor.dual_part.x1 = 0.0f;
pose->_versor.dual_part.x2 = 0.0f;
pose->_versor.dual_part.x3 = 0.0f;
pose->_versor.dual_part.s = 0.0f;
pose->_versor.dual_part.x = 0.0f;
pose->_versor.dual_part.y = 0.0f;
pose->_versor.dual_part.z = 0.0f;
}
inline void bgc_fp64_rigid_pose3_reset(BGC_FP64_RigidPose3* const pose)
{
pose->_versor.real_part.s0 = 1.0;
pose->_versor.real_part.x1 = 0.0;
pose->_versor.real_part.x2 = 0.0;
pose->_versor.real_part.x3 = 0.0;
pose->_versor.real_part.s = 1.0;
pose->_versor.real_part.x = 0.0;
pose->_versor.real_part.y = 0.0;
pose->_versor.real_part.z = 0.0;
pose->_versor.dual_part.s0 = 0.0;
pose->_versor.dual_part.x1 = 0.0;
pose->_versor.dual_part.x2 = 0.0;
pose->_versor.dual_part.x3 = 0.0;
pose->_versor.dual_part.s = 0.0;
pose->_versor.dual_part.x = 0.0;
pose->_versor.dual_part.y = 0.0;
pose->_versor.dual_part.z = 0.0;
}
// ================= Normalize ================== //
@ -182,7 +182,7 @@ inline void bgc_fp64_rigid_pose3_convert_to_fp32(BGC_FP32_RigidPose3* const dest
inline void bgc_fp32_rigid_pose3_shorten(BGC_FP32_RigidPose3* const pose)
{
if (pose->_versor.real_part.s0 < 0.0f) {
if (pose->_versor.real_part.s < 0.0f) {
bgc_fp32_quaternion_revert(&pose->_versor.real_part);
bgc_fp32_quaternion_revert(&pose->_versor.dual_part);
}
@ -190,7 +190,7 @@ inline void bgc_fp32_rigid_pose3_shorten(BGC_FP32_RigidPose3* const pose)
inline void bgc_fp64_rigid_pose3_shorten(BGC_FP64_RigidPose3* const pose)
{
if (pose->_versor.real_part.s0 < 0.0) {
if (pose->_versor.real_part.s < 0.0) {
bgc_fp64_quaternion_revert(&pose->_versor.real_part);
bgc_fp64_quaternion_revert(&pose->_versor.dual_part);
}
@ -200,7 +200,7 @@ inline void bgc_fp64_rigid_pose3_shorten(BGC_FP64_RigidPose3* const pose)
inline void bgc_fp32_rigid_pose3_get_shortened(BGC_FP32_RigidPose3* const shortened, const BGC_FP32_RigidPose3* const pose)
{
if (pose->_versor.real_part.s0 < 0.0f) {
if (pose->_versor.real_part.s < 0.0f) {
bgc_fp32_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
bgc_fp32_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
}
@ -212,7 +212,7 @@ inline void bgc_fp32_rigid_pose3_get_shortened(BGC_FP32_RigidPose3* const shorte
inline void bgc_fp64_rigid_pose3_get_shortened(BGC_FP64_RigidPose3* const shortened, const BGC_FP64_RigidPose3* const pose)
{
if (pose->_versor.real_part.s0 < 0.0) {
if (pose->_versor.real_part.s < 0.0) {
bgc_fp64_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
bgc_fp64_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
}
@ -351,9 +351,9 @@ inline void bgc_fp32_rigid_pose3_get_shift(BGC_FP32_Vector3* const shift, const
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
shift->x1 = 2.0f * ((dual->x1 * real->s0 + dual->x3 * real->x2) - (dual->s0 * real->x1 + dual->x2 * real->x3));
shift->x2 = 2.0f * ((dual->x2 * real->s0 + dual->x1 * real->x3) - (dual->s0 * real->x2 + dual->x3 * real->x1));
shift->x3 = 2.0f * ((dual->x3 * real->s0 + dual->x2 * real->x1) - (dual->s0 * real->x3 + dual->x1 * real->x2));
shift->x = 2.0f * ((dual->x * real->s + dual->z * real->y) - (dual->s * real->x + dual->y * real->z));
shift->y = 2.0f * ((dual->y * real->s + dual->x * real->z) - (dual->s * real->y + dual->z * real->x));
shift->z = 2.0f * ((dual->z * real->s + dual->y * real->x) - (dual->s * real->z + dual->x * real->y));
}
inline void bgc_fp64_rigid_pose3_get_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
@ -361,9 +361,9 @@ inline void bgc_fp64_rigid_pose3_get_shift(BGC_FP64_Vector3* const shift, const
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
shift->x1 = 2.0 * ((dual->x1 * real->s0 + dual->x3 * real->x2) - (dual->s0 * real->x1 + dual->x2 * real->x3));
shift->x2 = 2.0 * ((dual->x2 * real->s0 + dual->x1 * real->x3) - (dual->s0 * real->x2 + dual->x3 * real->x1));
shift->x3 = 2.0 * ((dual->x3 * real->s0 + dual->x2 * real->x1) - (dual->s0 * real->x3 + dual->x1 * real->x2));
shift->x = 2.0 * ((dual->x * real->s + dual->z * real->y) - (dual->s * real->x + dual->y * real->z));
shift->y = 2.0 * ((dual->y * real->s + dual->x * real->z) - (dual->s * real->y + dual->z * real->x));
shift->z = 2.0 * ((dual->z * real->s + dual->y * real->x) - (dual->s * real->z + dual->x * real->y));
}
// ============= Get Reverse Shift ============= //
@ -373,9 +373,9 @@ inline void bgc_fp32_rigid_pose3_get_reverse_shift(BGC_FP32_Vector3* const shift
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
shift->x1 = 2.0f * ((dual->s0 * real->x1 - dual->x1 * real->s0) + (dual->x3 * real->x2 - dual->x2 * real->x3));
shift->x2 = 2.0f * ((dual->s0 * real->x2 - dual->x2 * real->s0) + (dual->x1 * real->x3 - dual->x3 * real->x1));
shift->x3 = 2.0f * ((dual->s0 * real->x3 - dual->x3 * real->s0) + (dual->x2 * real->x1 - dual->x1 * real->x2));
shift->x = 2.0f * ((dual->s * real->x - dual->x * real->s) + (dual->z * real->y - dual->y * real->z));
shift->y = 2.0f * ((dual->s * real->y - dual->y * real->s) + (dual->x * real->z - dual->z * real->x));
shift->z = 2.0f * ((dual->s * real->z - dual->z * real->s) + (dual->y * real->x - dual->x * real->y));
}
inline void bgc_fp64_rigid_pose3_get_reverse_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
@ -383,9 +383,9 @@ inline void bgc_fp64_rigid_pose3_get_reverse_shift(BGC_FP64_Vector3* const shift
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
shift->x1 = 2.0 * ((dual->s0 * real->x1 - dual->x1 * real->s0) + (dual->x3 * real->x2 - dual->x2 * real->x3));
shift->x2 = 2.0 * ((dual->s0 * real->x2 - dual->x2 * real->s0) + (dual->x1 * real->x3 - dual->x3 * real->x1));
shift->x3 = 2.0 * ((dual->s0 * real->x3 - dual->x3 * real->s0) + (dual->x2 * real->x1 - dual->x1 * real->x2));
shift->x = 2.0 * ((dual->s * real->x - dual->x * real->s) + (dual->z * real->y - dual->y * real->z));
shift->y = 2.0 * ((dual->s * real->y - dual->y * real->s) + (dual->x * real->z - dual->z * real->x));
shift->z = 2.0 * ((dual->s * real->z - dual->z * real->s) + (dual->y * real->x - dual->x * real->y));
}
// ================ Get Affine3 ================= //
@ -439,10 +439,10 @@ inline void bgc_fp32_rigid_pose3_set_position(BGC_FP32_RigidPose3* const pose, c
bgc_fp32_quaternion_copy(&pose->_versor.real_part, versor);
pose->_versor.dual_part.s0 = -0.5f * (shift->x1 * versor->x1 + shift->x2 * versor->x2 + shift->x3 * versor->x3);
pose->_versor.dual_part.x1 = -0.5f * (shift->x3 * versor->x2 - shift->x2 * versor->x3 - shift->x1 * versor->s0);
pose->_versor.dual_part.x2 = -0.5f * (shift->x1 * versor->x3 - shift->x3 * versor->x1 - shift->x2 * versor->s0);
pose->_versor.dual_part.x3 = -0.5f * (shift->x2 * versor->x1 - shift->x1 * versor->x2 - shift->x3 * versor->s0);
pose->_versor.dual_part.s = -0.5f * (shift->x * versor->x + shift->y * versor->y + shift->z * versor->z);
pose->_versor.dual_part.x = -0.5f * (shift->z * versor->y - shift->y * versor->z - shift->x * versor->s);
pose->_versor.dual_part.y = -0.5f * (shift->x * versor->z - shift->z * versor->x - shift->y * versor->s);
pose->_versor.dual_part.z = -0.5f * (shift->y * versor->x - shift->x * versor->y - shift->z * versor->s);
}
inline void bgc_fp64_rigid_pose3_set_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
@ -452,10 +452,10 @@ inline void bgc_fp64_rigid_pose3_set_position(BGC_FP64_RigidPose3* const pose, c
bgc_fp64_quaternion_copy(&pose->_versor.real_part, versor);
pose->_versor.dual_part.s0 = -0.5 * (shift->x1 * versor->x1 + shift->x2 * versor->x2 + shift->x3 * versor->x3);
pose->_versor.dual_part.x1 = -0.5 * (shift->x3 * versor->x2 - shift->x2 * versor->x3 - shift->x1 * versor->s0);
pose->_versor.dual_part.x2 = -0.5 * (shift->x1 * versor->x3 - shift->x3 * versor->x1 - shift->x2 * versor->s0);
pose->_versor.dual_part.x3 = -0.5 * (shift->x2 * versor->x1 - shift->x1 * versor->x2 - shift->x3 * versor->s0);
pose->_versor.dual_part.s = -0.5 * (shift->x * versor->x + shift->y * versor->y + shift->z * versor->z);
pose->_versor.dual_part.x = -0.5 * (shift->z * versor->y - shift->y * versor->z - shift->x * versor->s);
pose->_versor.dual_part.y = -0.5 * (shift->x * versor->z - shift->z * versor->x - shift->y * versor->s);
pose->_versor.dual_part.z = -0.5 * (shift->y * versor->x - shift->x * versor->y - shift->z * versor->s);
}
// =========== Get Reverse Position3 ============ //
@ -481,10 +481,10 @@ inline void bgc_fp32_rigid_pose3_set_reverse_position(BGC_FP32_RigidPose3* const
bgc_fp32_quaternion_get_conjugate(&pose->_versor.real_part, versor);
pose->_versor.dual_part.s0 = -0.5f * (versor->x1 * shift->x1 + versor->x2 * shift->x2 + versor->x3 * shift->x3);
pose->_versor.dual_part.x1 = -0.5f * (versor->s0 * shift->x1 + versor->x3 * shift->x2 - versor->x2 * shift->x3);
pose->_versor.dual_part.x2 = -0.5f * (versor->s0 * shift->x2 + versor->x1 * shift->x3 - versor->x3 * shift->x1);
pose->_versor.dual_part.x3 = -0.5f * (versor->s0 * shift->x3 + versor->x2 * shift->x1 - versor->x1 * shift->x2);
pose->_versor.dual_part.s = -0.5f * (versor->x * shift->x + versor->y * shift->y + versor->z * shift->z);
pose->_versor.dual_part.x = -0.5f * (versor->s * shift->x + versor->z * shift->y - versor->y * shift->z);
pose->_versor.dual_part.y = -0.5f * (versor->s * shift->y + versor->x * shift->z - versor->z * shift->x);
pose->_versor.dual_part.z = -0.5f * (versor->s * shift->z + versor->y * shift->x - versor->x * shift->y);
}
inline void bgc_fp64_rigid_pose3_set_reverse_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
@ -494,10 +494,10 @@ inline void bgc_fp64_rigid_pose3_set_reverse_position(BGC_FP64_RigidPose3* const
bgc_fp64_quaternion_get_conjugate(&pose->_versor.real_part, versor);
pose->_versor.dual_part.s0 = -0.5f * (versor->x1 * shift->x1 + versor->x2 * shift->x2 + versor->x3 * shift->x3);
pose->_versor.dual_part.x1 = -0.5f * (versor->s0 * shift->x1 + versor->x3 * shift->x2 - versor->x2 * shift->x3);
pose->_versor.dual_part.x2 = -0.5f * (versor->s0 * shift->x2 + versor->x1 * shift->x3 - versor->x3 * shift->x1);
pose->_versor.dual_part.x3 = -0.5f * (versor->s0 * shift->x3 + versor->x2 * shift->x1 - versor->x1 * shift->x2);
pose->_versor.dual_part.s = -0.5f * (versor->x * shift->x + versor->y * shift->y + versor->z * shift->z);
pose->_versor.dual_part.x = -0.5f * (versor->s * shift->x + versor->z * shift->y - versor->y * shift->z);
pose->_versor.dual_part.y = -0.5f * (versor->s * shift->y + versor->x * shift->z - versor->z * shift->x);
pose->_versor.dual_part.z = -0.5f * (versor->s * shift->z + versor->y * shift->x - versor->x * shift->y);
}
// ============== Transform Vector ============== //

View file

@ -23,7 +23,7 @@ extern inline void bgc_fp64_slerp3_get_phase_both_matrices(BGC_FP64_Matrix3x3* c
void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const augment)
{
const float square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
const float square_vector = augment->_versor.x * augment->_versor.x + augment->_versor.y * augment->_versor.y + augment->_versor.z * augment->_versor.z;
if (isnan(square_vector)) {
bgc_fp32_slerp3_reset(slerp);
@ -31,15 +31,15 @@ void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* co
}
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
slerp->_cosine_weight.s0 = start->_versor.s0;
slerp->_cosine_weight.x1 = start->_versor.x1;
slerp->_cosine_weight.x2 = start->_versor.x2;
slerp->_cosine_weight.x3 = start->_versor.x3;
slerp->_cosine_weight.s = start->_versor.s;
slerp->_cosine_weight.x = start->_versor.x;
slerp->_cosine_weight.y = start->_versor.y;
slerp->_cosine_weight.z = start->_versor.z;
slerp->_sine_weight.s0 = 0.0f;
slerp->_sine_weight.x1 = 0.0f;
slerp->_sine_weight.x2 = 0.0f;
slerp->_sine_weight.x3 = 0.0f;
slerp->_sine_weight.s = 0.0f;
slerp->_sine_weight.x = 0.0f;
slerp->_sine_weight.y = 0.0f;
slerp->_sine_weight.z = 0.0f;
slerp->radians = 0.0f;
return;
@ -47,24 +47,24 @@ void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* co
const float vector_modulus = sqrtf(square_vector);
slerp->radians = atan2f(vector_modulus, augment->_versor.s0);
slerp->radians = atan2f(vector_modulus, augment->_versor.s);
const float multiplier = 1.0f / vector_modulus;
slerp->_cosine_weight.s0 = start->_versor.s0;
slerp->_cosine_weight.x1 = start->_versor.x1;
slerp->_cosine_weight.x2 = start->_versor.x2;
slerp->_cosine_weight.x3 = start->_versor.x3;
slerp->_cosine_weight.s = start->_versor.s;
slerp->_cosine_weight.x = start->_versor.x;
slerp->_cosine_weight.y = start->_versor.y;
slerp->_cosine_weight.z = start->_versor.z;
slerp->_sine_weight.s0 = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
slerp->_sine_weight.x1 = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
slerp->_sine_weight.x2 = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
slerp->_sine_weight.x3 = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
slerp->_sine_weight.s = -multiplier * (augment->_versor.x * start->_versor.x + augment->_versor.y * start->_versor.y + augment->_versor.z * start->_versor.z);
slerp->_sine_weight.x = multiplier * (augment->_versor.x * start->_versor.s + augment->_versor.y * start->_versor.z - augment->_versor.z * start->_versor.y);
slerp->_sine_weight.y = multiplier * (augment->_versor.y * start->_versor.s - augment->_versor.x * start->_versor.z + augment->_versor.z * start->_versor.x);
slerp->_sine_weight.z = multiplier * (augment->_versor.z * start->_versor.s - augment->_versor.y * start->_versor.x + augment->_versor.x * start->_versor.y);
}
void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const augment)
{
const double square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
const double square_vector = augment->_versor.x * augment->_versor.x + augment->_versor.y * augment->_versor.y + augment->_versor.z * augment->_versor.z;
if (isnan(square_vector)) {
bgc_fp64_slerp3_reset(slerp);
@ -72,15 +72,15 @@ void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* co
}
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
slerp->_cosine_weight.s0 = start->_versor.s0;
slerp->_cosine_weight.x1 = start->_versor.x1;
slerp->_cosine_weight.x2 = start->_versor.x2;
slerp->_cosine_weight.x3 = start->_versor.x3;
slerp->_cosine_weight.s = start->_versor.s;
slerp->_cosine_weight.x = start->_versor.x;
slerp->_cosine_weight.y = start->_versor.y;
slerp->_cosine_weight.z = start->_versor.z;
slerp->_sine_weight.s0 = 0.0;
slerp->_sine_weight.x1 = 0.0;
slerp->_sine_weight.x2 = 0.0;
slerp->_sine_weight.x3 = 0.0;
slerp->_sine_weight.s = 0.0;
slerp->_sine_weight.x = 0.0;
slerp->_sine_weight.y = 0.0;
slerp->_sine_weight.z = 0.0;
slerp->radians = 0.0;
return;
@ -88,17 +88,17 @@ void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* co
const double vector_modulus = sqrt(square_vector);
slerp->radians = atan2(vector_modulus, augment->_versor.s0);
slerp->radians = atan2(vector_modulus, augment->_versor.s);
const double multiplier = 1.0 / vector_modulus;
slerp->_cosine_weight.s0 = start->_versor.s0;
slerp->_cosine_weight.x1 = start->_versor.x1;
slerp->_cosine_weight.x2 = start->_versor.x2;
slerp->_cosine_weight.x3 = start->_versor.x3;
slerp->_cosine_weight.s = start->_versor.s;
slerp->_cosine_weight.x = start->_versor.x;
slerp->_cosine_weight.y = start->_versor.y;
slerp->_cosine_weight.z = start->_versor.z;
slerp->_sine_weight.s0 = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
slerp->_sine_weight.x1 = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
slerp->_sine_weight.x2 = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
slerp->_sine_weight.x3 = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
slerp->_sine_weight.s = -multiplier * (augment->_versor.x * start->_versor.x + augment->_versor.y * start->_versor.y + augment->_versor.z * start->_versor.z);
slerp->_sine_weight.x = multiplier * (augment->_versor.x * start->_versor.s + augment->_versor.y * start->_versor.z - augment->_versor.z * start->_versor.y);
slerp->_sine_weight.y = multiplier * (augment->_versor.y * start->_versor.s - augment->_versor.x * start->_versor.z + augment->_versor.z * start->_versor.x);
slerp->_sine_weight.z = multiplier * (augment->_versor.z * start->_versor.s - augment->_versor.y * start->_versor.x + augment->_versor.x * start->_versor.y);
}

View file

@ -9,30 +9,30 @@
inline void bgc_fp32_slerp3_reset(BGC_FP32_Slerp3* const slerp)
{
slerp->_cosine_weight.s0 = 1.0f;
slerp->_cosine_weight.x1 = 0.0f;
slerp->_cosine_weight.x2 = 0.0f;
slerp->_cosine_weight.x3 = 0.0f;
slerp->_cosine_weight.s = 1.0f;
slerp->_cosine_weight.x = 0.0f;
slerp->_cosine_weight.y = 0.0f;
slerp->_cosine_weight.z = 0.0f;
slerp->_sine_weight.s0 = 0.0f;
slerp->_sine_weight.x1 = 0.0f;
slerp->_sine_weight.x2 = 0.0f;
slerp->_sine_weight.x3 = 0.0f;
slerp->_sine_weight.s = 0.0f;
slerp->_sine_weight.x = 0.0f;
slerp->_sine_weight.y = 0.0f;
slerp->_sine_weight.z = 0.0f;
slerp->radians = 0.0f;
}
inline void bgc_fp64_slerp3_reset(BGC_FP64_Slerp3* const slerp)
{
slerp->_cosine_weight.s0 = 1.0;
slerp->_cosine_weight.x1 = 0.0;
slerp->_cosine_weight.x2 = 0.0;
slerp->_cosine_weight.x3 = 0.0;
slerp->_cosine_weight.s = 1.0;
slerp->_cosine_weight.x = 0.0;
slerp->_cosine_weight.y = 0.0;
slerp->_cosine_weight.z = 0.0;
slerp->_sine_weight.s0 = 0.0;
slerp->_sine_weight.x1 = 0.0;
slerp->_sine_weight.x2 = 0.0;
slerp->_sine_weight.x3 = 0.0;
slerp->_sine_weight.s = 0.0;
slerp->_sine_weight.x = 0.0;
slerp->_sine_weight.y = 0.0;
slerp->_sine_weight.z = 0.0;
slerp->radians = 0.0;
}

View file

@ -10,8 +10,8 @@ extern inline void bgc_fp64_turn2_reset(BGC_FP64_Turn2* const turn);
extern void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* const turn);
extern void _bgc_fp64_turn2_normalize(BGC_FP64_Turn2* const turn);
extern inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x1, const float x2);
extern inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x1, const double x2);
extern inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x, const float y);
extern inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x, const double y);
extern inline void bgc_fp32_turn2_set_angle(BGC_FP32_Turn2* const turn, const float angle, const int angle_unit);
extern inline void bgc_fp64_turn2_set_angle(BGC_FP64_Turn2* const turn, const double angle, const int angle_unit);

View file

@ -101,18 +101,18 @@ inline int bgc_fp64_turn2_is_idle(const BGC_FP64_Turn2* const turn)
// ==================== Set ===================== //
inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x1, const float x2)
inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x, const float y)
{
turn->_cos = x1;
turn->_sin = x2;
turn->_cos = x;
turn->_sin = y;
_bgc_fp32_turn2_normalize(turn);
}
inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x1, const double x2)
inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x, const double y)
{
turn->_cos = x1;
turn->_sin = x2;
turn->_cos = x;
turn->_sin = y;
_bgc_fp64_turn2_normalize(turn);
}
@ -347,40 +347,40 @@ inline void bgc_fp64_turn2_get_reverse_matrix(BGC_FP64_Matrix2x2* const matrix,
inline void bgc_fp32_turn2_vector(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
{
const float x1 = turn->_cos * vector->x1 - turn->_sin * vector->x2;
const float x2 = turn->_sin * vector->x1 + turn->_cos * vector->x2;
const float x = turn->_cos * vector->x - turn->_sin * vector->y;
const float y = turn->_sin * vector->x + turn->_cos * vector->y;
turned_vector->x1 = x1;
turned_vector->x2 = x2;
turned_vector->x = x;
turned_vector->y = y;
}
inline void bgc_fp64_turn2_vector(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
{
const double x1 = turn->_cos * vector->x1 - turn->_sin * vector->x2;
const double x2 = turn->_sin * vector->x1 + turn->_cos * vector->x2;
const double x = turn->_cos * vector->x - turn->_sin * vector->y;
const double y = turn->_sin * vector->x + turn->_cos * vector->y;
turned_vector->x1 = x1;
turned_vector->x2 = x2;
turned_vector->x = x;
turned_vector->y = y;
}
// ============ Turn Vector Backward ============ //
inline void bgc_fp32_turn2_vector_back(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
{
const float x1 = turn->_sin * vector->x2 + turn->_cos * vector->x1;
const float x2 = turn->_cos * vector->x2 - turn->_sin * vector->x1;
const float x = turn->_sin * vector->y + turn->_cos * vector->x;
const float y = turn->_cos * vector->y - turn->_sin * vector->x;
turned_vector->x1 = x1;
turned_vector->x2 = x2;
turned_vector->x = x;
turned_vector->y = y;
}
inline void bgc_fp64_turn2_vector_back(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
{
const double x1 = turn->_sin * vector->x2 + turn->_cos * vector->x1;
const double x2 = turn->_cos * vector->x2 - turn->_sin * vector->x1;
const double x = turn->_sin * vector->y + turn->_cos * vector->x;
const double y = turn->_cos * vector->y - turn->_sin * vector->x;
turned_vector->x1 = x1;
turned_vector->x2 = x2;
turned_vector->x = x;
turned_vector->y = y;
}
// ================== Are Close ================= //

View file

@ -12,8 +12,8 @@ extern inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn);
extern inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn);
extern inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn);
extern inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s0, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s0, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s, const float x, const float y, const float z);
extern inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s, const double x, const double y, const double z);
extern inline void bgc_fp32_turn3_get_quaternion(BGC_FP32_Quaternion* const quaternion, const BGC_FP32_Turn3* const turn);
extern inline void bgc_fp64_turn3_get_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Turn3* const turn);
@ -82,7 +82,7 @@ extern inline int bgc_fp64_turn3_are_close(const BGC_FP64_Turn3* const turn1, co
float bgc_fp32_turn3_get_rotation(BGC_FP32_Vector3* const axis, const BGC_FP32_Turn3* const turn, const int angle_unit)
{
const float square_vector_modulus = turn->_versor.x1 * turn->_versor.x1 + turn->_versor.x2 * turn->_versor.x2 + turn->_versor.x3 * turn->_versor.x3;
const float square_vector_modulus = turn->_versor.x * turn->_versor.x + turn->_versor.y * turn->_versor.y + turn->_versor.z * turn->_versor.z;
if (square_vector_modulus <= BGC_FP32_SQUARE_EPSILON) {
bgc_fp32_vector3_reset(axis);
@ -93,16 +93,16 @@ float bgc_fp32_turn3_get_rotation(BGC_FP32_Vector3* const axis, const BGC_FP32_T
const float multiplier = 1.0f / vector_modulus;
axis->x1 = turn->_versor.x1 * multiplier;
axis->x2 = turn->_versor.x2 * multiplier;
axis->x3 = turn->_versor.x3 * multiplier;
axis->x = turn->_versor.x * multiplier;
axis->y = turn->_versor.y * multiplier;
axis->z = turn->_versor.z * multiplier;
return 2.0f * atan2f(vector_modulus, turn->_versor.s0);
return 2.0f * atan2f(vector_modulus, turn->_versor.s);
}
double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_Turn3* const turn, const int angle_unit)
{
const double square_vector_modulus = turn->_versor.x1 * turn->_versor.x1 + turn->_versor.x2 * turn->_versor.x2 + turn->_versor.x3 * turn->_versor.x3;
const double square_vector_modulus = turn->_versor.x * turn->_versor.x + turn->_versor.y * turn->_versor.y + turn->_versor.z * turn->_versor.z;
if (square_vector_modulus <= BGC_FP64_SQUARE_EPSILON) {
bgc_fp64_vector3_reset(axis);
@ -113,18 +113,18 @@ double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_
const double multiplier = 1.0 / vector_modulus;
axis->x1 = turn->_versor.x1 * multiplier;
axis->x2 = turn->_versor.x2 * multiplier;
axis->x3 = turn->_versor.x3 * multiplier;
axis->x = turn->_versor.x * multiplier;
axis->y = turn->_versor.y * multiplier;
axis->z = turn->_versor.z * multiplier;
return 2.0 * atan2(vector_modulus, turn->_versor.s0);
return 2.0 * atan2(vector_modulus, turn->_versor.s);
}
// ================ Set Rotation ================ //
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, const float x2, const float x3, const float angle, const int angle_unit)
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x, const float y, const float z, const float angle, const int angle_unit)
{
const float square_vector = x1 * x1 + x2 * x2 + x3 * x3;
const float square_vector = x * x + y * y + z * z;
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
bgc_fp32_turn3_reset(turn);
@ -142,14 +142,14 @@ void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, con
const float multiplier = sine / sqrtf(square_vector);
bgc_fp32_quaternion_set_values(&turn->_versor, cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier);
bgc_fp32_quaternion_set_values(&turn->_versor, cosf(half_angle), x * multiplier, y * multiplier, z * multiplier);
_bgc_fp32_turn3_normalize(turn);
}
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, const double x2, const double x3, const double angle, const int angle_unit)
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x, const double y, const double z, const double angle, const int angle_unit)
{
const double square_vector = x1 * x1 + x2 * x2 + x3 * x3;
const double square_vector = x * x + y * y + z * z;
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
bgc_fp64_turn3_reset(turn);
@ -167,7 +167,7 @@ void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, co
const double multiplier = sine / sqrt(square_vector);
bgc_fp64_quaternion_set_values(&turn->_versor, cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier);
bgc_fp64_quaternion_set_values(&turn->_versor, cos(half_angle), x * multiplier, y * multiplier, z * multiplier);
_bgc_fp64_turn3_normalize(turn);
}
@ -210,7 +210,7 @@ int bgc_fp32_turn3_find_direction_difference(BGC_FP32_Turn3* const turn, const B
const float vector_multiplier = sinf(angle) / axis_modulus;
bgc_fp32_turn3_set_values(turn, cosf(angle), axis.x1 * vector_multiplier, axis.x2 * vector_multiplier, axis.x3 * vector_multiplier);
bgc_fp32_turn3_set_values(turn, cosf(angle), axis.x * vector_multiplier, axis.y * vector_multiplier, axis.z * vector_multiplier);
return BGC_SUCCESS;
}
@ -251,7 +251,7 @@ int bgc_fp64_turn3_find_direction_difference(BGC_FP64_Turn3* const turn, const B
const double vector_multiplier = sin(angle) / axis_modulus;
bgc_fp64_turn3_set_values(turn, cos(angle), axis.x1 * vector_multiplier, axis.x2 * vector_multiplier, axis.x3 * vector_multiplier);
bgc_fp64_turn3_set_values(turn, cos(angle), axis.x * vector_multiplier, axis.y * vector_multiplier, axis.z * vector_multiplier);
return BGC_SUCCESS;
}
@ -332,18 +332,18 @@ static inline void _bgc_fp32_turn3_get_turning_quaternion(BGC_FP32_Quaternion* c
if (axis_square_modulus <= BGC_FP32_SQUARE_EPSILON) {
// unit_start and unit_end are co-directional, angle = 180 degrees
if (dot_product >= 0.0f) {
quaternion->s0 = 1.0f;
quaternion->x1 = 0.0f;
quaternion->x2 = 0.0f;
quaternion->x3 = 0.0f;
quaternion->s = 1.0f;
quaternion->x = 0.0f;
quaternion->y = 0.0f;
quaternion->z = 0.0f;
return;
}
// unit_start and unit_end are opposite, angle = 180 degrees
quaternion->s0 = 0.0f;
quaternion->x1 = unit_orthogonal->x1;
quaternion->x2 = unit_orthogonal->x2;
quaternion->x3 = unit_orthogonal->x3;
quaternion->s = 0.0f;
quaternion->x = unit_orthogonal->x;
quaternion->y = unit_orthogonal->y;
quaternion->z = unit_orthogonal->z;
return;
}
@ -353,10 +353,10 @@ static inline void _bgc_fp32_turn3_get_turning_quaternion(BGC_FP32_Quaternion* c
const float multiplier = sinf(angle) / axis_modulus;
quaternion->s0 = cosf(angle);
quaternion->x1 = axis.x1 * multiplier;
quaternion->x2 = axis.x2 * multiplier;
quaternion->x3 = axis.x3 * multiplier;
quaternion->s = cosf(angle);
quaternion->x = axis.x * multiplier;
quaternion->y = axis.y * multiplier;
quaternion->z = axis.z * multiplier;
}
static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Vector3* const unit_start, const BGC_FP64_Vector3* const unit_end, const BGC_FP64_Vector3* const unit_orthogonal)
@ -373,18 +373,18 @@ static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* c
if (axis_square_modulus <= BGC_FP64_SQUARE_EPSILON) {
// unit_start and unit_end are co-directional, angle = 180 degrees
if (dot_product >= 0.0) {
quaternion->s0 = 1.0;
quaternion->x1 = 0.0;
quaternion->x2 = 0.0;
quaternion->x3 = 0.0;
quaternion->s = 1.0;
quaternion->x = 0.0;
quaternion->y = 0.0;
quaternion->z = 0.0;
return;
}
// unit_start and unit_end are opposite, angle = 180 degrees
quaternion->s0 = 0.0;
quaternion->x1 = unit_orthogonal->x1;
quaternion->x2 = unit_orthogonal->x2;
quaternion->x3 = unit_orthogonal->x3;
quaternion->s = 0.0;
quaternion->x = unit_orthogonal->x;
quaternion->y = unit_orthogonal->y;
quaternion->z = unit_orthogonal->z;
return;
}
@ -394,10 +394,10 @@ static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* c
const double multiplier = sin(angle) / axis_modulus;
quaternion->s0 = cos(angle);
quaternion->x1 = axis.x1 * multiplier;
quaternion->x2 = axis.x2 * multiplier;
quaternion->x3 = axis.x3 * multiplier;
quaternion->s = cos(angle);
quaternion->x = axis.x * multiplier;
quaternion->y = axis.y * multiplier;
quaternion->z = axis.z * multiplier;
}
// ============ Make Pair Difference ============ //
@ -492,7 +492,7 @@ int bgc_fp64_turn3_find_pair_difference(
void bgc_fp32_turn3_get_power(BGC_FP32_Turn3* const power, const BGC_FP32_Turn3* const base, const float exponent)
{
const float square_vector = base->_versor.x1 * base->_versor.x1 + base->_versor.x2 * base->_versor.x2 + base->_versor.x3 * base->_versor.x3;
const float square_vector = base->_versor.x * base->_versor.x + base->_versor.y * base->_versor.y + base->_versor.z * base->_versor.z;
if (square_vector <= BGC_FP32_SQUARE_EPSILON || square_vector != square_vector) {
bgc_fp32_turn3_reset(power);
@ -501,16 +501,16 @@ void bgc_fp32_turn3_get_power(BGC_FP32_Turn3* const power, const BGC_FP32_Turn3*
const float vector_modulus = sqrtf(square_vector);
const float angle = atan2f(vector_modulus, base->_versor.s0) * exponent;
const float angle = atan2f(vector_modulus, base->_versor.s) * exponent;
const float multiplier = sinf(angle) / vector_modulus;
bgc_fp32_turn3_set_values(power, cosf(angle), base->_versor.x1 * multiplier, base->_versor.x2 * multiplier, base->_versor.x3 * multiplier);
bgc_fp32_turn3_set_values(power, cosf(angle), base->_versor.x * multiplier, base->_versor.y * multiplier, base->_versor.z * multiplier);
}
void bgc_fp64_turn3_get_power(BGC_FP64_Turn3* const power, const BGC_FP64_Turn3* const base, const double exponent)
{
const double square_vector = base->_versor.x1 * base->_versor.x1 + base->_versor.x2 * base->_versor.x2 + base->_versor.x3 * base->_versor.x3;
const double square_vector = base->_versor.x * base->_versor.x + base->_versor.y * base->_versor.y + base->_versor.z * base->_versor.z;
if (square_vector <= BGC_FP64_SQUARE_EPSILON || square_vector != square_vector) {
bgc_fp64_turn3_reset(power);
@ -519,23 +519,23 @@ void bgc_fp64_turn3_get_power(BGC_FP64_Turn3* const power, const BGC_FP64_Turn3*
const double vector_modulus = sqrt(square_vector);
const double angle = atan2(vector_modulus, base->_versor.s0) * exponent;
const double angle = atan2(vector_modulus, base->_versor.s) * exponent;
const double multiplier = sin(angle) / vector_modulus;
bgc_fp64_turn3_set_values(power, cos(angle), base->_versor.x1 * multiplier, base->_versor.x2 * multiplier, base->_versor.x3 * multiplier);
bgc_fp64_turn3_set_values(power, cos(angle), base->_versor.x * multiplier, base->_versor.y * multiplier, base->_versor.z * multiplier);
}
// ============ Sphere Interpolation ============ //
void bgc_fp32_turn3_spherically_interpolate(BGC_FP32_Turn3* const interpolation, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const end, const float phase)
{
const float delta_s0 = (end->_versor.s0 * start->_versor.s0 + end->_versor.x1 * start->_versor.x1) + (end->_versor.x2 * start->_versor.x2 + end->_versor.x3 * start->_versor.x3);
const float delta_x1 = (end->_versor.x1 * start->_versor.s0 + end->_versor.x3 * start->_versor.x2) - (end->_versor.s0 * start->_versor.x1 + end->_versor.x2 * start->_versor.x3);
const float delta_x2 = (end->_versor.x2 * start->_versor.s0 + end->_versor.x1 * start->_versor.x3) - (end->_versor.s0 * start->_versor.x2 + end->_versor.x3 * start->_versor.x1);
const float delta_x3 = (end->_versor.x3 * start->_versor.s0 + end->_versor.x2 * start->_versor.x1) - (end->_versor.s0 * start->_versor.x3 + end->_versor.x1 * start->_versor.x2);
const float delta_s = (end->_versor.s * start->_versor.s + end->_versor.x * start->_versor.x) + (end->_versor.y * start->_versor.y + end->_versor.z * start->_versor.z);
const float delta_x = (end->_versor.x * start->_versor.s + end->_versor.z * start->_versor.y) - (end->_versor.s * start->_versor.x + end->_versor.y * start->_versor.z);
const float delta_y = (end->_versor.y * start->_versor.s + end->_versor.x * start->_versor.z) - (end->_versor.s * start->_versor.y + end->_versor.z * start->_versor.x);
const float delta_z = (end->_versor.z * start->_versor.s + end->_versor.y * start->_versor.x) - (end->_versor.s * start->_versor.z + end->_versor.x * start->_versor.y);
const float square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
const float square_vector = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z;
// square_vector != square_vector means checking for NaN value at square_vector
if (square_vector <= BGC_FP32_SQUARE_EPSILON || isnan(square_vector)) {
@ -545,32 +545,32 @@ void bgc_fp32_turn3_spherically_interpolate(BGC_FP32_Turn3* const interpolation,
// Calculating of the turning which fits the phase:
const float vector_modulus = sqrtf(square_vector);
const float angle = atan2f(vector_modulus, delta_s0) * phase;
const float angle = atan2f(vector_modulus, delta_s) * phase;
const float multiplier = sinf(angle) / vector_modulus;
const float turn_s0 = cosf(angle);
const float turn_x1 = delta_x1 * multiplier;
const float turn_x2 = delta_x2 * multiplier;
const float turn_x3 = delta_x3 * multiplier;
const float turn_s = cosf(angle);
const float turn_x = delta_x * multiplier;
const float turn_y = delta_y * multiplier;
const float turn_z = delta_z * multiplier;
// Combining of starting orientation with the turning
bgc_fp32_turn3_set_values(
interpolation,
(turn_s0 * start->_versor.s0 - turn_x1 * start->_versor.x1) - (turn_x2 * start->_versor.x2 + turn_x3 * start->_versor.x3),
(turn_x1 * start->_versor.s0 + turn_s0 * start->_versor.x1) - (turn_x3 * start->_versor.x2 - turn_x2 * start->_versor.x3),
(turn_x2 * start->_versor.s0 + turn_s0 * start->_versor.x2) - (turn_x1 * start->_versor.x3 - turn_x3 * start->_versor.x1),
(turn_x3 * start->_versor.s0 + turn_s0 * start->_versor.x3) - (turn_x2 * start->_versor.x1 - turn_x1 * start->_versor.x2)
(turn_s * start->_versor.s - turn_x * start->_versor.x) - (turn_y * start->_versor.y + turn_z * start->_versor.z),
(turn_x * start->_versor.s + turn_s * start->_versor.x) - (turn_z * start->_versor.y - turn_y * start->_versor.z),
(turn_y * start->_versor.s + turn_s * start->_versor.y) - (turn_x * start->_versor.z - turn_z * start->_versor.x),
(turn_z * start->_versor.s + turn_s * start->_versor.z) - (turn_y * start->_versor.x - turn_x * start->_versor.y)
);
}
void bgc_fp64_turn3_spherically_interpolate(BGC_FP64_Turn3* const interpolation, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const end, const double phase)
{
const double delta_s0 = (end->_versor.s0 * start->_versor.s0 + end->_versor.x1 * start->_versor.x1) + (end->_versor.x2 * start->_versor.x2 + end->_versor.x3 * start->_versor.x3);
const double delta_x1 = (end->_versor.x1 * start->_versor.s0 + end->_versor.x3 * start->_versor.x2) - (end->_versor.s0 * start->_versor.x1 + end->_versor.x2 * start->_versor.x3);
const double delta_x2 = (end->_versor.x2 * start->_versor.s0 + end->_versor.x1 * start->_versor.x3) - (end->_versor.s0 * start->_versor.x2 + end->_versor.x3 * start->_versor.x1);
const double delta_x3 = (end->_versor.x3 * start->_versor.s0 + end->_versor.x2 * start->_versor.x1) - (end->_versor.s0 * start->_versor.x3 + end->_versor.x1 * start->_versor.x2);
const double delta_s = (end->_versor.s * start->_versor.s + end->_versor.x * start->_versor.x) + (end->_versor.y * start->_versor.y + end->_versor.z * start->_versor.z);
const double delta_x = (end->_versor.x * start->_versor.s + end->_versor.z * start->_versor.y) - (end->_versor.s * start->_versor.x + end->_versor.y * start->_versor.z);
const double delta_y = (end->_versor.y * start->_versor.s + end->_versor.x * start->_versor.z) - (end->_versor.s * start->_versor.y + end->_versor.z * start->_versor.x);
const double delta_z = (end->_versor.z * start->_versor.s + end->_versor.y * start->_versor.x) - (end->_versor.s * start->_versor.z + end->_versor.x * start->_versor.y);
const double square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
const double square_vector = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z;
// square_vector != square_vector means checking for NaN value at square_vector
if (square_vector <= BGC_FP64_SQUARE_EPSILON || isnan(square_vector)) {
@ -580,20 +580,20 @@ void bgc_fp64_turn3_spherically_interpolate(BGC_FP64_Turn3* const interpolation,
// Calculating of the turning which fits the phase:
const double vector_modulus = sqrt(square_vector);
const double angle = atan2(vector_modulus, delta_s0) * phase;
const double angle = atan2(vector_modulus, delta_s) * phase;
const double multiplier = sin(angle) / vector_modulus;
const double turn_s0 = cos(angle);
const double turn_x1 = delta_x1 * multiplier;
const double turn_x2 = delta_x2 * multiplier;
const double turn_x3 = delta_x3 * multiplier;
const double turn_s = cos(angle);
const double turn_x = delta_x * multiplier;
const double turn_y = delta_y * multiplier;
const double turn_z = delta_z * multiplier;
// Combining of starting orientation with the turning
bgc_fp64_turn3_set_values(
interpolation,
(turn_s0 * start->_versor.s0 - turn_x1 * start->_versor.x1) - (turn_x2 * start->_versor.x2 + turn_x3 * start->_versor.x3),
(turn_x1 * start->_versor.s0 + turn_s0 * start->_versor.x1) - (turn_x3 * start->_versor.x2 - turn_x2 * start->_versor.x3),
(turn_x2 * start->_versor.s0 + turn_s0 * start->_versor.x2) - (turn_x1 * start->_versor.x3 - turn_x3 * start->_versor.x1),
(turn_x3 * start->_versor.s0 + turn_s0 * start->_versor.x3) - (turn_x2 * start->_versor.x1 - turn_x1 * start->_versor.x2)
(turn_s * start->_versor.s - turn_x * start->_versor.x) - (turn_y * start->_versor.y + turn_z * start->_versor.z),
(turn_x * start->_versor.s + turn_s * start->_versor.x) - (turn_z * start->_versor.y - turn_y * start->_versor.z),
(turn_y * start->_versor.s + turn_s * start->_versor.y) - (turn_x * start->_versor.z - turn_z * start->_versor.x),
(turn_z * start->_versor.s + turn_s * start->_versor.z) - (turn_y * start->_versor.x - turn_x * start->_versor.y)
);
}

View file

@ -36,18 +36,18 @@ extern const BGC_FP64_Turn3 BGC_FP64_IDLE_TURN3;
inline void bgc_fp32_turn3_reset(BGC_FP32_Turn3* const turn)
{
turn->_versor.s0 = 1.0f;
turn->_versor.x1 = 0.0f;
turn->_versor.x2 = 0.0f;
turn->_versor.x3 = 0.0f;
turn->_versor.s = 1.0f;
turn->_versor.x = 0.0f;
turn->_versor.y = 0.0f;
turn->_versor.z = 0.0f;
}
inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn)
{
turn->_versor.s0 = 1.0;
turn->_versor.x1 = 0.0;
turn->_versor.x2 = 0.0;
turn->_versor.x3 = 0.0;
turn->_versor.s = 1.0;
turn->_versor.x = 0.0;
turn->_versor.y = 0.0;
turn->_versor.z = 0.0;
}
// ============= Private: Normalize ============= //
@ -61,19 +61,19 @@ inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn)
}
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
turn->_versor.s0 = 1.0f;
turn->_versor.x1 = 0.0f;
turn->_versor.x2 = 0.0f;
turn->_versor.x3 = 0.0f;
turn->_versor.s = 1.0f;
turn->_versor.x = 0.0f;
turn->_versor.y = 0.0f;
turn->_versor.z = 0.0f;
return;
}
const float multiplier = sqrtf(1.0f / square_magnitude);
turn->_versor.s0 *= multiplier;
turn->_versor.x1 *= multiplier;
turn->_versor.x2 *= multiplier;
turn->_versor.x3 *= multiplier;
turn->_versor.s *= multiplier;
turn->_versor.x *= multiplier;
turn->_versor.y *= multiplier;
turn->_versor.z *= multiplier;
}
inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
@ -85,32 +85,32 @@ inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
}
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
turn->_versor.s0 = 1.0;
turn->_versor.x1 = 0.0;
turn->_versor.x2 = 0.0;
turn->_versor.x3 = 0.0;
turn->_versor.s = 1.0;
turn->_versor.x = 0.0;
turn->_versor.y = 0.0;
turn->_versor.z = 0.0;
return;
}
const double multiplier = sqrt(1.0 / square_magnitude);
turn->_versor.s0 *= multiplier;
turn->_versor.x1 *= multiplier;
turn->_versor.x2 *= multiplier;
turn->_versor.x3 *= multiplier;
turn->_versor.s *= multiplier;
turn->_versor.x *= multiplier;
turn->_versor.y *= multiplier;
turn->_versor.z *= multiplier;
}
// ================= Set Values ================= //
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s0, const float x1, const float x2, const float x3)
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s, const float x, const float y, const float z)
{
bgc_fp32_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
bgc_fp32_quaternion_set_values(&turn->_versor, s, x, y, z);
_bgc_fp32_turn3_normalize(turn);
}
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s0, const double x1, const double x2, const double x3)
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s, const double x, const double y, const double z)
{
bgc_fp64_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
bgc_fp64_quaternion_set_values(&turn->_versor, s, x, y, z);
_bgc_fp64_turn3_normalize(turn);
}
@ -148,9 +148,9 @@ double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_
// ================ Set Rotation ================ //
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, const float x2, const float x3, const float angle, const int angle_unit);
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x, const float y, const float z, const float angle, const int angle_unit);
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, const double x2, const double x3, const double angle, const int angle_unit);
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x, const double y, const double z, const double angle, const int angle_unit);
// ========= Find Direction Difference ========== //
@ -231,21 +231,21 @@ inline void bgc_fp64_turn3_convert_to_fp32(BGC_FP32_Turn3* const destination, co
inline void bgc_fp32_turn3_shorten(BGC_FP32_Turn3* const turn)
{
if (turn->_versor.s0 < 0.0f) {
if (turn->_versor.s < 0.0f) {
bgc_fp32_quaternion_revert(&turn->_versor);
}
}
inline void bgc_fp64_turn3_shorten(BGC_FP64_Turn3* const turn)
{
if (turn->_versor.s0 < 0.0) {
if (turn->_versor.s < 0.0) {
bgc_fp64_quaternion_revert(&turn->_versor);
}
}
inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const BGC_FP32_Turn3* const turn)
{
if (turn->_versor.s0 >= 0.0f) {
if (turn->_versor.s >= 0.0f) {
bgc_fp32_quaternion_copy(&shortened->_versor, &turn->_versor);
}
else {
@ -255,7 +255,7 @@ inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const
inline void bgc_fp64_turn3_get_shortened(BGC_FP64_Turn3* const shortened, const BGC_FP64_Turn3* const turn)
{
if (turn->_versor.s0 >= 0.0) {
if (turn->_versor.s >= 0.0) {
bgc_fp64_quaternion_copy(&shortened->_versor, &turn->_versor);
}
else {

View file

@ -5,24 +5,24 @@
typedef struct
{
float x1, x2;
float x, y;
} BGC_FP32_Vector2;
typedef struct
{
double x1, x2;
double x, y;
} BGC_FP64_Vector2;
// ================== Vector3 =================== //
typedef struct
{
float x1, x2, x3;
float x, y, z;
} BGC_FP32_Vector3;
typedef struct
{
double x1, x2, x3;
double x, y, z;
} BGC_FP64_Vector3;
// ================== Matrix2x2 ================= //
@ -128,11 +128,11 @@ typedef struct
// ================= Quaternion ================= //
typedef struct {
float s0, x1, x2, x3;
float s, x, y, z;
} BGC_FP32_Quaternion;
typedef struct {
double s0, x1, x2, x3;
double s, x, y, z;
} BGC_FP64_Quaternion;
// =================== Turn3 ==================== //

View file

@ -3,8 +3,8 @@
extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector);
extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector);
extern inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x1, const float x2);
extern inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x1, const double x2);
extern inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
extern inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
extern inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector);
extern inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector);

View file

@ -11,40 +11,40 @@
inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector)
{
vector->x1 = 0.0f;
vector->x2 = 0.0f;
vector->x = 0.0f;
vector->y = 0.0f;
}
inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector)
{
vector->x1 = 0.0;
vector->x2 = 0.0;
vector->x = 0.0;
vector->y = 0.0;
}
// ==================== Set ===================== //
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x1, const float x2)
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y)
{
destination->x1 = x1;
destination->x2 = x2;
destination->x = x;
destination->y = y;
}
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x1, const double x2)
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y)
{
destination->x1 = x1;
destination->x2 = x2;
destination->x = x;
destination->y = y;
}
// ================== Modulus =================== //
inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector)
{
return vector->x1 * vector->x1 + vector->x2 * vector->x2;
return vector->x * vector->x + vector->y * vector->y;
}
inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector)
{
return vector->x1 * vector->x1 + vector->x2 * vector->x2;
return vector->x * vector->x + vector->y * vector->y;
}
inline float bgc_fp32_vector2_get_length(const BGC_FP32_Vector2* const vector)
@ -83,160 +83,160 @@ inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* const vector)
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x = source->x;
destination->y = source->y;
}
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x = source->x;
destination->y = source->y;
}
// ==================== Swap ==================== //
inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2)
{
const float x1 = vector2->x1;
const float x2 = vector2->x2;
const float x = vector2->x;
const float y = vector2->y;
vector2->x1 = vector1->x1;
vector2->x2 = vector1->x2;
vector2->x = vector1->x;
vector2->y = vector1->y;
vector1->x1 = x1;
vector1->x2 = x2;
vector1->x = x;
vector1->y = y;
}
inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* const vector2)
{
const double x1 = vector2->x1;
const double x2 = vector2->x2;
const double x = vector2->x;
const double y = vector2->y;
vector2->x1 = vector1->x1;
vector2->x2 = vector1->x2;
vector2->x = vector1->x;
vector2->y = vector1->y;
vector1->x1 = x1;
vector1->x2 = x2;
vector1->x = x;
vector1->y = y;
}
// ================== Convert =================== //
inline void bgc_fp32_vector2_convert_to_fp64(BGC_FP64_Vector2* const destination, const BGC_FP32_Vector2* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x = source->x;
destination->y = source->y;
}
inline void bgc_fp64_vector2_convert_to_fp32(BGC_FP32_Vector2* const destination, const BGC_FP64_Vector2* const source)
{
destination->x1 = (float)source->x1;
destination->x2 = (float)source->x2;
destination->x = (float)source->x;
destination->y = (float)source->y;
}
// ==================== Add ===================== //
inline void bgc_fp32_vector2_add(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
{
sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2;
sum->x = vector1->x + vector2->x;
sum->y = vector1->y + vector2->y;
}
inline void bgc_fp64_vector2_add(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
{
sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2;
sum->x = vector1->x + vector2->x;
sum->y = vector1->y + vector2->y;
}
// ================= Add Scaled ================= //
inline void bgc_fp32_vector2_add_scaled(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
{
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
sum->x = basic_vector->x + scalable_vector->x * scale;
sum->y = basic_vector->y + scalable_vector->y * scale;
}
inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
{
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
sum->x = basic_vector->x + scalable_vector->x * scale;
sum->y = basic_vector->y + scalable_vector->y * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const minuend, const BGC_FP32_Vector2* const subtrahend)
{
difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2;
difference->x = minuend->x - subtrahend->x;
difference->y = minuend->y - subtrahend->y;
}
inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const minuend, const BGC_FP64_Vector2* const subtrahend)
{
difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2;
difference->x = minuend->x - subtrahend->x;
difference->y = minuend->y - subtrahend->y;
}
// ============== Subtract Scaled =============== //
inline void bgc_fp32_vector2_subtract_scaled(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
{
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
difference->x = basic_vector->x - scalable_vector->x * scale;
difference->y = basic_vector->y - scalable_vector->y * scale;
}
inline void bgc_fp64_vector2_subtract_scaled(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
{
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
difference->x = basic_vector->x - scalable_vector->x * scale;
difference->y = basic_vector->y - scalable_vector->y * scale;
}
// ================== Multiply ================== //
inline void bgc_fp32_vector2_multiply_by_real_number(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const multiplicand, const float multiplier)
{
product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier;
product->x = multiplicand->x * multiplier;
product->y = multiplicand->y * multiplier;
}
inline void bgc_fp64_vector2_multiply_by_real_number(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const multiplicand, const double multiplier)
{
product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier;
product->x = multiplicand->x * multiplier;
product->y = multiplicand->y * multiplier;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_vector2_multiply_by_matrix2x2(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix2x2* const matrix)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
const float x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
const float y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
product->x = x;
product->y = y;
}
inline void bgc_fp64_vector2_multiply_by_matrix2x2(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix2x2* const matrix)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
const double x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
const double y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
product->x = x;
product->y = y;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_vector2_multiply_by_matrix3x2(BGC_FP32_Vector3* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix3x2* const matrix)
{
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
product->z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3;
}
inline void bgc_fp64_vector2_multiply_by_matrix3x2(BGC_FP64_Vector3* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix3x2* const matrix)
{
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
product->z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3;
}
// =================== Divide =================== //
@ -267,28 +267,28 @@ inline int bgc_fp64_vector2_divide_by_real_number(BGC_FP64_Vector2* const quotie
inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
{
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f;
mean->x = (vector1->x + vector2->x) * 0.5f;
mean->y = (vector1->y + vector2->y) * 0.5f;
}
inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
{
mean->x1 = (vector1->x1 + vector2->x1) * 0.5;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5;
mean->x = (vector1->x + vector2->x) * 0.5;
mean->y = (vector1->y + vector2->y) * 0.5;
}
// =============== Mean of Three ================ //
inline void bgc_fp32_vector2_get_mean3(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2, const BGC_FP32_Vector2* const vector3)
{
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP32_ONE_THIRD;
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_vector2_get_mean3(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2, const BGC_FP64_Vector2* const vector3)
{
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP64_ONE_THIRD;
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP64_ONE_THIRD;
}
// =================== Linear =================== //
@ -297,42 +297,42 @@ inline void bgc_fp32_vector2_interpolate(BGC_FP32_Vector2* const interpolation,
{
const float counter_phase = 1.0f - phase;
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
interpolation->x = first->x * counter_phase + second->x * phase;
interpolation->y = first->y * counter_phase + second->y * phase;
}
inline void bgc_fp64_vector2_interpolate(BGC_FP64_Vector2* const interpolation, const BGC_FP64_Vector2* const first, const BGC_FP64_Vector2* const second, const double phase)
{
const double counter_phase = 1.0 - phase;
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
interpolation->x = first->x * counter_phase + second->x * phase;
interpolation->y = first->y * counter_phase + second->y * phase;
}
// ================== Negative ================== //
inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* const vector)
{
vector->x1 = -vector->x1;
vector->x2 = -vector->x2;
vector->x = -vector->x;
vector->y = -vector->y;
}
inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* const vector)
{
vector->x1 = -vector->x1;
vector->x2 = -vector->x2;
vector->x = -vector->x;
vector->y = -vector->y;
}
inline void bgc_fp32_vector2_get_reverse(BGC_FP32_Vector2* const reverse, const BGC_FP32_Vector2* const vector)
{
reverse->x1 = -vector->x1;
reverse->x2 = -vector->x2;
reverse->x = -vector->x;
reverse->y = -vector->y;
}
inline void bgc_fp64_vector2_get_reverse(BGC_FP64_Vector2* const reverse, const BGC_FP64_Vector2* const vector)
{
reverse->x1 = -vector->x1;
reverse->x2 = -vector->x2;
reverse->x = -vector->x;
reverse->y = -vector->y;
}
// ================= Normalize ================== //
@ -351,8 +351,8 @@ inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* const vector)
const float multiplier = sqrtf(1.0f / square_modulus);
vector->x1 *= multiplier;
vector->x2 *= multiplier;
vector->x *= multiplier;
vector->y *= multiplier;
return BGC_SUCCESS;
}
@ -371,8 +371,8 @@ inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* const vector)
const double multiplier = sqrt(1.0 / square_modulus);
vector->x1 *= multiplier;
vector->x2 *= multiplier;
vector->x *= multiplier;
vector->y *= multiplier;
return BGC_SUCCESS;
}
@ -417,24 +417,24 @@ inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* const normalized, c
inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
{
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
return vector1->x * vector2->x + vector1->y * vector2->y;
}
inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
{
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
return vector1->x * vector2->x + vector1->y * vector2->y;
}
// ============= Get Cross Product ============== //
inline float bgc_fp32_vector2_get_cross_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
{
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
return vector1->x * vector2->y - vector1->y * vector2->x;
}
inline double bgc_fp64_vector2_get_cross_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
{
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
return vector1->x * vector2->y - vector1->y * vector2->x;
}
// ================= Get Angle ================== //
@ -447,18 +447,18 @@ double bgc_fp64_vector2_get_angle(const BGC_FP64_Vector2* const vector1, const B
inline float bgc_fp32_vector2_get_square_distance(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
{
const float dx1 = vector1->x1 - vector2->x1;
const float dx2 = vector1->x2 - vector2->x2;
const float dx = vector1->x - vector2->x;
const float dy = vector1->y - vector2->y;
return dx1 * dx1 + dx2 * dx2;
return dx * dx + dy * dy;
}
inline double bgc_fp64_vector2_get_square_distance(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
{
const double dx1 = vector1->x1 - vector2->x1;
const double dx2 = vector1->x2 - vector2->x2;
const double dx = vector1->x - vector2->x;
const double dy = vector1->y - vector2->y;
return dx1 * dx1 + dx2 * dx2;
return dx * dx + dy * dy;
}
// ================== Distance ================== //

View file

@ -3,8 +3,8 @@
extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector);
extern inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
extern inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
extern inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector);
extern inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector);

View file

@ -11,44 +11,44 @@
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector)
{
vector->x1 = 0.0f;
vector->x2 = 0.0f;
vector->x3 = 0.0f;
vector->x = 0.0f;
vector->y = 0.0f;
vector->z = 0.0f;
}
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector)
{
vector->x1 = 0.0;
vector->x2 = 0.0;
vector->x3 = 0.0;
vector->x = 0.0;
vector->y = 0.0;
vector->z = 0.0;
}
// ==================== Set ===================== //
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x1, const float x2, const float x3)
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z)
{
destination->x1 = x1;
destination->x2 = x2;
destination->x3 = x3;
destination->x = x;
destination->y = y;
destination->z = z;
}
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x1, const double x2, const double x3)
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z)
{
destination->x1 = x1;
destination->x2 = x2;
destination->x3 = x3;
destination->x = x;
destination->y = y;
destination->z = z;
}
// ================== Modulus =================== //
inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector)
{
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
return vector->x * vector->x + vector->y * vector->y + vector->z * vector->z;
}
inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector)
{
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
return vector->x * vector->x + vector->y * vector->y + vector->z * vector->z;
}
inline float bgc_fp32_vector3_get_length(const BGC_FP32_Vector3* const vector)
@ -87,246 +87,246 @@ inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* const vector)
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x3 = source->x3;
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
}
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x3 = source->x3;
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
}
// ==================== Swap ==================== //
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2)
{
const float x1 = vector2->x1;
const float x2 = vector2->x2;
const float x3 = vector2->x3;
const float x = vector2->x;
const float y = vector2->y;
const float z = vector2->z;
vector2->x1 = vector1->x1;
vector2->x2 = vector1->x2;
vector2->x3 = vector1->x3;
vector2->x = vector1->x;
vector2->y = vector1->y;
vector2->z = vector1->z;
vector1->x1 = x1;
vector1->x2 = x2;
vector1->x3 = x3;
vector1->x = x;
vector1->y = y;
vector1->z = z;
}
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2)
{
const double x1 = vector2->x1;
const double x2 = vector2->x2;
const double x3 = vector2->x3;
const double x = vector2->x;
const double y = vector2->y;
const double z = vector2->z;
vector2->x1 = vector1->x1;
vector2->x2 = vector1->x2;
vector2->x3 = vector1->x3;
vector2->x = vector1->x;
vector2->y = vector1->y;
vector2->z = vector1->z;
vector1->x1 = x1;
vector1->x2 = x2;
vector1->x3 = x3;
vector1->x = x;
vector1->y = y;
vector1->z = z;
}
// ================== Convert =================== //
inline void bgc_fp32_vector3_convert_to_fp64(BGC_FP64_Vector3* const destination, const BGC_FP32_Vector3* const source)
{
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x3 = source->x3;
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
}
inline void bgc_fp64_vector3_convert_to_fp32(BGC_FP32_Vector3* const destination, const BGC_FP64_Vector3* const source)
{
destination->x1 = (float)source->x1;
destination->x2 = (float)source->x2;
destination->x3 = (float)source->x3;
destination->x = (float)source->x;
destination->y = (float)source->y;
destination->z = (float)source->z;
}
// ==================== Add ===================== //
inline void bgc_fp32_vector3_add(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2;
sum->x3 = vector1->x3 + vector2->x3;
sum->x = vector1->x + vector2->x;
sum->y = vector1->y + vector2->y;
sum->z = vector1->z + vector2->z;
}
inline void bgc_fp64_vector3_add(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2;
sum->x3 = vector1->x3 + vector2->x3;
sum->x = vector1->x + vector2->x;
sum->y = vector1->y + vector2->y;
sum->z = vector1->z + vector2->z;
}
// ================= Add scaled ================= //
inline void bgc_fp32_vector3_add_scaled(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
{
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;
sum->x = basic_vector->x + scalable_vector->x * scale;
sum->y = basic_vector->y + scalable_vector->y * scale;
sum->z = basic_vector->z + scalable_vector->z * scale;
}
inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
{
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;
sum->x = basic_vector->x + scalable_vector->x * scale;
sum->y = basic_vector->y + scalable_vector->y * scale;
sum->z = basic_vector->z + scalable_vector->z * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const minuend, const BGC_FP32_Vector3* const subtrahend)
{
difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2;
difference->x3 = minuend->x3 - subtrahend->x3;
difference->x = minuend->x - subtrahend->x;
difference->y = minuend->y - subtrahend->y;
difference->z = minuend->z - subtrahend->z;
}
inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const minuend, const BGC_FP64_Vector3* const subtrahend)
{
difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2;
difference->x3 = minuend->x3 - subtrahend->x3;
difference->x = minuend->x - subtrahend->x;
difference->y = minuend->y - subtrahend->y;
difference->z = minuend->z - subtrahend->z;
}
// ============== Subtract Scaled =============== //
inline void bgc_fp32_vector3_subtract_scaled(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
{
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
difference->x3 = basic_vector->x3 - scalable_vector->x3 * scale;
difference->x = basic_vector->x - scalable_vector->x * scale;
difference->y = basic_vector->y - scalable_vector->y * scale;
difference->z = basic_vector->z - scalable_vector->z * scale;
}
inline void bgc_fp64_vector3_subtract_scaled(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
{
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
difference->x3 = basic_vector->x3 - scalable_vector->x3 * scale;
difference->x = basic_vector->x - scalable_vector->x * scale;
difference->y = basic_vector->y - scalable_vector->y * scale;
difference->z = basic_vector->z - scalable_vector->z * scale;
}
// ================== Multiply ================== //
inline void bgc_fp32_vector3_multiply_by_real_number(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const multiplicand, const float multiplier)
{
product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier;
product->x3 = multiplicand->x3 * multiplier;
product->x = multiplicand->x * multiplier;
product->y = multiplicand->y * multiplier;
product->z = multiplicand->z * multiplier;
}
inline void bgc_fp64_vector3_multiply_by_real_number(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const multiplicand, const double multiplier)
{
product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier;
product->x3 = multiplicand->x3 * multiplier;
product->x = multiplicand->x * multiplier;
product->y = multiplicand->y * multiplier;
product->z = multiplicand->z * multiplier;
}
// ========== Multiply by Dual Number =========== //
inline void bgc_fp32_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
{
const float real_x1 = multiplicand->x1 * multiplier->real_part;
const float real_x2 = multiplicand->x2 * multiplier->real_part;
const float real_x3 = multiplicand->x3 * multiplier->real_part;
const float real_x = multiplicand->x * multiplier->real_part;
const float real_y = multiplicand->y * multiplier->real_part;
const float real_z = multiplicand->z * multiplier->real_part;
const float dual_x1 = multiplicand->x1 * multiplier->dual_part;
const float dual_x2 = multiplicand->x2 * multiplier->dual_part;
const float dual_x3 = multiplicand->x3 * multiplier->dual_part;
const float dual_x = multiplicand->x * multiplier->dual_part;
const float dual_y = multiplicand->y * multiplier->dual_part;
const float dual_z = multiplicand->z * multiplier->dual_part;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->dual_part.x1 = dual_x1;
product->dual_part.x2 = dual_x2;
product->dual_part.x3 = dual_x3;
product->dual_part.x = dual_x;
product->dual_part.y = dual_y;
product->dual_part.z = dual_z;
}
inline void bgc_fp64_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
{
const double real_x1 = multiplicand->x1 * multiplier->real_part;
const double real_x2 = multiplicand->x2 * multiplier->real_part;
const double real_x3 = multiplicand->x3 * multiplier->real_part;
const double real_x = multiplicand->x * multiplier->real_part;
const double real_y = multiplicand->y * multiplier->real_part;
const double real_z = multiplicand->z * multiplier->real_part;
const double dual_x1 = multiplicand->x1 * multiplier->dual_part;
const double dual_x2 = multiplicand->x2 * multiplier->dual_part;
const double dual_x3 = multiplicand->x3 * multiplier->dual_part;
const double dual_x = multiplicand->x * multiplier->dual_part;
const double dual_y = multiplicand->y * multiplier->dual_part;
const double dual_z = multiplicand->z * multiplier->dual_part;
product->real_part.x1 = real_x1;
product->real_part.x2 = real_x2;
product->real_part.x3 = real_x3;
product->real_part.x = real_x;
product->real_part.y = real_y;
product->real_part.z = real_z;
product->dual_part.x1 = dual_x1;
product->dual_part.x2 = dual_x2;
product->dual_part.x3 = dual_x3;
product->dual_part.x = dual_x;
product->dual_part.y = dual_y;
product->dual_part.z = dual_z;
}
// ====== Restrict Multiply by Dual Number ====== //
inline void _bgc_fp32_restrict_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
{
product->real_part.x1 = multiplicand->x1 * multiplier->real_part;
product->real_part.x2 = multiplicand->x2 * multiplier->real_part;
product->real_part.x3 = multiplicand->x3 * multiplier->real_part;
product->real_part.x = multiplicand->x * multiplier->real_part;
product->real_part.y = multiplicand->y * multiplier->real_part;
product->real_part.z = multiplicand->z * multiplier->real_part;
product->dual_part.x1 = multiplicand->x1 * multiplier->dual_part;
product->dual_part.x2 = multiplicand->x2 * multiplier->dual_part;
product->dual_part.x3 = multiplicand->x3 * multiplier->dual_part;
product->dual_part.x = multiplicand->x * multiplier->dual_part;
product->dual_part.y = multiplicand->y * multiplier->dual_part;
product->dual_part.z = multiplicand->z * multiplier->dual_part;
}
inline void _bgc_fp64_restrict_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
{
product->real_part.x1 = multiplicand->x1 * multiplier->real_part;
product->real_part.x2 = multiplicand->x2 * multiplier->real_part;
product->real_part.x3 = multiplicand->x3 * multiplier->real_part;
product->real_part.x = multiplicand->x * multiplier->real_part;
product->real_part.y = multiplicand->y * multiplier->real_part;
product->real_part.z = multiplicand->z * multiplier->real_part;
product->dual_part.x1 = multiplicand->x1 * multiplier->dual_part;
product->dual_part.x2 = multiplicand->x2 * multiplier->dual_part;
product->dual_part.x3 = multiplicand->x3 * multiplier->dual_part;
product->dual_part.x = multiplicand->x * multiplier->dual_part;
product->dual_part.y = multiplicand->y * multiplier->dual_part;
product->dual_part.z = multiplicand->z * multiplier->dual_part;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_vector3_multiply_by_matrix2x3(BGC_FP32_Vector2* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix2x3* const matrix)
{
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
}
inline void bgc_fp64_vector3_multiply_by_matrix2x3(BGC_FP64_Vector2* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix2x3* const matrix)
{
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_vector3_multiply_by_matrix3x3(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
const float x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
const float y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
const float z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3 + vector->z * matrix->r3c3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
inline void bgc_fp64_vector3_multiply_by_matrix3x3(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
const double x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
const double y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
const double z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3 + vector->z * matrix->r3c3;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
// =================== Divide =================== //
@ -357,32 +357,32 @@ inline int bgc_fp64_vector3_divide_by_real_number(BGC_FP64_Vector3* const quotie
inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f;
mean->x3 = (vector1->x3 + vector2->x3) * 0.5f;
mean->x = (vector1->x + vector2->x) * 0.5f;
mean->y = (vector1->y + vector2->y) * 0.5f;
mean->z = (vector1->z + vector2->z) * 0.5f;
}
inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
mean->x1 = (vector1->x1 + vector2->x1) * 0.5;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5;
mean->x3 = (vector1->x3 + vector2->x3) * 0.5;
mean->x = (vector1->x + vector2->x) * 0.5;
mean->y = (vector1->y + vector2->y) * 0.5;
mean->z = (vector1->z + vector2->z) * 0.5;
}
// ================== Average3 ================== //
inline void bgc_fp32_vector3_get_mean3(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const vector3)
{
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD;
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP32_ONE_THIRD;
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP32_ONE_THIRD;
mean->z = (vector1->z + vector2->z + vector3->z) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_vector3_get_mean3(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const vector3)
{
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD;
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP64_ONE_THIRD;
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP64_ONE_THIRD;
mean->z = (vector1->z + vector2->z + vector3->z) * BGC_FP64_ONE_THIRD;
}
// =================== Linear =================== //
@ -391,48 +391,48 @@ inline void bgc_fp32_vector3_interpolate(BGC_FP32_Vector3* const interpolation,
{
const float counter_phase = 1.0f - phase;
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
interpolation->x3 = first->x3 * counter_phase + second->x3 * phase;
interpolation->x = first->x * counter_phase + second->x * phase;
interpolation->y = first->y * counter_phase + second->y * phase;
interpolation->z = first->z * counter_phase + second->z * phase;
}
inline void bgc_fp64_vector3_interpolate(BGC_FP64_Vector3* const interpolation, const BGC_FP64_Vector3* const first, const BGC_FP64_Vector3* const second, const double phase)
{
const double counter_phase = 1.0 - phase;
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
interpolation->x3 = first->x3 * counter_phase + second->x3 * phase;
interpolation->x = first->x * counter_phase + second->x * phase;
interpolation->y = first->y * counter_phase + second->y * phase;
interpolation->z = first->z * counter_phase + second->z * phase;
}
// ================== Negative ================== //
inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* const vector)
{
vector->x1 = -vector->x1;
vector->x2 = -vector->x2;
vector->x3 = -vector->x3;
vector->x = -vector->x;
vector->y = -vector->y;
vector->z = -vector->z;
}
inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* const vector)
{
vector->x1 = -vector->x1;
vector->x2 = -vector->x2;
vector->x3 = -vector->x3;
vector->x = -vector->x;
vector->y = -vector->y;
vector->z = -vector->z;
}
inline void bgc_fp32_vector3_get_reverse(BGC_FP32_Vector3* const reverse, const BGC_FP32_Vector3* const vector)
{
reverse->x1 = -vector->x1;
reverse->x2 = -vector->x2;
reverse->x3 = -vector->x3;
reverse->x = -vector->x;
reverse->y = -vector->y;
reverse->z = -vector->z;
}
inline void bgc_fp64_vector3_get_reverse(BGC_FP64_Vector3* const reverse, const BGC_FP64_Vector3* const vector)
{
reverse->x1 = -vector->x1;
reverse->x2 = -vector->x2;
reverse->x3 = -vector->x3;
reverse->x = -vector->x;
reverse->y = -vector->y;
reverse->z = -vector->z;
}
// ================= Normalize ================== //
@ -451,9 +451,9 @@ inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* const vector)
const float multiplier = sqrtf(1.0f / square_modulus);
vector->x1 *= multiplier;
vector->x2 *= multiplier;
vector->x3 *= multiplier;
vector->x *= multiplier;
vector->y *= multiplier;
vector->z *= multiplier;
return BGC_SUCCESS;
}
@ -472,9 +472,9 @@ inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* const vector)
const double multiplier = sqrt(1.0 / square_modulus);
vector->x1 *= multiplier;
vector->x2 *= multiplier;
vector->x3 *= multiplier;
vector->x *= multiplier;
vector->y *= multiplier;
vector->z *= multiplier;
return BGC_SUCCESS;
}
@ -519,68 +519,68 @@ inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* const normalized, c
inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
return vector1->x * vector2->x + vector1->y * vector2->y + vector1->z * vector2->z;
}
inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
return vector1->x * vector2->x + vector1->y * vector2->y + vector1->z * vector2->z;
}
// =============== Triple Product =============== //
inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const 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);
return vector1->x * (vector2->y * vector3->z - vector2->z * vector3->y)
+ vector1->y * (vector2->z * vector3->x - vector2->x * vector3->z)
+ vector1->z * (vector2->x * vector3->y - vector2->y * vector3->x);
}
inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const 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);
return vector1->x * (vector2->y * vector3->z - vector2->z * vector3->y)
+ vector1->y * (vector2->z * vector3->x - vector2->x * vector3->z)
+ vector1->z * (vector2->x * vector3->y - vector2->y * vector3->x);
}
// =========== Restrict Cross Product =========== //
inline void _bgc_fp32_restrict_vector3_get_cross_product(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
product->x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
product->x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
product->x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
product->x = vector1->y * vector2->z - vector1->z * vector2->y;
product->y = vector1->z * vector2->x - vector1->x * vector2->z;
product->z = vector1->x * vector2->y - vector1->y * vector2->x;
}
inline void _bgc_fp64_restrict_vector3_get_cross_product(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
product->x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
product->x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
product->x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
product->x = vector1->y * vector2->z - vector1->z * vector2->y;
product->y = vector1->z * vector2->x - vector1->x * vector2->z;
product->z = vector1->x * vector2->y - vector1->y * vector2->x;
}
// =============== Cross Product ================ //
inline void bgc_fp32_vector3_get_cross_product(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
const float x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
const float x = vector1->y * vector2->z - vector1->z * vector2->y;
const float y = vector1->z * vector2->x - vector1->x * vector2->z;
const float z = vector1->x * vector2->y - vector1->y * vector2->x;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
const double x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
const double x = vector1->y * vector2->z - vector1->z * vector2->y;
const double y = vector1->z * vector2->x - vector1->x * vector2->z;
const double z = vector1->x * vector2->y - vector1->y * vector2->x;
product->x1 = x1;
product->x2 = x2;
product->x3 = x3;
product->x = x;
product->y = y;
product->z = z;
}
// ============ Double Cross Product ============ //
@ -591,9 +591,9 @@ inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* const product, c
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;
product->x = vector2->x * ac - vector3->x * ab;
product->y = vector2->y * ac - vector3->y * ab;
product->z = vector2->z * ac - vector3->z * ab;
}
// [a x [b x c]] = b * (a, c) - c * (a, b)
@ -602,9 +602,9 @@ inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* const product, c
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;
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
product->x = vector2->x * ac - vector3->x * ab;
product->y = vector2->y * ac - vector3->y * ab;
product->z = vector2->z * ac - vector3->z * ab;
}
// ====== Alternative Double Cross Product ====== //
@ -615,9 +615,9 @@ inline void bgc_fp32_vector3_get_alternative_double_cross(BGC_FP32_Vector3* cons
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;
product->x = vector2->x * ac - vector1->x * bc;
product->y = vector2->y * ac - vector1->y * bc;
product->z = vector2->z * ac - vector1->z * bc;
}
// [[a x b] x c] = - [c x [a x b]] = -(a * (b, c) - b * (a, c)) = b * (a, c) - a * (b, c)
@ -626,9 +626,9 @@ inline void bgc_fp64_vector3_get_alternative_double_cross(BGC_FP64_Vector3* cons
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;
product->x = vector2->x * ac - vector1->x * bc;
product->y = vector2->y * ac - vector1->y * bc;
product->z = vector2->z * ac - vector1->z * bc;
}
// =================== Angle ==================== //
@ -641,20 +641,20 @@ double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* const vector1, const B
inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
{
const float dx1 = (vector1->x1 - vector2->x1);
const float dx2 = (vector1->x2 - vector2->x2);
const float dx3 = (vector1->x3 - vector2->x3);
const float dx = (vector1->x - vector2->x);
const float dy = (vector1->y - vector2->y);
const float dz = (vector1->z - vector2->z);
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
return dx * dx + dy * dy + dz * dz;
}
inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
{
const double dx1 = (vector1->x1 - vector2->x1);
const double dx2 = (vector1->x2 - vector2->x2);
const double dx3 = (vector1->x3 - vector2->x3);
const double dx = (vector1->x - vector2->x);
const double dy = (vector1->y - vector2->y);
const double dz = (vector1->z - vector2->z);
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
return dx * dx + dy * dy + dz * dz;
}
// ================== Distance ================== //