Развитие дуальный чисел, векторов и кватернионов, а также гомогенных векторов и матриц
This commit is contained in:
parent
3f96b661a9
commit
b87518cd3f
21 changed files with 1787 additions and 1511 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue