Развитие дуальный чисел, векторов и кватернионов, а также гомогенных векторов и матриц

This commit is contained in:
Andrey Pokidov 2026-02-03 19:56:56 +07:00
parent 3f96b661a9
commit b87518cd3f
21 changed files with 1787 additions and 1511 deletions

View file

@ -64,6 +64,22 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="cotes-number.h" />
<Unit filename="dual-number.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="dual-number.h" />
<Unit filename="dual-quaternion.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="dual-quaternion.h" />
<Unit filename="dual-vector3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="dual-vector3.h" />
<Unit filename="hg-matrix3x3.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="hg-matrix3x3.h" />
<Unit filename="hg-vector3.c">
<Option compilerVar="CC" />
</Unit>

View file

@ -250,36 +250,36 @@ inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, cons
inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
{
matrix->row1_col1 = number->_cos;
matrix->row1_col2 = -number->_sin;
matrix->row2_col1 = number->_sin;
matrix->row2_col2 = number->_cos;
matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin;
matrix->r2c1 = number->_sin;
matrix->r2c2 = number->_cos;
}
inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
{
matrix->row1_col1 = number->_cos;
matrix->row1_col2 = -number->_sin;
matrix->row2_col1 = number->_sin;
matrix->row2_col2 = number->_cos;
matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin;
matrix->r2c1 = number->_sin;
matrix->r2c2 = number->_cos;
}
// ============== Reverse Matrix ================ //
inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
{
matrix->row1_col1 = number->_cos;
matrix->row1_col2 = number->_sin;
matrix->row2_col1 = -number->_sin;
matrix->row2_col2 = number->_cos;
matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin;
matrix->r2c1 = -number->_sin;
matrix->r2c2 = number->_cos;
}
inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
{
matrix->row1_col1 = number->_cos;
matrix->row1_col2 = number->_sin;
matrix->row2_col1 = -number->_sin;
matrix->row2_col2 = number->_cos;
matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin;
matrix->r2c1 = -number->_sin;
matrix->r2c2 = number->_cos;
}
// ================ Turn Vector ================= //

View file

@ -11,3 +11,24 @@ inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BG
inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second);
inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second);
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale);
inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale);
inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend);
inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend);
inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier);
inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier);
inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor);
inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor);
inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third);
inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third);

View file

@ -1,6 +1,8 @@
#ifndef _BGC_DUAL_NUMBER_H_
#define _BGC_DUAL_NUMBER_H_
#include "utilities.h"
// =================== Types ==================== //
typedef struct {
@ -67,4 +69,100 @@ inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualN
first->dual = second->dual;
}
// ==================== Add ===================== //
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
{
sum->real = first->real + second->real;
sum->dual = first->dual + second->dual;
}
inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
{
sum->real = first->real + second->real;
sum->dual = first->dual + second->dual;
}
// ================= Add Scaled ================= //
inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale)
{
sum->real = base_number->real + scalable_number->real * scale;
sum->dual = base_number->dual + scalable_number->dual * scale;
}
inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale)
{
sum->real = base_number->real + scalable_number->real * scale;
sum->dual = base_number->dual + scalable_number->dual * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend)
{
difference->real = minuend->real - subtrahend->real;
difference->dual = minuend->dual - subtrahend->dual;
}
inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend)
{
difference->real = minuend->real - subtrahend->real;
difference->dual = minuend->dual - subtrahend->dual;
}
// ================== Multiply ================== //
inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier)
{
product->real = multiplicand->real * multiplier;
product->dual = multiplicand->dual * multiplier;
}
inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier)
{
product->real = multiplicand->real * multiplier;
product->dual = multiplicand->dual * multiplier;
}
// =================== Divide =================== //
inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor)
{
bgc_fp32_dual_number_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor)
{
bgc_fp64_dual_number_multiply(quotient, dividend, 1.0 / divisor);
}
// ================ Mean of Two ================= //
inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
{
mean->real = (first->real + second->real) * 0.5f;
mean->dual = (first->dual + second->dual) * 0.5f;
}
inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
{
mean->real = (first->real + second->real) * 0.5;
mean->dual = (first->dual + second->dual) * 0.5;
}
// =============== Mean of Three ================ //
inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third)
{
mean->real = (first->real + second->real + third->real) * BGC_FP32_ONE_THIRD;
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third)
{
mean->real = (first->real + second->real + third->real) * BGC_FP64_ONE_THIRD;
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP64_ONE_THIRD;
}
#endif

View file

@ -0,0 +1,10 @@
#include "dual-quaternion.h"
extern inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion);
extern inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion);
extern inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source);
extern inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source);
extern inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second);
extern inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second);

View file

@ -0,0 +1,58 @@
#ifndef _BGC_DUAL_QUATERNION_H_
#define _BGC_DUAL_QUATERNION_H_
#include "quaternion.h"
// =================== Types ==================== //
typedef struct {
BGC_FP32_Quaternion real, dual;
} BGC_FP32_DualQuaternion;
typedef struct {
BGC_FP64_Quaternion real, dual;
} BGC_FP64_DualQuaternion;
// =================== Reset ==================== //
inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion)
{
bgc_fp32_quaternion_reset(&quaternion->real);
bgc_fp32_quaternion_reset(&quaternion->dual);
}
inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion)
{
bgc_fp64_quaternion_reset(&quaternion->real);
bgc_fp64_quaternion_reset(&quaternion->dual);
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source)
{
bgc_fp32_quaternion_copy(&destination->real, &source->real);
bgc_fp32_quaternion_copy(&destination->dual, &source->dual);
}
inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source)
{
bgc_fp64_quaternion_copy(&destination->real, &source->real);
bgc_fp64_quaternion_copy(&destination->dual, &source->dual);
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second)
{
bgc_fp32_quaternion_swap(&first->real, &second->real);
bgc_fp32_quaternion_swap(&first->dual, &second->dual);
}
inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second)
{
bgc_fp64_quaternion_swap(&first->real, &second->real);
bgc_fp64_quaternion_swap(&first->dual, &second->dual);
}
#endif

View file

@ -1,22 +1,34 @@
#include "./dual-vector3.h"
inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector);
inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector);
extern inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector);
extern inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector);
inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual);
inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual);
extern inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual);
extern inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual);
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source);
extern inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source);
inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
extern inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second);
extern inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second);
inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second);
inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second);
extern inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale);
inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale);
extern inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
extern inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend);
inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend);
extern inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second);
extern inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second);
extern inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale);
extern inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale);
extern inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend);
extern inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend);
extern inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier);
extern inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier);
extern inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor);
extern inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor);

View file

@ -41,6 +41,34 @@ inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_F
bgc_fp64_vector3_copy(&vector->dual, dual);
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source)
{
bgc_fp32_vector3_copy(&destination->real, &source->real);
bgc_fp32_vector3_copy(&destination->dual, &source->dual);
}
inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source)
{
bgc_fp64_vector3_copy(&destination->real, &source->real);
bgc_fp64_vector3_copy(&destination->dual, &source->dual);
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second)
{
bgc_fp32_vector3_swap(&first->real, &second->real);
bgc_fp32_vector3_swap(&first->dual, &second->dual);
}
inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second)
{
bgc_fp64_vector3_swap(&first->real, &second->real);
bgc_fp64_vector3_swap(&first->dual, &second->dual);
}
// ================== Set Real ================== //
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3)
@ -115,6 +143,32 @@ inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, con
bgc_fp64_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
}
// ================== Multiply ================== //
inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier)
{
bgc_fp32_vector3_multiply(&product->real, &multiplicand->real, multiplier);
bgc_fp32_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
}
inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier)
{
bgc_fp64_vector3_multiply(&product->real, &multiplicand->real, multiplier);
bgc_fp64_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
}
// =================== Divide =================== //
inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor)
{
bgc_fp32_dual_vector3_multiply(quotient, dividend, 1.0f / divisor);
}
inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor)
{
bgc_fp64_dual_vector3_multiply(quotient, dividend, 1.0 / divisor);
}
// ================== Average2 ================== //
inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2)
@ -133,14 +187,14 @@ inline void bgc_fp64_dual_vector3_get_mean2(BGC_FP64_DualVector3* mean, const BG
inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3)
{
bgc_fp32_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp32_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
bgc_fp32_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp32_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
}
inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3)
{
bgc_fp64_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp64_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
bgc_fp64_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
bgc_fp64_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
}
#endif

View file

@ -1,10 +0,0 @@
#include "dual-versor.h"
extern inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number);
extern inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number);
extern inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source);
extern inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source);
extern inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second);
extern inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second);

View file

@ -1,147 +0,0 @@
#ifndef _BGC_DUAL_VERSOR_H_
#define _BGC_DUAL_VERSOR_H_
// =================== Types ==================== //
typedef struct {
struct {
float s0, x1, x2, x3;
} _real, _dual;
} BGC_FP32_DualVersor;
typedef struct {
struct {
double s0, x1, x2, x3;
} _real, _dual;
} BGC_FP64_DualVersor;
// =================== Reset ==================== //
inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number)
{
number->_real.s0 = 1.0f;
number->_real.x1 = 0.0f;
number->_real.x2 = 0.0f;
number->_real.x3 = 0.0f;
number->_dual.s0 = 0.0f;
number->_dual.x1 = 0.0f;
number->_dual.x2 = 0.0f;
number->_dual.x3 = 0.0f;
}
inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number)
{
number->_real.s0 = 1.0f;
number->_real.x1 = 0.0f;
number->_real.x2 = 0.0f;
number->_real.x3 = 0.0f;
number->_dual.s0 = 0.0f;
number->_dual.x1 = 0.0f;
number->_dual.x2 = 0.0f;
number->_dual.x3 = 0.0f;
}
// ==================== Copy ==================== //
inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source)
{
destination->_real.s0 = source->_real.s0;
destination->_real.x1 = source->_real.x1;
destination->_real.x2 = source->_real.x2;
destination->_real.x3 = source->_real.x3;
destination->_dual.s0 = source->_dual.s0;
destination->_dual.x1 = source->_dual.x1;
destination->_dual.x2 = source->_dual.x2;
destination->_dual.x3 = source->_dual.x3;
}
inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source)
{
destination->_real.s0 = source->_real.s0;
destination->_real.x1 = source->_real.x1;
destination->_real.x2 = source->_real.x2;
destination->_real.x3 = source->_real.x3;
destination->_dual.s0 = source->_dual.s0;
destination->_dual.x1 = source->_dual.x1;
destination->_dual.x2 = source->_dual.x2;
destination->_dual.x3 = source->_dual.x3;
}
// ==================== Swap ==================== //
inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second)
{
// Real
float s0 = second->_real.s0;
float x1 = second->_real.x1;
float x2 = second->_real.x2;
float x3 = second->_real.x3;
second->_real.s0 = first->_real.s0;
second->_real.x1 = first->_real.x1;
second->_real.x2 = first->_real.x2;
second->_real.x3 = first->_real.x3;
first->_real.s0 = s0;
first->_real.x1 = x1;
first->_real.x2 = x2;
first->_real.x3 = x3;
// Dual
s0 = second->_dual.s0;
x1 = second->_dual.x1;
x2 = second->_dual.x2;
x3 = second->_dual.x3;
second->_dual.s0 = first->_dual.s0;
second->_dual.x1 = first->_dual.x1;
second->_dual.x2 = first->_dual.x2;
second->_dual.x3 = first->_dual.x3;
first->_dual.s0 = s0;
first->_dual.x1 = x1;
first->_dual.x2 = x2;
first->_dual.x3 = x3;
}
inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second)
{
// Real
double s0 = second->_real.s0;
double x1 = second->_real.x1;
double x2 = second->_real.x2;
double x3 = second->_real.x3;
second->_real.s0 = first->_real.s0;
second->_real.x1 = first->_real.x1;
second->_real.x2 = first->_real.x2;
second->_real.x3 = first->_real.x3;
first->_real.s0 = s0;
first->_real.x1 = x1;
first->_real.x2 = x2;
first->_real.x3 = x3;
// Dual
s0 = second->_dual.s0;
x1 = second->_dual.x1;
x2 = second->_dual.x2;
x3 = second->_dual.x3;
second->_dual.s0 = first->_dual.s0;
second->_dual.x1 = first->_dual.x1;
second->_dual.x2 = first->_dual.x2;
second->_dual.x3 = first->_dual.x3;
first->_dual.s0 = s0;
first->_dual.x1 = x1;
first->_dual.x2 = x2;
first->_dual.x3 = x3;
}
#endif

View file

@ -0,0 +1,7 @@
#include "hg-matrix3x3.h"
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix);
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix);
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift);
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift);

View file

@ -0,0 +1,123 @@
#ifndef _BGC_HG_MATRIX3X3_H_INCLUDED_
#define _BGC_HG_MATRIX3X3_H_INCLUDED_
#include "vector3.h"
#include "matrices.h"
#include "hg-vector3.h"
// =================== Types ==================== //
typedef struct
{
float r1c1, r1c2, r1c3, r1d0;
float r2c1, r2c2, r2c3, r2d0;
float r3c1, r3c2, r3c3, r3d0;
float d0c1, d0c2, d0c3, d0d0;
} BGC_FP32_HgMatrix3x3;
typedef struct
{
double r1c1, r1c2, r1c3, r1d0;
double r2c1, r2c2, r2c3, r2d0;
double r3c1, r3c2, r3c3, r3d0;
double d0c1, d0c2, d0c3, d0d0;
} BGC_FP64_HgMatrix3x3;
// =================== Reset ==================== //
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1c2 = 0.0f;
homogeneous_matrix->r1d0 = 0.0f;
homogeneous_matrix->r2c1 = 0.0f;
homogeneous_matrix->r2c2 = 1.0f;
homogeneous_matrix->r2c2 = 0.0f;
homogeneous_matrix->r2d0 = 0.0f;
homogeneous_matrix->r3c1 = 0.0f;
homogeneous_matrix->r3c2 = 0.0f;
homogeneous_matrix->r3c2 = 1.0f;
homogeneous_matrix->r3d0 = 0.0f;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix)
{
homogeneous_matrix->r1c1 = 1.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1c2 = 0.0;
homogeneous_matrix->r1d0 = 0.0;
homogeneous_matrix->r2c1 = 0.0;
homogeneous_matrix->r2c2 = 1.0;
homogeneous_matrix->r2c2 = 0.0;
homogeneous_matrix->r2d0 = 0.0;
homogeneous_matrix->r3c1 = 0.0;
homogeneous_matrix->r3c2 = 0.0;
homogeneous_matrix->r3c2 = 1.0;
homogeneous_matrix->r3d0 = 0.0;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
// ==================== Make ==================== //
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0c2 = 0.0f;
homogeneous_matrix->d0d0 = 1.0f;
}
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift)
{
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
homogeneous_matrix->r1d0 = shift->x1;
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
homogeneous_matrix->r2d0 = shift->x2;
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
homogeneous_matrix->r3d0 = shift->x3;
homogeneous_matrix->d0c1 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0c2 = 0.0;
homogeneous_matrix->d0d0 = 1.0;
}
#endif

View file

@ -8,13 +8,13 @@
// Homogeneous 3D Vector
typedef struct
{
float x1, x2, x3, ratio;
float x1, x2, x3, d0;
} BGC_FP32_HgVector3;
// Homogeneous 3D Vector
typedef struct
{
double x1, x2, x3, ratio;
double x1, x2, x3, d0;
} BGC_FP64_HgVector3;
// ================ Reset Point ================= //
@ -24,7 +24,7 @@ inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vect
homogeneous_vector->x1 = 0.0f;
homogeneous_vector->x2 = 0.0f;
homogeneous_vector->x3 = 0.0f;
homogeneous_vector->ratio = 1.0f;
homogeneous_vector->d0 = 1.0f;
}
inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector)
@ -32,7 +32,7 @@ inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vect
homogeneous_vector->x1 = 0.0;
homogeneous_vector->x2 = 0.0;
homogeneous_vector->x3 = 0.0;
homogeneous_vector->ratio = 1.0;
homogeneous_vector->d0 = 1.0;
}
// ================ Reset Point ================= //
@ -42,7 +42,7 @@ inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vec
homogeneous_vector->x1 = 0.0f;
homogeneous_vector->x2 = 0.0f;
homogeneous_vector->x3 = 0.0f;
homogeneous_vector->ratio = 0.0f;
homogeneous_vector->d0 = 0.0f;
}
inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector)
@ -50,25 +50,25 @@ inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vec
homogeneous_vector->x1 = 0.0;
homogeneous_vector->x2 = 0.0;
homogeneous_vector->x3 = 0.0;
homogeneous_vector->ratio = 0.0;
homogeneous_vector->d0 = 0.0;
}
// ==================== Make ==================== //
inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio)
inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float d0)
{
homogeneous_vector->x1 = x1;
homogeneous_vector->x2 = x2;
homogeneous_vector->x3 = x3;
homogeneous_vector->ratio = ratio;
homogeneous_vector->d0 = d0;
}
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio)
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double d0)
{
homogeneous_vector->x1 = x1;
homogeneous_vector->x2 = x2;
homogeneous_vector->x3 = x3;
homogeneous_vector->ratio = ratio;
homogeneous_vector->d0 = d0;
}
// ================= Make Point ================= //
@ -78,7 +78,7 @@ inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vecto
homogeneous_vector->x1 = regular_vector->x1;
homogeneous_vector->x2 = regular_vector->x2;
homogeneous_vector->x3 = regular_vector->x3;
homogeneous_vector->ratio = 1.0f;
homogeneous_vector->d0 = 1.0f;
}
inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
@ -86,7 +86,7 @@ inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vecto
homogeneous_vector->x1 = regular_vector->x1;
homogeneous_vector->x2 = regular_vector->x2;
homogeneous_vector->x3 = regular_vector->x3;
homogeneous_vector->ratio = 1.0;
homogeneous_vector->d0 = 1.0;
}
// ================ Make Vector ================= //
@ -96,7 +96,7 @@ inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vect
homogeneous_vector->x1 = regular_vector->x1;
homogeneous_vector->x2 = regular_vector->x2;
homogeneous_vector->x3 = regular_vector->x3;
homogeneous_vector->ratio = 0.0f;
homogeneous_vector->d0 = 0.0f;
}
inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
@ -104,31 +104,31 @@ inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vect
homogeneous_vector->x1 = regular_vector->x1;
homogeneous_vector->x2 = regular_vector->x2;
homogeneous_vector->x3 = regular_vector->x3;
homogeneous_vector->ratio = 0.0;
homogeneous_vector->d0 = 0.0;
}
// ================== Is Point ================== //
inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector)
{
return !bgc_fp32_is_zero(homogeneous_vector->ratio);
return !bgc_fp32_is_zero(homogeneous_vector->d0);
}
inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector)
{
return !bgc_fp64_is_zero(homogeneous_vector->ratio);
return !bgc_fp64_is_zero(homogeneous_vector->d0);
}
// ================= Is Vector ================== //
inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector)
{
return bgc_fp32_is_zero(homogeneous_vector->ratio);
return bgc_fp32_is_zero(homogeneous_vector->d0);
}
inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector)
{
return bgc_fp64_is_zero(homogeneous_vector->ratio);
return bgc_fp64_is_zero(homogeneous_vector->d0);
}
// ==================== Copy ==================== //
@ -138,7 +138,7 @@ inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x3 = source->x3;
destination->ratio = source->ratio;
destination->d0 = source->d0;
}
inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source)
@ -146,7 +146,7 @@ inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_
destination->x1 = source->x1;
destination->x2 = source->x2;
destination->x3 = source->x3;
destination->ratio = source->ratio;
destination->d0 = source->d0;
}
// ==================== Swap ==================== //
@ -156,17 +156,17 @@ inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVecto
const float x1 = first->x1;
const float x2 = first->x2;
const float x3 = first->x3;
const float ratio = first->ratio;
const float d0 = first->d0;
first->x1 = second->x1;
first->x2 = second->x2;
first->x3 = second->x3;
first->ratio = second->ratio;
first->d0 = second->d0;
second->x1 = x1;
second->x2 = x2;
second->x3 = x3;
second->ratio = ratio;
second->d0 = d0;
}
inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second)
@ -174,17 +174,51 @@ inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVecto
const double x1 = first->x1;
const double x2 = first->x2;
const double x3 = first->x3;
const double ratio = first->ratio;
const double d0 = first->d0;
first->x1 = second->x1;
first->x2 = second->x2;
first->x3 = second->x3;
first->ratio = second->ratio;
first->d0 = second->d0;
second->x1 = x1;
second->x2 = x2;
second->x3 = x3;
second->ratio = ratio;
second->d0 = d0;
}
// ================== Rescale =================== //
inline int bgc_fp32_hg_vector3_rescale(BGC_FP32_HgVector3* homogeneous_vector, const float new_ratio)
{
if (bgc_fp32_is_zero(homogeneous_vector->d0)) {
return 0;
}
const float multiplier = new_ratio / homogeneous_vector->d0;
homogeneous_vector->x1 *= multiplier;
homogeneous_vector->x2 *= multiplier;
homogeneous_vector->x3 *= multiplier;
homogeneous_vector->d0 = new_ratio;
return 1;
}
inline int bgc_fp64_hg_vector3_rescale(BGC_FP64_HgVector3* homogeneous_vector, const double new_ratio)
{
if (bgc_fp64_is_zero(homogeneous_vector->d0)) {
return 0;
}
const double multiplier = new_ratio / homogeneous_vector->d0;
homogeneous_vector->x1 *= multiplier;
homogeneous_vector->x2 *= multiplier;
homogeneous_vector->x3 *= multiplier;
homogeneous_vector->d0 = new_ratio;
return 1;
}
#endif

View file

@ -4,361 +4,361 @@
// ================== Matrix2x2 ================= //
typedef struct {
float row1_col1, row1_col2;
float row2_col1, row2_col2;
float r1c1, r1c2;
float r2c1, r2c2;
} BGC_FP32_Matrix2x2;
typedef struct {
double row1_col1, row1_col2;
double row2_col1, row2_col2;
double r1c1, r1c2;
double r2c1, r2c2;
} BGC_FP64_Matrix2x2;
// ================== Matrix2x3 ================= //
typedef struct {
float row1_col1, row1_col2;
float row2_col1, row2_col2;
float row3_col1, row3_col2;
float r1c1, r1c2;
float r2c1, r2c2;
float r3c1, r3c2;
} BGC_FP32_Matrix2x3;
typedef struct {
double row1_col1, row1_col2;
double row2_col1, row2_col2;
double row3_col1, row3_col2;
double r1c1, r1c2;
double r2c1, r2c2;
double r3c1, r3c2;
} BGC_FP64_Matrix2x3;
// ================== Matrix3x2 ================= //
typedef struct {
float row1_col1, row1_col2, row1_col3;
float row2_col1, row2_col2, row2_col3;
float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3;
} BGC_FP32_Matrix3x2;
typedef struct {
double row1_col1, row1_col2, row1_col3;
double row2_col1, row2_col2, row2_col3;
double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3;
} BGC_FP64_Matrix3x2;
// ================== Matrix3x3 ================= //
typedef struct {
float row1_col1, row1_col2, row1_col3;
float row2_col1, row2_col2, row2_col3;
float row3_col1, row3_col2, row3_col3;
float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3;
float r3c1, r3c2, r3c3;
} BGC_FP32_Matrix3x3;
typedef struct {
double row1_col1, row1_col2, row1_col3;
double row2_col1, row2_col2, row2_col3;
double row3_col1, row3_col2, row3_col3;
double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3;
double r3c1, r3c2, r3c3;
} BGC_FP64_Matrix3x3;
// ========== Matrix Product 2x2 at 2x2 ========= //
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
}
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
}
// ========== Matrix Product 2x2 at 3x2 ========= //
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== Matrix Product 2x3 at 2x2 ========= //
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 2x3 at 3x2 ========= //
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
{
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
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->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3;
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;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
{
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
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->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3;
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;
}
// ========== Matrix Product 3x2 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
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;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
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;
}
// ========== Matrix Product 3x2 at 3x3 ========= //
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== Matrix Product 3x3 at 2x3 ========= //
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 3x3 at 3x3 ========= //
inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
const float row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->row3_col3 = row3_col3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
{
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
const double row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3;
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;
product->row1_col1 = row1_col1;
product->row1_col2 = row1_col2;
product->row1_col3 = row1_col3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->row2_col1 = row2_col1;
product->row2_col2 = row2_col2;
product->row2_col3 = row2_col3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->row3_col1 = row3_col1;
product->row3_col2 = row3_col2;
product->row3_col3 = row3_col3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
#endif // _BGC_MATRIX_TYPES_H_

View file

@ -9,54 +9,54 @@
inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix)
{
matrix->row1_col1 = 0.0f;
matrix->row1_col2 = 0.0f;
matrix->row2_col1 = 0.0f;
matrix->row2_col2 = 0.0f;
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
matrix->r2c1 = 0.0f;
matrix->r2c2 = 0.0f;
}
inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix)
{
matrix->row1_col1 = 0.0;
matrix->row1_col2 = 0.0;
matrix->row2_col1 = 0.0;
matrix->row2_col2 = 0.0;
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
matrix->r2c1 = 0.0;
matrix->r2c2 = 0.0;
}
// ================== Identity ================== //
inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix)
{
matrix->row1_col1 = 1.0f;
matrix->row1_col2 = 0.0f;
matrix->row2_col1 = 0.0f;
matrix->row2_col2 = 1.0f;
matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f;
matrix->r2c1 = 0.0f;
matrix->r2c2 = 1.0f;
}
inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix)
{
matrix->row1_col1 = 1.0;
matrix->row1_col2 = 0.0;
matrix->row2_col1 = 0.0;
matrix->row2_col2 = 1.0;
matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0;
matrix->r2c1 = 0.0;
matrix->r2c2 = 1.0;
}
// ================ Set Diagonal ================ //
inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2)
{
matrix->row1_col1 = d1;
matrix->row1_col2 = 0.0f;
matrix->row2_col1 = 0.0f;
matrix->row2_col2 = d2;
matrix->r1c1 = d1;
matrix->r1c2 = 0.0f;
matrix->r2c1 = 0.0f;
matrix->r2c2 = d2;
}
inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2)
{
matrix->row1_col1 = d1;
matrix->row1_col2 = 0.0;
matrix->row2_col1 = 0.0;
matrix->row2_col2 = d2;
matrix->r1c1 = d1;
matrix->r1c2 = 0.0;
matrix->r2c1 = 0.0;
matrix->r2c2 = d2;
}
// ============== Rotation Matrix =============== //
@ -67,10 +67,10 @@ inline void bgc_fp32_matrix2x2_make_for_turn(BGC_FP32_Matrix2x2* matrix, const f
const float cosine = cosf(radians);
const float sine = sinf(radians);
matrix->row1_col1 = cosine;
matrix->row1_col2 = -sine;
matrix->row2_col1 = sine;
matrix->row2_col2 = cosine;
matrix->r1c1 = cosine;
matrix->r1c2 = -sine;
matrix->r2c1 = sine;
matrix->r2c2 = cosine;
}
inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit)
@ -79,36 +79,36 @@ inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const d
const double cosine = cos(radians);
const double sine = sin(radians);
matrix->row1_col1 = cosine;
matrix->row1_col2 = -sine;
matrix->row2_col1 = sine;
matrix->row2_col2 = cosine;
matrix->r1c1 = cosine;
matrix->r1c2 = -sine;
matrix->r2c1 = sine;
matrix->r2c2 = cosine;
}
// ================ Determinant ================= //
inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix)
{
return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
}
inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix)
{
return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
}
// ================ Is Identity ================= //
inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix)
{
return bgc_fp32_is_unit(matrix->row1_col1) && bgc_fp32_is_zero(matrix->row1_col2)
&& bgc_fp32_is_zero(matrix->row2_col1) && bgc_fp32_is_unit(matrix->row2_col2);
return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2)
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2);
}
inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix)
{
return bgc_fp64_is_unit(matrix->row1_col1) && bgc_fp64_is_zero(matrix->row1_col2)
&& bgc_fp64_is_zero(matrix->row2_col1) && bgc_fp64_is_unit(matrix->row2_col2);
return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2)
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2);
}
// ================ Is Singular ================= //
@ -129,11 +129,11 @@ inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix)
{
BGC_FP32_Matrix2x2 product;
product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1;
product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1;
product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_fp32_matrix2x2_is_identity(&product);
}
@ -142,11 +142,11 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
{
BGC_FP64_Matrix2x2 product;
product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1;
product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2;
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1;
product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2;
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_fp64_matrix2x2_is_identity(&product);
}
@ -155,84 +155,84 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
}
inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
}
// ==================== Swap ==================== //
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2)
{
const float row1_col1 = matrix2->row1_col1;
const float row1_col2 = matrix2->row1_col2;
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float row2_col1 = matrix2->row2_col1;
const float row2_col2 = matrix2->row2_col2;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
}
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2)
{
const double row1_col1 = matrix2->row1_col1;
const double row1_col2 = matrix2->row1_col2;
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double row2_col1 = matrix2->row2_col1;
const double row2_col2 = matrix2->row2_col2;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
}
// ================== Convert =================== //
inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
{
destination->row1_col1 = (float)source->row1_col1;
destination->row1_col2 = (float)source->row1_col2;
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
destination->row2_col1 = (float)source->row2_col1;
destination->row2_col2 = (float)source->row2_col2;
destination->r2c1 = (float)source->r2c1;
destination->r2c2 = (float)source->r2c2;
}
inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
}
// ================ Get Inverse ================= //
@ -245,19 +245,19 @@ inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC
return 0;
}
const float row1_col1 = matrix->row2_col2;
const float row1_col2 = -matrix->row1_col2;
const float r1c1 = matrix->r2c2;
const float r1c2 = -matrix->r1c2;
const float row2_col1 = -matrix->row2_col1;
const float row2_col2 = matrix->row1_col1;
const float r2c1 = -matrix->r2c1;
const float r2c2 = matrix->r1c1;
const float multiplier = 1.0f / determinant;
inverse->row1_col1 = row1_col1 * multiplier;
inverse->row1_col2 = row1_col2 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->row2_col1 = row2_col1 * multiplier;
inverse->row2_col2 = row2_col2 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
return 1;
}
@ -270,19 +270,19 @@ inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC
return 0;
}
const double row1_col1 = matrix->row2_col2;
const double row1_col2 = -matrix->row1_col2;
const double r1c1 = matrix->r2c2;
const double r1c2 = -matrix->r1c2;
const double row2_col1 = -matrix->row2_col1;
const double row2_col2 = matrix->row1_col1;
const double r2c1 = -matrix->r2c1;
const double r2c2 = matrix->r1c1;
const double multiplier = 1.0 / determinant;
inverse->row1_col1 = row1_col1 * multiplier;
inverse->row1_col2 = row1_col2 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->row2_col1 = row2_col1 * multiplier;
inverse->row2_col2 = row2_col2 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
return 1;
}
@ -303,40 +303,40 @@ inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix)
inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix)
{
const float row1_col2 = matrix->row1_col2;
matrix->row1_col2 = matrix->row2_col1;
matrix->row2_col1 = row1_col2;
const float r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix)
{
const double row1_col2 = matrix->row1_col2;
matrix->row1_col2 = matrix->row2_col1;
matrix->row2_col1 = row1_col2;
const double r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
// =============== Get Transpose ================ //
inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix)
{
const float row1_col2 = matrix->row1_col2;
const float r1c2 = matrix->r1c2;
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->row2_col1 = row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->r2c1 = r1c2;
transposed->r2c2 = matrix->r2c2;
}
inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix)
{
const double row1_col2 = matrix->row1_col2;
const double r1c2 = matrix->r1c2;
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->row2_col1 = row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->r2c1 = r1c2;
transposed->r2c2 = matrix->r2c2;
}
// ================== Get Row =================== //
@ -344,14 +344,14 @@ inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, co
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
@ -362,14 +362,14 @@ inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Mat
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
@ -382,28 +382,28 @@ inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Mat
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row)
{
if (row_number == 1) {
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
}
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row)
{
if (row_number == 1) {
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
}
@ -412,14 +412,14 @@ inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
@ -430,14 +430,14 @@ inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
@ -450,28 +450,28 @@ inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column)
{
if (column_number == 1) {
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2) {
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
}
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column)
{
if (column_number == 1) {
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2) {
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
}
@ -479,80 +479,80 @@ inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
}
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
}
// ================= Add scaled ================= //
inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
}
inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
}
inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
}
// ================== Multiply ================== //
inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
}
inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
}
// =================== Divide =================== //
@ -573,30 +573,30 @@ inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, co
{
const float counter_phase = 1.0f - phase;
interpolation->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
}
inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase)
{
const double counter_phase = 1.0 - phase;
interpolation->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
}
// ============ Right Vector Product ============ //
inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
{
const float x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
const float x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x1 = x1;
product->x2 = x2;
@ -604,8 +604,8 @@ inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, co
inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
{
const double x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
const double x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
product->x1 = x1;
product->x2 = x2;
@ -615,8 +615,8 @@ inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, co
inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
{
const float x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
const float x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
@ -624,8 +624,8 @@ inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, co
inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
{
const double x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
const double x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;

View file

@ -9,166 +9,166 @@
inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix)
{
matrix->row1_col1 = 0.0f;
matrix->row1_col2 = 0.0f;
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
matrix->row2_col1 = 0.0f;
matrix->row2_col2 = 0.0f;
matrix->r2c1 = 0.0f;
matrix->r2c2 = 0.0f;
matrix->row3_col1 = 0.0f;
matrix->row3_col2 = 0.0f;
matrix->r3c1 = 0.0f;
matrix->r3c2 = 0.0f;
}
inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix)
{
matrix->row1_col1 = 0.0;
matrix->row1_col2 = 0.0;
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
matrix->row2_col1 = 0.0;
matrix->row2_col2 = 0.0;
matrix->r2c1 = 0.0;
matrix->r2c2 = 0.0;
matrix->row3_col1 = 0.0;
matrix->row3_col2 = 0.0;
matrix->r3c1 = 0.0;
matrix->r3c2 = 0.0;
}
// ==================== Copy ==================== //
inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->row3_col1 = source->row3_col1;
destination->row3_col2 = source->row3_col2;
destination->r3c1 = source->r3c1;
destination->r3c2 = source->r3c2;
}
inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->row3_col1 = source->row3_col1;
destination->row3_col2 = source->row3_col2;
destination->r3c1 = source->r3c1;
destination->r3c2 = source->r3c2;
}
// ==================== Swap ==================== //
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2)
{
const float row1_col1 = matrix2->row1_col1;
const float row1_col2 = matrix2->row1_col2;
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float row2_col1 = matrix2->row2_col1;
const float row2_col2 = matrix2->row2_col2;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float row3_col1 = matrix2->row3_col1;
const float row3_col2 = matrix2->row3_col2;
const float r3c1 = matrix2->r3c1;
const float r3c2 = matrix2->r3c2;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->row3_col1 = matrix1->row3_col1;
matrix2->row3_col2 = matrix1->row3_col2;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->row3_col1 = row3_col1;
matrix1->row3_col2 = row3_col2;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
}
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2)
{
const double row1_col1 = matrix2->row1_col1;
const double row1_col2 = matrix2->row1_col2;
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double row2_col1 = matrix2->row2_col1;
const double row2_col2 = matrix2->row2_col2;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double row3_col1 = matrix2->row3_col1;
const double row3_col2 = matrix2->row3_col2;
const double r3c1 = matrix2->r3c1;
const double r3c2 = matrix2->r3c2;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->row3_col1 = matrix1->row3_col1;
matrix2->row3_col2 = matrix1->row3_col2;
matrix2->r3c1 = matrix1->r3c1;
matrix2->r3c2 = matrix1->r3c2;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->row3_col1 = row3_col1;
matrix1->row3_col2 = row3_col2;
matrix1->r3c1 = r3c1;
matrix1->r3c2 = r3c2;
}
// ================== Convert =================== //
inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source)
{
destination->row1_col1 = (float)source->row1_col1;
destination->row1_col2 = (float)source->row1_col2;
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
destination->row2_col1 = (float)source->row2_col1;
destination->row2_col2 = (float)source->row2_col2;
destination->r2c1 = (float)source->r2c1;
destination->r2c2 = (float)source->r2c2;
destination->row3_col1 = (float)source->row3_col1;
destination->row3_col2 = (float)source->row3_col2;
destination->r3c1 = (float)source->r3c1;
destination->r3c2 = (float)source->r3c2;
}
inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->row3_col1 = source->row3_col1;
destination->row3_col2 = source->row3_col2;
destination->r3c1 = source->r3c1;
destination->r3c2 = source->r3c2;
}
// ================= Transpose ================== //
inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix)
{
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->row2_col1 = matrix->row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->r2c1 = matrix->r1c2;
transposed->r2c2 = matrix->r2c2;
transposed->row3_col1 = matrix->row1_col3;
transposed->row3_col2 = matrix->row2_col3;
transposed->r3c1 = matrix->r1c3;
transposed->r3c2 = matrix->r2c3;
}
inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* matrix)
{
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->row2_col1 = matrix->row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->r2c1 = matrix->r1c2;
transposed->r2c2 = matrix->r2c2;
transposed->row3_col1 = matrix->row1_col3;
transposed->row3_col2 = matrix->row2_col3;
transposed->r3c1 = matrix->r1c3;
transposed->r3c2 = matrix->r2c3;
}
// ================== Get Row =================== //
@ -176,20 +176,20 @@ inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, co
inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
if (row_number == 3) {
row->x1 = matrix->row3_col1;
row->x2 = matrix->row3_col2;
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
@ -200,20 +200,20 @@ inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Mat
inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number)
{
if (row_number == 1) {
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (row_number == 2) {
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
if (row_number == 3) {
row->x1 = matrix->row3_col1;
row->x2 = matrix->row3_col2;
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
@ -226,40 +226,40 @@ inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Mat
inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row)
{
if (row_number == 1) {
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (row_number == 3) {
matrix->row3_col1 = row->x1;
matrix->row3_col2 = row->x2;
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
}
inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row)
{
if (row_number == 1) {
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (row_number == 2) {
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (row_number == 3) {
matrix->row3_col1 = row->x1;
matrix->row3_col2 = row->x2;
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
}
@ -268,32 +268,32 @@ inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row
inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x3 = matrix->row3_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x3 = matrix->row3_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
}
inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number)
{
if (column_number == 1) {
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x3 = matrix->row3_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (column_number == 2) {
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x3 = matrix->row3_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
}
@ -302,32 +302,32 @@ inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP
inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int column_number, const BGC_FP32_Vector3* column)
{
if (column_number == 1) {
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->row3_col1 = column->x3;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2) {
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->row3_col2 = column->x3;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
}
}
inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int column_number, const BGC_FP64_Vector3* column)
{
if (column_number == 1) {
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->row3_col1 = column->x3;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (column_number == 2) {
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->row3_col2 = column->x3;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
}
}
@ -335,104 +335,104 @@ inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1;
sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
}
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1;
sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2;
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
}
// ================= Add scaled ================= //
inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale;
sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale;
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
}
inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale;
sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale;
sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale;
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1;
difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2;
difference->r3c1 = minuend->r3c1 - subtrahend->r3c1;
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
}
inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1;
difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2;
difference->r3c1 = minuend->r3c1 - subtrahend->r3c1;
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
}
// ================== Multiply ================== //
inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
product->row3_col1 = multiplicand->row3_col1 * multiplier;
product->row3_col2 = multiplicand->row3_col2 * multiplier;
product->r3c1 = multiplicand->r3c1 * multiplier;
product->r3c2 = multiplicand->r3c2 * multiplier;
}
inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
product->row3_col1 = multiplicand->row3_col1 * multiplier;
product->row3_col2 = multiplicand->row3_col2 * multiplier;
product->r3c1 = multiplicand->r3c1 * multiplier;
product->r3c2 = multiplicand->r3c2 * multiplier;
}
// =================== Divide =================== //
@ -453,58 +453,58 @@ inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, co
{
const float couter_phase = 1.0f - phase;
interpolation->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->row3_col1 = first->row3_col1 * couter_phase + second->row3_col1 * phase;
interpolation->row3_col2 = first->row3_col2 * couter_phase + second->row3_col2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
}
inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase)
{
const double couter_phase = 1.0 - phase;
interpolation->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->row3_col1 = first->row3_col1 * couter_phase + second->row3_col1 * phase;
interpolation->row3_col2 = first->row3_col2 * couter_phase + second->row3_col2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix)
{
product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1;
product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2;
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;
}
inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix)
{
product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1;
product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2;
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;
}
// ============ Right Vector Product ============ //
inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector)
{
product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
product->x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2;
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;
}
inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector)
{
product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
product->x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2;
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;
}
#endif

