Добавление swap функций для векторов, кватернионов и матриц / Swap functions have been added for vectors, quaternions and matrixes
This commit is contained in:
parent
a30629df67
commit
5fd14e4627
10 changed files with 363 additions and 12 deletions
|
|
@ -236,6 +236,7 @@ int main()
|
|||
bg_fp32_versor_combine(&versors1[i], &versors2[i], &results[i]);
|
||||
bg_fp32_versor_get_rotation_matrix(&versors1[i], &matrixes[i]);
|
||||
bg_fp32_matrix3x3_right_product(&matrixes[i], &vectors[i], &vectors[i]);
|
||||
//bg_fp32_versor_turn(&results[i], &vectors[i], &vectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,50 @@ static inline void bg_fp64_matrix2x2_copy(const BgFP64Matrix2x2* from, BgFP64Mat
|
|||
to->r2c2 = from->r2c2;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_swap(BgFP32Matrix2x2* matrix1, BgFP32Matrix2x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
|
||||
const float r2c1 = matrix2->r2c1;
|
||||
const float r2c2 = matrix2->r2c2;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x2_swap(BgFP64Matrix2x2* matrix1, BgFP64Matrix2x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
|
||||
const double r2c1 = matrix2->r2c1;
|
||||
const double r2c2 = matrix2->r2c2;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
static inline void bg_fp32_matrix2x2_set_from_fp64(const BgFP64Matrix2x2* from, BgFP32Matrix2x2* to)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,68 @@ static inline void bg_fp64_matrix2x3_copy(const BgFP64Matrix2x3* from, BgFP64Mat
|
|||
to->r3c2 = from->r3c2;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix2x3_swap(BgFP32Matrix2x3* matrix1, BgFP32Matrix2x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
|
||||
const float r2c1 = matrix2->r2c1;
|
||||
const float r2c2 = matrix2->r2c2;
|
||||
|
||||
const float r3c1 = matrix2->r3c1;
|
||||
const float r3c2 = matrix2->r3c2;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
|
||||
matrix2->r3c1 = matrix1->r3c1;
|
||||
matrix2->r3c2 = matrix1->r3c2;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
|
||||
matrix1->r3c1 = r3c1;
|
||||
matrix1->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix2x3_swap(BgFP64Matrix2x3* matrix1, BgFP64Matrix2x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
|
||||
const double r2c1 = matrix2->r2c1;
|
||||
const double r2c2 = matrix2->r2c2;
|
||||
|
||||
const double r3c1 = matrix2->r3c1;
|
||||
const double r3c2 = matrix2->r3c2;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
|
||||
matrix2->r3c1 = matrix1->r3c1;
|
||||
matrix2->r3c2 = matrix1->r3c2;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
|
||||
matrix1->r3c1 = r3c1;
|
||||
matrix1->r3c2 = r3c2;
|
||||
}
|
||||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
static inline void bg_fp32_matrix2x3_set_from_fp64(const BgFP64Matrix2x3* from, BgFP32Matrix2x3* to)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,86 @@ static inline void bg_fp64_matrix3x2_reset(BgFP64Matrix3x2* matrix)
|
|||
matrix->r2c3 = 0.0;
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix3x2_copy(const BgFP32Matrix3x2* from, BgFP32Matrix3x2* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
to->r1c3 = from->r1c3;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r2c3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x2_copy(const BgFP64Matrix3x2* from, BgFP64Matrix3x2* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
to->r1c3 = from->r1c3;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r2c3;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix3x2_swap(BgFP32Matrix3x2* matrix1, BgFP32Matrix3x2* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
const float r1c3 = matrix2->r1c3;
|
||||
|
||||
const float r2c1 = matrix2->r2c1;
|
||||
const float r2c2 = matrix2->r2c2;
|
||||
const float r2c3 = matrix2->r2c3;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
matrix2->r1c3 = matrix1->r1c3;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
matrix2->r2c3 = matrix1->r2c3;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
matrix1->r1c3 = r1c3;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
matrix1->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x2_swap(BgFP64Matrix3x2* matrix1, BgFP64Matrix3x2* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
const double r1c3 = matrix2->r1c3;
|
||||
|
||||
const double r2c1 = matrix2->r2c1;
|
||||
const double r2c2 = matrix2->r2c2;
|
||||
const double r2c3 = matrix2->r2c3;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
matrix2->r1c3 = matrix1->r1c3;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
matrix2->r2c3 = matrix1->r2c3;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
matrix1->r1c3 = r1c3;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
matrix1->r2c3 = r2c3;
|
||||
}
|
||||
|
||||
// ============= Set from twin type ============= //
|
||||
|
||||
static inline void bg_fp32_matrix3x2_set_from_fp64(const BgFP64Matrix3x2* from, BgFP32Matrix3x2* to)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,86 @@ static inline void bg_fp64_matrix3x3_copy(const BgFP64Matrix3x3* from, BgFP64Mat
|
|||
to->r3c3 = from->r3c3;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_matrix3x3_swap(BgFP32Matrix3x3* matrix1, BgFP32Matrix3x3* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
const float r1c3 = matrix2->r1c3;
|
||||
|
||||
const float r2c1 = matrix2->r2c1;
|
||||
const float r2c2 = matrix2->r2c2;
|
||||
const float r2c3 = matrix2->r2c3;
|
||||
|
||||
const float r3c1 = matrix2->r3c1;
|
||||
const float r3c2 = matrix2->r3c2;
|
||||
const float r3c3 = matrix2->r3c3;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
matrix2->r1c3 = matrix1->r1c3;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
matrix2->r2c3 = matrix1->r2c3;
|
||||
|
||||
matrix2->r3c1 = matrix1->r3c1;
|
||||
matrix2->r3c2 = matrix1->r3c2;
|
||||
matrix2->r3c3 = matrix1->r3c3;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
matrix1->r1c3 = r1c3;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
matrix1->r2c3 = r2c3;
|
||||
|
||||
matrix1->r3c1 = r3c1;
|
||||
matrix1->r3c2 = r3c2;
|
||||
matrix1->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x3_swap(BgFP64Matrix3x3* matrix1, BgFP64Matrix3x3* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
const double r1c3 = matrix2->r1c3;
|
||||
|
||||
const double r2c1 = matrix2->r2c1;
|
||||
const double r2c2 = matrix2->r2c2;
|
||||
const double r2c3 = matrix2->r2c3;
|
||||
|
||||
const double r3c1 = matrix2->r3c1;
|
||||
const double r3c2 = matrix2->r3c2;
|
||||
const double r3c3 = matrix2->r3c3;
|
||||
|
||||
matrix2->r1c1 = matrix1->r1c1;
|
||||
matrix2->r1c2 = matrix1->r1c2;
|
||||
matrix2->r1c3 = matrix1->r1c3;
|
||||
|
||||
matrix2->r2c1 = matrix1->r2c1;
|
||||
matrix2->r2c2 = matrix1->r2c2;
|
||||
matrix2->r2c3 = matrix1->r2c3;
|
||||
|
||||
matrix2->r3c1 = matrix1->r3c1;
|
||||
matrix2->r3c2 = matrix1->r3c2;
|
||||
matrix2->r3c3 = matrix1->r3c3;
|
||||
|
||||
matrix1->r1c1 = r1c1;
|
||||
matrix1->r1c2 = r1c2;
|
||||
matrix1->r1c3 = r1c3;
|
||||
|
||||
matrix1->r2c1 = r2c1;
|
||||
matrix1->r2c2 = r2c2;
|
||||
matrix1->r2c3 = r2c3;
|
||||
|
||||
matrix1->r3c1 = r3c1;
|
||||
matrix1->r3c2 = r3c2;
|
||||
matrix1->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
// ============= Set from twin type ============= //
|
||||
|
||||
static inline void bg_fp32_matrix3x3_set_from_fp64(const BgFP64Matrix3x3* from, BgFP32Matrix3x3* to)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,44 @@ static inline void bg_fp64_quaternion_copy(const BgFP64Quaternion* from, BgFP64Q
|
|||
to->x3 = from->x3;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||