View file

@ -9,152 +9,152 @@
inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix)
{
matrix->row1_col1 = 0.0f;
matrix->row1_col2 = 0.0f;
matrix->row1_col3 = 0.0f;
matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f;
matrix->r1c3 = 0.0f;
matrix->row2_col1 = 0.0f;
matrix->row2_col2 = 0.0f;
matrix->row2_col3 = 0.0f;
matrix->r2c1 = 0.0f;
matrix->r2c2 = 0.0f;
matrix->r2c3 = 0.0f;
}
inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix)
{
matrix->row1_col1 = 0.0;
matrix->row1_col2 = 0.0;
matrix->row1_col3 = 0.0;
matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0;
matrix->r1c3 = 0.0;
matrix->row2_col1 = 0.0;
matrix->row2_col2 = 0.0;
matrix->row2_col3 = 0.0;
matrix->r2c1 = 0.0;
matrix->r2c2 = 0.0;
matrix->r2c3 = 0.0;
}
// ==================== Copy ==================== //
inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->row1_col3 = source->row1_col3;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->r1c3 = source->r1c3;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->row2_col3 = source->row2_col3;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->r2c3 = source->r2c3;
}
inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->row1_col3 = source->row1_col3;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->r1c3 = source->r1c3;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->row2_col3 = source->row2_col3;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->r2c3 = source->r2c3;
}
// ==================== Swap ==================== //
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2)
{
const float row1_col1 = matrix2->row1_col1;
const float row1_col2 = matrix2->row1_col2;
const float row1_col3 = matrix2->row1_col3;
const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2;
const float r1c3 = matrix2->r1c3;
const float row2_col1 = matrix2->row2_col1;
const float row2_col2 = matrix2->row2_col2;
const float row2_col3 = matrix2->row2_col3;
const float r2c1 = matrix2->r2c1;
const float r2c2 = matrix2->r2c2;
const float r2c3 = matrix2->r2c3;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->row1_col3 = matrix1->row1_col3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->row2_col3 = matrix1->row2_col3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->row1_col3 = row1_col3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->row2_col3 = row2_col3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
}
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2)
{
const double row1_col1 = matrix2->row1_col1;
const double row1_col2 = matrix2->row1_col2;
const double row1_col3 = matrix2->row1_col3;
const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2;
const double r1c3 = matrix2->r1c3;
const double row2_col1 = matrix2->row2_col1;
const double row2_col2 = matrix2->row2_col2;
const double row2_col3 = matrix2->row2_col3;
const double r2c1 = matrix2->r2c1;
const double r2c2 = matrix2->r2c2;
const double r2c3 = matrix2->r2c3;
matrix2->row1_col1 = matrix1->row1_col1;
matrix2->row1_col2 = matrix1->row1_col2;
matrix2->row1_col3 = matrix1->row1_col3;
matrix2->r1c1 = matrix1->r1c1;
matrix2->r1c2 = matrix1->r1c2;
matrix2->r1c3 = matrix1->r1c3;
matrix2->row2_col1 = matrix1->row2_col1;
matrix2->row2_col2 = matrix1->row2_col2;
matrix2->row2_col3 = matrix1->row2_col3;
matrix2->r2c1 = matrix1->r2c1;
matrix2->r2c2 = matrix1->r2c2;
matrix2->r2c3 = matrix1->r2c3;
matrix1->row1_col1 = row1_col1;
matrix1->row1_col2 = row1_col2;
matrix1->row1_col3 = row1_col3;
matrix1->r1c1 = r1c1;
matrix1->r1c2 = r1c2;
matrix1->r1c3 = r1c3;
matrix1->row2_col1 = row2_col1;
matrix1->row2_col2 = row2_col2;
matrix1->row2_col3 = row2_col3;
matrix1->r2c1 = r2c1;
matrix1->r2c2 = r2c2;
matrix1->r2c3 = r2c3;
}
// ================== Convert =================== //
inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source)
{
destination->row1_col1 = (float)source->row1_col1;
destination->row1_col2 = (float)source->row1_col2;
destination->row1_col3 = (float)source->row1_col3;
destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2;
destination->r1c3 = (float)source->r1c3;
destination->row2_col1 = (float)source->row2_col1;
destination->row2_col2 = (float)source->row2_col2;
destination->row2_col3 = (float)source->row2_col3;
destination->r2c1 = (float)source->r2c1;
destination->r2c2 = (float)source->r2c2;
destination->r2c3 = (float)source->r2c3;
}
inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source)
{
destination->row1_col1 = source->row1_col1;
destination->row1_col2 = source->row1_col2;
destination->row1_col3 = source->row1_col3;
destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2;
destination->r1c3 = source->r1c3;
destination->row2_col1 = source->row2_col1;
destination->row2_col2 = source->row2_col2;
destination->row2_col3 = source->row2_col3;
destination->r2c1 = source->r2c1;
destination->r2c2 = source->r2c2;
destination->r2c3 = source->r2c3;
}
// ================= Transpose ================== //
inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix)
{
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->row1_col3 = matrix->row3_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->r1c3 = matrix->r3c1;
transposed->row2_col1 = matrix->row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->row2_col3 = matrix->row3_col2;
transposed->r2c1 = matrix->r1c2;
transposed->r2c2 = matrix->r2c2;
transposed->r2c3 = matrix->r3c2;
}
inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* matrix)
{
transposed->row1_col1 = matrix->row1_col1;
transposed->row1_col2 = matrix->row2_col1;
transposed->row1_col3 = matrix->row3_col1;
transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1;
transposed->r1c3 = matrix->r3c1;
transposed->row2_col1 = matrix->row1_col2;
transposed->row2_col2 = matrix->row2_col2;
transposed->row2_col3 = matrix->row3_col2;
transposed->r2c1 = matrix->r1c2;
transposed->r2c2 = matrix->r2c2;
transposed->r2c3 = matrix->r3c2;
}
// ================== Get Row =================== //
@ -163,17 +163,17 @@ inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Mat
{
if (row_number == 1)
{
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x3 = matrix->row1_col3;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x3 = matrix->row2_col3;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
@ -186,17 +186,17 @@ inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Mat
{
if (row_number == 1)
{
row->x1 = matrix->row1_col1;
row->x2 = matrix->row1_col2;
row->x3 = matrix->row1_col3;
row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (row_number == 2)
{
row->x1 = matrix->row2_col1;
row->x2 = matrix->row2_col2;
row->x3 = matrix->row2_col3;
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
@ -211,17 +211,17 @@ inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row
{
if (row_number == 1)
{
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->row1_col3 = row->x3;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (row_number == 2)
{
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->row2_col3 = row->x3;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
}
@ -229,17 +229,17 @@ inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row
{
if (row_number == 1)
{
matrix->row1_col1 = row->x1;
matrix->row1_col2 = row->x2;
matrix->row1_col3 = row->x3;
matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (row_number == 2)
{
matrix->row2_col1 = row->x1;
matrix->row2_col2 = row->x2;
matrix->row2_col3 = row->x3;
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
}
@ -249,22 +249,22 @@ inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP
{
if (column_number == 1)
{
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->row1_col3;
column->x2 = matrix->row2_col3;
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
@ -276,22 +276,22 @@ inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP
{
if (column_number == 1)
{
column->x1 = matrix->row1_col1;
column->x2 = matrix->row2_col1;
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (column_number == 2)
{
column->x1 = matrix->row1_col2;
column->x2 = matrix->row2_col2;
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (column_number == 3)
{
column->x1 = matrix->row1_col3;
column->x2 = matrix->row2_col3;
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
@ -305,22 +305,22 @@ inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int
{
if (column_number == 1)
{
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2)
{
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
if (column_number == 3)
{
matrix->row1_col3 = column->x1;
matrix->row2_col3 = column->x2;
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
}
}
@ -328,22 +328,22 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int
{
if (column_number == 1)
{
matrix->row1_col1 = column->x1;
matrix->row2_col1 = column->x2;
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (column_number == 2)
{
matrix->row1_col2 = column->x1;
matrix->row2_col2 = column->x2;
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
if (column_number == 3)
{
matrix->row1_col3 = column->x1;
matrix->row2_col3 = column->x2;
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
}
}
@ -351,96 +351,96 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
}
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
{
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3;
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3;
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
}
// ================= Add scaled ================= //
inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
}
inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale)
{
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale;
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale;
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale;
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
}
// ================== Subtract ================== //
inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->r1c3 = minuend->r1c3 - subtrahend->r1c3;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
}
inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend)
{
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3;
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
difference->r1c3 = minuend->r1c3 - subtrahend->r1c3;
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3;
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
}
// ================== Multiply ================== //
inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->row1_col3 = multiplicand->row1_col3 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->r1c3 = multiplicand->r1c3 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->row2_col3 = multiplicand->row2_col3 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
product->r2c3 = multiplicand->r2c3 * multiplier;
}
inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier)
{
product->row1_col1 = multiplicand->row1_col1 * multiplier;
product->row1_col2 = multiplicand->row1_col2 * multiplier;
product->row1_col3 = multiplicand->row1_col3 * multiplier;
product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier;
product->r1c3 = multiplicand->r1c3 * multiplier;
product->row2_col1 = multiplicand->row2_col1 * multiplier;
product->row2_col2 = multiplicand->row2_col2 * multiplier;
product->row2_col3 = multiplicand->row2_col3 * multiplier;
product->r2c1 = multiplicand->r2c1 * multiplier;
product->r2c2 = multiplicand->r2c2 * multiplier;
product->r2c3 = multiplicand->r2c3 * multiplier;
}
// =================== Divide =================== //
@ -461,56 +461,56 @@ inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, co
{
const float couter_phase = 1.0f - phase;
interpolation->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase;
interpolation->row1_col3 = first->row1_col3 * couter_phase + second->row1_col3 * phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase;
interpolation->row2_col3 = first->row2_col3 * couter_phase + second->row2_col3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
}
inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase)
{
const double couter_phase = 1.0 - phase;
interpolation->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase;
interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase;
interpolation->row1_col3 = first->row1_col3 * couter_phase + second->row1_col3 * phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase;
interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase;
interpolation->row2_col3 = first->row2_col3 * couter_phase + second->row2_col3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
}
// ============ Left Vector Product ============= //
inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix)
{
product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
product->x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3;
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;
}
inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix)
{
product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
product->x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3;
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;
}
// ============ Right Vector Product ============ //
inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector)
{
product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3;
product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3;
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;
}
inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector)
{
product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3;
product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3;
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;
}
#endif

View file

@ -85,31 +85,31 @@ int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_M
return 0;
}
const float row1_col1 = matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2;
const float row1_col2 = matrix->row1_col3 * matrix->row3_col2 - matrix->row1_col2 * matrix->row3_col3;
const float row1_col3 = matrix->row1_col2 * matrix->row2_col3 - matrix->row1_col3 * matrix->row2_col2;
const float r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
const float r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3;
const float r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2;
const float row2_col1 = matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3;
const float row2_col2 = matrix->row1_col1 * matrix->row3_col3 - matrix->row1_col3 * matrix->row3_col1;
const float row2_col3 = matrix->row1_col3 * matrix->row2_col1 - matrix->row1_col1 * matrix->row2_col3;
const float r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3;
const float r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1;
const float r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3;
const float row3_col1 = matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1;
const float row3_col2 = matrix->row1_col2 * matrix->row3_col1 - matrix->row1_col1 * matrix->row3_col2;
const float row3_col3 = matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
const float r3c1 = matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1;
const float r3c2 = matrix->r1c2 * matrix->r3c1 - matrix->r1c1 * matrix->r3c2;
const float r3c3 = matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
const float multiplier = 1.0f / determinant;
inverse->row1_col1 = row1_col1 * multiplier;
inverse->row1_col2 = row1_col2 * multiplier;
inverse->row1_col3 = row1_col3 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->r1c3 = r1c3 * multiplier;
inverse->row2_col1 = row2_col1 * multiplier;
inverse->row2_col2 = row2_col2 * multiplier;
inverse->row2_col3 = row2_col3 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
inverse->r2c3 = r2c3 * multiplier;
inverse->row3_col1 = row3_col1 * multiplier;
inverse->row3_col2 = row3_col2 * multiplier;
inverse->row3_col3 = row3_col3 * multiplier;
inverse->r3c1 = r3c1 * multiplier;
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
}
@ -122,31 +122,31 @@ int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_M
return 0;
}
const double row1_col1 = matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2;
const double row1_col2 = matrix->row1_col3 * matrix->row3_col2 - matrix->row1_col2 * matrix->row3_col3;
const double row1_col3 = matrix->row1_col2 * matrix->row2_col3 - matrix->row1_col3 * matrix->row2_col2;
const double r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
const double r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3;
const double r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2;
const double row2_col1 = matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3;
const double row2_col2 = matrix->row1_col1 * matrix->row3_col3 - matrix->row1_col3 * matrix->row3_col1;
const double row2_col3 = matrix->row1_col3 * matrix->row2_col1 - matrix->row1_col1 * matrix->row2_col3;
const double r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3;
const double r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1;
const double r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3;
const double row3_col1 = matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1;
const double row3_col2 = matrix->row1_col2 * matrix->row3_col1 - matrix->row1_col1 * matrix->row3_col2;
const double row3_col3 = matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
const double r3c1 = matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1;
const double r3c2 = matrix->r1c2 * matrix->r3c1 - matrix->r1c1 * matrix->r3c2;
const double r3c3 = matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
const double multiplier = 1.0 / determinant;
inverse->row1_col1 = row1_col1 * multiplier;
inverse->row1_col2 = row1_col2 * multiplier;
inverse->row1_col3 = row1_col3 * multiplier;
inverse->r1c1 = r1c1 * multiplier;
inverse->r1c2 = r1c2 * multiplier;
inverse->r1c3 = r1c3 * multiplier;
inverse->row2_col1 = row2_col1 * multiplier;
inverse->row2_col2 = row2_col2 * multiplier;
inverse->row2_col3 = row2_col3 * multiplier;
inverse->r2c1 = r2c1 * multiplier;
inverse->r2c2 = r2c2 * multiplier;
inverse->r2c3 = r2c3 * multiplier;
inverse->row3_col1 = row3_col1 * multiplier;
inverse->row3_col2 = row3_col2 * multiplier;
inverse->row3_col3 = row3_col3 * multiplier;
inverse->r3c1 = r3c1 * multiplier;
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
}

File diff suppressed because it is too large Load diff

View file

@ -635,17 +635,17 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation,
const float corrector2 = 2.0f * corrector1;
rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
rotation->row1_col2 = corrector2 * (x1x2 - s0x3);
rotation->row2_col3 = corrector2 * (x2x3 - s0x1);
rotation->row3_col1 = corrector2 * (x1x3 - s0x2);
rotation->r1c2 = corrector2 * (x1x2 - s0x3);
rotation->r2c3 = corrector2 * (x2x3 - s0x1);
rotation->r3c1 = corrector2 * (x1x3 - s0x2);
rotation->row2_col1 = corrector2 * (x1x2 + s0x3);
rotation->row3_col2 = corrector2 * (x2x3 + s0x1);
rotation->row1_col3 = corrector2 * (x1x3 + s0x2);
rotation->r2c1 = corrector2 * (x1x2 + s0x3);
rotation->r3c2 = corrector2 * (x2x3 + s0x1);
rotation->r1c3 = corrector2 * (x1x3 + s0x2);
return 1;
}
@ -676,17 +676,17 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation,
const double corrector2 = 2.0f * corrector1;
rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
rotation->row1_col2 = corrector2 * (x1x2 - s0x3);
rotation->row2_col3 = corrector2 * (x2x3 - s0x1);
rotation->row3_col1 = corrector2 * (x1x3 - s0x2);
rotation->r1c2 = corrector2 * (x1x2 - s0x3);
rotation->r2c3 = corrector2 * (x2x3 - s0x1);
rotation->r3c1 = corrector2 * (x1x3 - s0x2);
rotation->row2_col1 = corrector2 * (x1x2 + s0x3);
rotation->row3_col2 = corrector2 * (x2x3 + s0x1);
rotation->row1_col3 = corrector2 * (x1x3 + s0x2);
rotation->r2c1 = corrector2 * (x1x2 + s0x3);
rotation->r3c2 = corrector2 * (x2x3 + s0x1);
rotation->r1c3 = corrector2 * (x1x3 + s0x2);
return 1;
}
@ -719,17 +719,17 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, c
const float corrector2 = 2.0f * corrector1;
reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
reverse->row1_col2 = corrector2 * (x1x2 + s0x3);
reverse->row2_col3 = corrector2 * (x2x3 + s0x1);
reverse->row3_col1 = corrector2 * (x1x3 + s0x2);
reverse->r1c2 = corrector2 * (x1x2 + s0x3);
reverse->r2c3 = corrector2 * (x2x3 + s0x1);
reverse->r3c1 = corrector2 * (x1x3 + s0x2);
reverse->row2_col1 = corrector2 * (x1x2 - s0x3);
reverse->row3_col2 = corrector2 * (x2x3 - s0x1);
reverse->row1_col3 = corrector2 * (x1x3 - s0x2);
reverse->r2c1 = corrector2 * (x1x2 - s0x3);
reverse->r3c2 = corrector2 * (x2x3 - s0x1);
reverse->r1c3 = corrector2 * (x1x3 - s0x2);
return 1;
}
@ -760,17 +760,17 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, c
const double corrector2 = 2.0f * corrector1;
reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
reverse->row1_col2 = corrector2 * (x1x2 + s0x3);
reverse->row2_col3 = corrector2 * (x2x3 + s0x1);
reverse->row3_col1 = corrector2 * (x1x3 + s0x2);
reverse->r1c2 = corrector2 * (x1x2 + s0x3);
reverse->r2c3 = corrector2 * (x2x3 + s0x1);
reverse->r3c1 = corrector2 * (x1x3 + s0x2);
reverse->row2_col1 = corrector2 * (x1x2 - s0x3);
reverse->row3_col2 = corrector2 * (x2x3 - s0x1);
reverse->row1_col3 = corrector2 * (x1x3 - s0x2);
reverse->r2c1 = corrector2 * (x1x2 - s0x3);
reverse->r3c2 = corrector2 * (x2x3 - s0x1);
reverse->r1c3 = corrector2 * (x1x3 - s0x2);
return 1;
}

View file

@ -460,17 +460,17 @@ inline void bgc_fp32_versor_get_rotation_matrix(BGC_FP32_Matrix3x3* matrix, cons
const float x1x3 = versor->_x1 * versor->_x3;
const float x2x3 = versor->_x2 * versor->_x3;
matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->row1_col2 = 2.0f * (x1x2 - s0x3);
matrix->row2_col3 = 2.0f * (x2x3 - s0x1);
matrix->row3_col1 = 2.0f * (x1x3 - s0x2);
matrix->r1c2 = 2.0f * (x1x2 - s0x3);
matrix->r2c3 = 2.0f * (x2x3 - s0x1);
matrix->r3c1 = 2.0f * (x1x3 - s0x2);
matrix->row2_col1 = 2.0f * (x1x2 + s0x3);
matrix->row3_col2 = 2.0f * (x2x3 + s0x1);
matrix->row1_col3 = 2.0f * (x1x3 + s0x2);
matrix->r2c1 = 2.0f * (x1x2 + s0x3);
matrix->r3c2 = 2.0f * (x2x3 + s0x1);
matrix->r1c3 = 2.0f * (x1x3 + s0x2);
}
inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor)
@ -487,17 +487,17 @@ inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, cons
const double x1x3 = versor->_x1 * versor->_x3;
const double x2x3 = versor->_x2 * versor->_x3;
matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->row1_col2 = 2.0 * (x1x2 - s0x3);
matrix->row2_col3 = 2.0 * (x2x3 - s0x1);
matrix->row3_col1 = 2.0 * (x1x3 - s0x2);
matrix->r1c2 = 2.0 * (x1x2 - s0x3);
matrix->r2c3 = 2.0 * (x2x3 - s0x1);
matrix->r3c1 = 2.0 * (x1x3 - s0x2);
matrix->row2_col1 = 2.0 * (x1x2 + s0x3);
matrix->row3_col2 = 2.0 * (x2x3 + s0x1);
matrix->row1_col3 = 2.0 * (x1x3 + s0x2);
matrix->r2c1 = 2.0 * (x1x2 + s0x3);
matrix->r3c2 = 2.0 * (x2x3 + s0x1);
matrix->r1c3 = 2.0 * (x1x3 + s0x2);
}
// ============= Get Reverse Matrix ============= //
@ -516,17 +516,17 @@ inline void bgc_fp32_versor_get_reverse_matrix(BGC_FP32_Matrix3x3* matrix, const
const float x1x3 = versor->_x1 * versor->_x3;
const float x2x3 = versor->_x2 * versor->_x3;
matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->row1_col2 = 2.0f * (x1x2 + s0x3);
matrix->row2_col3 = 2.0f * (x2x3 + s0x1);
matrix->row3_col1 = 2.0f * (x1x3 + s0x2);
matrix->r1c2 = 2.0f * (x1x2 + s0x3);
matrix->r2c3 = 2.0f * (x2x3 + s0x1);
matrix->r3c1 = 2.0f * (x1x3 + s0x2);
matrix->row2_col1 = 2.0f * (x1x2 - s0x3);
matrix->row3_col2 = 2.0f * (x2x3 - s0x1);
matrix->row1_col3 = 2.0f * (x1x3 - s0x2);
matrix->r2c1 = 2.0f * (x1x2 - s0x3);
matrix->r3c2 = 2.0f * (x2x3 - s0x1);
matrix->r1c3 = 2.0f * (x1x3 - s0x2);
}
inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor)
@ -543,17 +543,17 @@ inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const
const double x1x3 = versor->_x1 * versor->_x3;
const double x2x3 = versor->_x2 * versor->_x3;
matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
matrix->row1_col2 = 2.0 * (x1x2 + s0x3);
matrix->row2_col3 = 2.0 * (x2x3 + s0x1);
matrix->row3_col1 = 2.0 * (x1x3 + s0x2);
matrix->r1c2 = 2.0 * (x1x2 + s0x3);
matrix->r2c3 = 2.0 * (x2x3 + s0x1);
matrix->r3c1 = 2.0 * (x1x3 + s0x2);
matrix->row2_col1 = 2.0 * (x1x2 - s0x3);
matrix->row3_col2 = 2.0 * (x2x3 - s0x1);
matrix->row1_col3 = 2.0 * (x1x3 - s0x2);
matrix->r2c1 = 2.0 * (x1x2 - s0x3);
matrix->r3c2 = 2.0 * (x2x3 - s0x1);
matrix->r1c3 = 2.0 * (x1x3 - s0x2);
}
// ============= Get Both Matrixes ============== //