Переименование s0 -> s, x1 -> x, x2 -> y, x3 -> z, что должно упростить читаемость кода. Также обновление документации
This commit is contained in:
parent
d83ab7160d
commit
b8d383da33
38 changed files with 2104 additions and 2070 deletions
|
|
@ -48,9 +48,9 @@ BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
|
||||||
get_random_value_fp32()
|
get_random_value_fp32()
|
||||||
);
|
);
|
||||||
|
|
||||||
position.shift.x1 = get_random_value_fp32();
|
position.shift.x = get_random_value_fp32();
|
||||||
position.shift.x2 = get_random_value_fp32();
|
position.shift.y = get_random_value_fp32();
|
||||||
position.shift.x3 = get_random_value_fp32();
|
position.shift.z = get_random_value_fp32();
|
||||||
|
|
||||||
bgc_fp32_position3_get_affine(&affines[i], &position);
|
bgc_fp32_position3_get_affine(&affines[i], &position);
|
||||||
}
|
}
|
||||||
|
|
@ -72,9 +72,9 @@ BGC_FP32_Vector3* _create_bgc_vector3_random_list(int amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
vectors[i].x1 = get_random_value_fp32();
|
vectors[i].x = get_random_value_fp32();
|
||||||
vectors[i].x2 = get_random_value_fp32();
|
vectors[i].y = get_random_value_fp32();
|
||||||
vectors[i].x3 = get_random_value_fp32();
|
vectors[i].z = get_random_value_fp32();
|
||||||
}
|
}
|
||||||
|
|
||||||
return vectors;
|
return vectors;
|
||||||
|
|
@ -146,7 +146,7 @@ float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
|
||||||
time = (float)(end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) * 0.000000001f;
|
time = (float)(end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) * 0.000000001f;
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
|
|
||||||
printf("Result vector [0] = (%f, %f, %f)\n", result_vectors[0].x1, result_vectors[0].x2, result_vectors[0].x3);
|
printf("Result vector [0] = (%f, %f, %f)\n", result_vectors[0].x, result_vectors[0].y, result_vectors[0].z);
|
||||||
|
|
||||||
free(result_vectors);
|
free(result_vectors);
|
||||||
free(source_vectors);
|
free(source_vectors);
|
||||||
|
|
|
||||||
|
|
@ -53,22 +53,22 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
|
|
||||||
void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion)
|
void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion)
|
||||||
{
|
{
|
||||||
printf("Quaternion FP32(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
|
printf("Quaternion FP32(s = %0.12f, x = %0.12f, y = %0.12f, z = %0.12f)\n", quaternion->s, quaternion->x, quaternion->y, quaternion->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion)
|
void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion)
|
||||||
{
|
{
|
||||||
printf("Quaternion FP64(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
|
printf("Quaternion FP64(s = %0.12f, x = %0.12f, y = %0.12f, z = %0.12f)\n", quaternion->s, quaternion->x, quaternion->y, quaternion->z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector_fp32(const BGC_FP32_Vector3* vector)
|
void print_vector_fp32(const BGC_FP32_Vector3* vector)
|
||||||
{
|
{
|
||||||
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_fp32_vector3_get_length(vector));
|
printf("(%f, %f, %f) / %f\n", vector->x, vector->y, vector->z, bgc_fp32_vector3_get_length(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector_fp64(const BGC_FP64_Vector3* vector)
|
void print_vector_fp64(const BGC_FP64_Vector3* vector)
|
||||||
{
|
{
|
||||||
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_fp64_vector3_get_length(vector));
|
printf("(%lf, %lf, %lf) / %lf\n", vector->x, vector->y, vector->z, bgc_fp64_vector3_get_length(vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
void list_work(const uint_fast32_t amount, structure_fp32_t* list)
|
void list_work(const uint_fast32_t amount, structure_fp32_t* list)
|
||||||
|
|
|
||||||
|
|
@ -214,48 +214,48 @@ inline void bgc_fp64_dual_quaternion_get_dual_conjugate(BGC_FP64_DualQuaternion*
|
||||||
|
|
||||||
inline void bgc_fp32_dual_quaternion_fully_conjugate(BGC_FP32_DualQuaternion* const quaternion)
|
inline void bgc_fp32_dual_quaternion_fully_conjugate(BGC_FP32_DualQuaternion* const quaternion)
|
||||||
{
|
{
|
||||||
quaternion->real_part.x1 = -quaternion->real_part.x1;
|
quaternion->real_part.x = -quaternion->real_part.x;
|
||||||
quaternion->real_part.x2 = -quaternion->real_part.x2;
|
quaternion->real_part.y = -quaternion->real_part.y;
|
||||||
quaternion->real_part.x3 = -quaternion->real_part.x3;
|
quaternion->real_part.z = -quaternion->real_part.z;
|
||||||
|
|
||||||
quaternion->dual_part.s0 = -quaternion->dual_part.s0;
|
quaternion->dual_part.s = -quaternion->dual_part.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_dual_quaternion_fully_conjugate(BGC_FP64_DualQuaternion* const quaternion)
|
inline void bgc_fp64_dual_quaternion_fully_conjugate(BGC_FP64_DualQuaternion* const quaternion)
|
||||||
{
|
{
|
||||||
quaternion->real_part.x1 = -quaternion->real_part.x1;
|
quaternion->real_part.x = -quaternion->real_part.x;
|
||||||
quaternion->real_part.x2 = -quaternion->real_part.x2;
|
quaternion->real_part.y = -quaternion->real_part.y;
|
||||||
quaternion->real_part.x3 = -quaternion->real_part.x3;
|
quaternion->real_part.z = -quaternion->real_part.z;
|
||||||
|
|
||||||
quaternion->dual_part.s0 = -quaternion->dual_part.s0;
|
quaternion->dual_part.s = -quaternion->dual_part.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Get Fully Conjugate ============= //
|
// ============ Get Fully Conjugate ============= //
|
||||||
|
|
||||||
inline void bgc_fp32_dual_quaternion_get_fully_conjugate(BGC_FP32_DualQuaternion* const conjugate, const BGC_FP32_DualQuaternion* const quaternion)
|
inline void bgc_fp32_dual_quaternion_get_fully_conjugate(BGC_FP32_DualQuaternion* const conjugate, const BGC_FP32_DualQuaternion* const quaternion)
|
||||||
{
|
{
|
||||||
conjugate->real_part.s0 = quaternion->real_part.s0;
|
conjugate->real_part.s = quaternion->real_part.s;
|
||||||
conjugate->real_part.x1 = -quaternion->real_part.x1;
|
conjugate->real_part.x = -quaternion->real_part.x;
|
||||||
conjugate->real_part.x2 = -quaternion->real_part.x2;
|
conjugate->real_part.y = -quaternion->real_part.y;
|
||||||
conjugate->real_part.x3 = -quaternion->real_part.x3;
|
conjugate->real_part.z = -quaternion->real_part.z;
|
||||||
|
|
||||||
conjugate->dual_part.s0 = -quaternion->dual_part.s0;
|
conjugate->dual_part.s = -quaternion->dual_part.s;
|
||||||
conjugate->dual_part.x1 = quaternion->dual_part.x1;
|
conjugate->dual_part.x = quaternion->dual_part.x;
|
||||||
conjugate->dual_part.x2 = quaternion->dual_part.x2;
|
conjugate->dual_part.y = quaternion->dual_part.y;
|
||||||
conjugate->dual_part.x3 = quaternion->dual_part.x3;
|
conjugate->dual_part.z = quaternion->dual_part.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_dual_quaternion_get_fully_conjugate(BGC_FP64_DualQuaternion* const conjugate, const BGC_FP64_DualQuaternion* const quaternion)
|
inline void bgc_fp64_dual_quaternion_get_fully_conjugate(BGC_FP64_DualQuaternion* const conjugate, const BGC_FP64_DualQuaternion* const quaternion)
|
||||||
{
|
{
|
||||||
conjugate->real_part.s0 = quaternion->real_part.s0;
|
conjugate->real_part.s = quaternion->real_part.s;
|
||||||
conjugate->real_part.x1 = -quaternion->real_part.x1;
|
conjugate->real_part.x = -quaternion->real_part.x;
|
||||||
conjugate->real_part.x2 = -quaternion->real_part.x2;
|
conjugate->real_part.y = -quaternion->real_part.y;
|
||||||
conjugate->real_part.x3 = -quaternion->real_part.x3;
|
conjugate->real_part.z = -quaternion->real_part.z;
|
||||||
|
|
||||||
conjugate->dual_part.s0 = -quaternion->dual_part.s0;
|
conjugate->dual_part.s = -quaternion->dual_part.s;
|
||||||
conjugate->dual_part.x1 = quaternion->dual_part.x1;
|
conjugate->dual_part.x = quaternion->dual_part.x;
|
||||||
conjugate->dual_part.x2 = quaternion->dual_part.x2;
|
conjugate->dual_part.y = quaternion->dual_part.y;
|
||||||
conjugate->dual_part.x3 = quaternion->dual_part.x3;
|
conjugate->dual_part.z = quaternion->dual_part.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Normalize ================== //
|
// ================= Normalize ================== //
|
||||||
|
|
|
||||||
|
|
@ -210,64 +210,64 @@ inline void bgc_fp64_dual_vector3_multiply_by_conjugate_dual_number(BGC_FP64_Dua
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
inline void bgc_fp32_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
const float real_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
const float real_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
const float real_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
const float real_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
const float real_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
const float real_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
const float dual_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
const float dual_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
const float dual_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
const float dual_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
const float dual_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
const float dual_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
inline void bgc_fp64_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
const double real_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
const double real_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
const double real_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
const double real_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
const double real_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
const double real_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
const double dual_x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
const double dual_x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
const double dual_x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
const double dual_y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
const double dual_x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
const double dual_z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== Restrict Left Dual Vector Product ====== //
|
// ===== Restrict Left Dual Vector Product ====== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
inline void _bgc_fp32_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_DualVector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
inline void _bgc_fp64_restrict_dual_vector3_multiply_by_matrix3x3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_DualVector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
|
|
||||||
product->real_part.x1 = vector->real_part.x1 * matrix->r1c1 + vector->real_part.x2 * matrix->r2c1 + vector->real_part.x3 * matrix->r3c1;
|
product->real_part.x = vector->real_part.x * matrix->r1c1 + vector->real_part.y * matrix->r2c1 + vector->real_part.z * matrix->r3c1;
|
||||||
product->real_part.x2 = vector->real_part.x1 * matrix->r1c2 + vector->real_part.x2 * matrix->r2c2 + vector->real_part.x3 * matrix->r3c2;
|
product->real_part.y = vector->real_part.x * matrix->r1c2 + vector->real_part.y * matrix->r2c2 + vector->real_part.z * matrix->r3c2;
|
||||||
product->real_part.x3 = vector->real_part.x1 * matrix->r1c3 + vector->real_part.x2 * matrix->r2c3 + vector->real_part.x3 * matrix->r3c3;
|
product->real_part.z = vector->real_part.x * matrix->r1c3 + vector->real_part.y * matrix->r2c3 + vector->real_part.z * matrix->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Divide =================== //
|
// =================== Divide =================== //
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ extern inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* const
|
||||||
extern inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
|
extern inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
|
||||||
extern inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
|
extern inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix1, BGC_FP32_Matrix2x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix, BGC_FP32_Matrix2x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix1, BGC_FP64_Matrix2x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix, BGC_FP64_Matrix2x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
|
extern inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* const destination, const BGC_FP64_Matrix2x2* const source);
|
||||||
extern inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
|
extern inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* const destination, const BGC_FP32_Matrix2x2* const source);
|
||||||
|
|
@ -57,8 +57,8 @@ extern inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column,
|
||||||
extern inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
|
extern inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
|
||||||
extern inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
|
extern inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const basic_matrix, const BGC_FP32_Matrix2x2* const scalable_matrix, const float scale);
|
extern inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const basic_matrix, const BGC_FP32_Matrix2x2* const scalable_matrix, const float scale);
|
||||||
extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const basic_matrix, const BGC_FP64_Matrix2x2* const scalable_matrix, const double scale);
|
extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const basic_matrix, const BGC_FP64_Matrix2x2* const scalable_matrix, const double scale);
|
||||||
|
|
@ -78,11 +78,11 @@ extern inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* cons
|
||||||
extern inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector);
|
extern inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector);
|
||||||
extern inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector);
|
extern inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix3x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix3x2* const matriy);
|
||||||
|
|
||||||
extern inline int bgc_fp32_matrix2x2_divide_by_real_number(BGC_FP32_Matrix2x2* const quotient, const BGC_FP32_Matrix2x2* const dividend, const float divisor);
|
extern inline int bgc_fp32_matrix2x2_divide_by_real_number(BGC_FP32_Matrix2x2* const quotient, const BGC_FP32_Matrix2x2* const dividend, const float divisor);
|
||||||
extern inline int bgc_fp64_matrix2x2_divide_by_real_number(BGC_FP64_Matrix2x2* const quotient, const BGC_FP64_Matrix2x2* const dividend, const double divisor);
|
extern inline int bgc_fp64_matrix2x2_divide_by_real_number(BGC_FP64_Matrix2x2* const quotient, const BGC_FP64_Matrix2x2* const dividend, const double divisor);
|
||||||
|
|
|
||||||
|
|
@ -175,46 +175,46 @@ inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* const destination, const
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix1, BGC_FP32_Matrix2x2* const matrix2)
|
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* const matrix, BGC_FP32_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matriy->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matriy->r1c2;
|
||||||
|
|
||||||
const float r2c1 = matrix2->r2c1;
|
const float r2c1 = matriy->r2c1;
|
||||||
const float r2c2 = matrix2->r2c2;
|
const float r2c2 = matriy->r2c2;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix1, BGC_FP64_Matrix2x2* const matrix2)
|
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* const matrix, BGC_FP64_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matriy->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matriy->r1c2;
|
||||||
|
|
||||||
const double r2c1 = matrix2->r2c1;
|
const double r2c1 = matriy->r2c1;
|
||||||
const double r2c2 = matrix2->r2c2;
|
const double r2c2 = matriy->r2c2;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
@ -346,37 +346,37 @@ inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* const transpos
|
||||||
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x2* const matrix, const int row_number)
|
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x2* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x2* const matrix, const int row_number)
|
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x2* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0;
|
row->x = 0.0;
|
||||||
row->x2 = 0.0;
|
row->y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Set Row =================== //
|
// ================== Set Row =================== //
|
||||||
|
|
@ -384,28 +384,28 @@ inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* const row, const BGC_FP
|
||||||
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
|
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
|
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,37 +414,37 @@ inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* const matrix, const i
|
||||||
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* const column, const BGC_FP32_Matrix2x2* const matrix, const int column_number)
|
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* const column, const BGC_FP32_Matrix2x2* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0f;
|
column->x = 0.0f;
|
||||||
column->x2 = 0.0f;
|
column->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix2x2* const matrix, const int column_number)
|
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix2x2* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0;
|
column->x = 0.0;
|
||||||
column->x2 = 0.0;
|
column->y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Set Column ================= //
|
// ================= Set Column ================= //
|
||||||
|
|
@ -452,49 +452,49 @@ inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* const column, const
|
||||||
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column)
|
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column)
|
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
|
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* const sum, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
|
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* const sum, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add Scaled ================= //
|
// ================= Add Scaled ================= //
|
||||||
|
|
@ -581,45 +581,45 @@ inline void bgc_fp64_matrix2x2_multiply_by_real_number(BGC_FP64_Matrix2x2* const
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const float x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const float y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const double x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const double y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======= Restrict Right Vector Product ======== //
|
// ======= Restrict Right Vector Product ======== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
|
inline void _bgc_fp32_restrict_matrix2x2_multiply_by_vector2(BGC_FP32_Vector2* restrict const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
|
inline void _bgc_fp64_restrict_matrix2x2_multiply_by_vector2(BGC_FP64_Vector2* restrict const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
// ========== Matrix Product 2y at 2y ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
|
inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -628,13 +628,13 @@ inline void bgc_fp32_matrix2x2_multiply_by_matrix2x2(BGC_FP32_Matrix2x2* const p
|
||||||
product->r2c2 = r2c2;
|
product->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
|
inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -643,17 +643,17 @@ inline void bgc_fp64_matrix2x2_multiply_by_matrix2x2(BGC_FP64_Matrix2x2* const p
|
||||||
product->r2c2 = r2c2;
|
product->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
// ========== Matrix Product 2y at 3y ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
|
inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix2x2* const matrix, const BGC_FP32_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -664,15 +664,15 @@ inline void bgc_fp32_matrix2x2_multiply_by_matrix3x2(BGC_FP32_Matrix3x2* const p
|
||||||
product->r2c3 = r2c3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
|
inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix2x2* const matrix, const BGC_FP64_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* const matrix);
|
||||||
extern inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
|
extern inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
|
||||||
extern inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
|
extern inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix1, BGC_FP32_Matrix2x3* const matrix2);
|
extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix, BGC_FP32_Matrix2x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix1, BGC_FP64_Matrix2x3* const matrix2);
|
extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix, BGC_FP64_Matrix2x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
|
extern inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* const destination, const BGC_FP32_Matrix2x3* const source);
|
||||||
extern inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
|
extern inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* const destination, const BGC_FP64_Matrix2x3* const source);
|
||||||
|
|
@ -27,8 +27,8 @@ extern inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column,
|
||||||
extern inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int number, const BGC_FP32_Vector3* const column);
|
extern inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int number, const BGC_FP32_Vector3* const column);
|
||||||
extern inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int number, const BGC_FP64_Vector3* const column);
|
extern inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int number, const BGC_FP64_Vector3* const column);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
|
extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
|
extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const basic_matrix, const BGC_FP32_Matrix2x3* const scalable_matrix, const float scale);
|
extern inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const basic_matrix, const BGC_FP32_Matrix2x3* const scalable_matrix, const float scale);
|
||||||
extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const basic_matrix, const BGC_FP64_Matrix2x3* const scalable_matrix, const double scale);
|
extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const basic_matrix, const BGC_FP64_Matrix2x3* const scalable_matrix, const double scale);
|
||||||
|
|
@ -45,11 +45,11 @@ extern inline void bgc_fp64_matrix2x3_multiply_by_real_number(BGC_FP64_Matrix2x3
|
||||||
extern inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* const vector);
|
extern inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* const vector);
|
||||||
extern inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* const vector);
|
extern inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
|
extern inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix3x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
|
extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix3x2* const matriy);
|
||||||
|
|
||||||
extern inline int bgc_fp32_matrix2x3_divide_by_real_number(BGC_FP32_Matrix2x3* const quotient, const BGC_FP32_Matrix2x3* const dividend, const float divisor);
|
extern inline int bgc_fp32_matrix2x3_divide_by_real_number(BGC_FP32_Matrix2x3* const quotient, const BGC_FP32_Matrix2x3* const dividend, const float divisor);
|
||||||
extern inline int bgc_fp64_matrix2x3_divide_by_real_number(BGC_FP64_Matrix2x3* const quotient, const BGC_FP64_Matrix2x3* const dividend, const double divisor);
|
extern inline int bgc_fp64_matrix2x3_divide_by_real_number(BGC_FP64_Matrix2x3* const quotient, const BGC_FP64_Matrix2x3* const dividend, const double divisor);
|
||||||
|
|
|
||||||
|
|
@ -60,64 +60,64 @@ inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* const destination, const
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix1, BGC_FP32_Matrix2x3* const matrix2)
|
inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* const matrix, BGC_FP32_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matriy->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matriy->r1c2;
|
||||||
|
|
||||||
const float r2c1 = matrix2->r2c1;
|
const float r2c1 = matriy->r2c1;
|
||||||
const float r2c2 = matrix2->r2c2;
|
const float r2c2 = matriy->r2c2;
|
||||||
|
|
||||||
const float r3c1 = matrix2->r3c1;
|
const float r3c1 = matriy->r3c1;
|
||||||
const float r3c2 = matrix2->r3c2;
|
const float r3c2 = matriy->r3c2;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
matrix2->r3c1 = matrix1->r3c1;
|
matriy->r3c1 = matrix->r3c1;
|
||||||
matrix2->r3c2 = matrix1->r3c2;
|
matriy->r3c2 = matrix->r3c2;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
|
|
||||||
matrix1->r3c1 = r3c1;
|
matrix->r3c1 = r3c1;
|
||||||
matrix1->r3c2 = r3c2;
|
matrix->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix1, BGC_FP64_Matrix2x3* const matrix2)
|
inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* const matrix, BGC_FP64_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matriy->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matriy->r1c2;
|
||||||
|
|
||||||
const double r2c1 = matrix2->r2c1;
|
const double r2c1 = matriy->r2c1;
|
||||||
const double r2c2 = matrix2->r2c2;
|
const double r2c2 = matriy->r2c2;
|
||||||
|
|
||||||
const double r3c1 = matrix2->r3c1;
|
const double r3c1 = matriy->r3c1;
|
||||||
const double r3c2 = matrix2->r3c2;
|
const double r3c2 = matriy->r3c2;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
matrix2->r3c1 = matrix1->r3c1;
|
matriy->r3c1 = matrix->r3c1;
|
||||||
matrix2->r3c2 = matrix1->r3c2;
|
matriy->r3c2 = matrix->r3c2;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
|
|
||||||
matrix1->r3c1 = r3c1;
|
matrix->r3c1 = r3c1;
|
||||||
matrix1->r3c2 = r3c2;
|
matrix->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
@ -177,49 +177,49 @@ inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* const transpos
|
||||||
inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x3* const matrix, const int row_number)
|
inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* const row, const BGC_FP32_Matrix2x3* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3) {
|
if (row_number == 3) {
|
||||||
row->x1 = matrix->r3c1;
|
row->x = matrix->r3c1;
|
||||||
row->x2 = matrix->r3c2;
|
row->y = matrix->r3c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x3* const matrix, const int row_number)
|
inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* const row, const BGC_FP64_Matrix2x3* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3) {
|
if (row_number == 3) {
|
||||||
row->x1 = matrix->r3c1;
|
row->x = matrix->r3c1;
|
||||||
row->x2 = matrix->r3c2;
|
row->y = matrix->r3c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Set Row =================== //
|
// ================== Set Row =================== //
|
||||||
|
|
@ -227,40 +227,40 @@ inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* const row, const BGC_FP
|
||||||
inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
|
inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* const matrix, const int row_number, const BGC_FP32_Vector2* const row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3) {
|
if (row_number == 3) {
|
||||||
matrix->r3c1 = row->x1;
|
matrix->r3c1 = row->x;
|
||||||
matrix->r3c2 = row->x2;
|
matrix->r3c2 = row->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
|
inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* const matrix, const int row_number, const BGC_FP64_Vector2* const row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3) {
|
if (row_number == 3) {
|
||||||
matrix->r3c1 = row->x1;
|
matrix->r3c1 = row->x;
|
||||||
matrix->r3c2 = row->x2;
|
matrix->r3c2 = row->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,32 +269,32 @@ inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* const matrix, const i
|
||||||
inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* const column, const BGC_FP32_Matrix2x3* const matrix, const int column_number)
|
inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* const column, const BGC_FP32_Matrix2x3* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
column->x3 = matrix->r3c1;
|
column->z = matrix->r3c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
column->x3 = matrix->r3c2;
|
column->z = matrix->r3c2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix2x3* const matrix, const int column_number)
|
inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix2x3* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
column->x3 = matrix->r3c1;
|
column->z = matrix->r3c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
column->x3 = matrix->r3c2;
|
column->z = matrix->r3c2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -303,59 +303,59 @@ inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* const column, const
|
||||||
inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column)
|
inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
matrix->r3c1 = column->x3;
|
matrix->r3c1 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
matrix->r3c2 = column->x3;
|
matrix->r3c2 = column->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column)
|
inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
matrix->r3c1 = column->x3;
|
matrix->r3c1 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
matrix->r3c2 = column->x3;
|
matrix->r3c2 = column->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
|
inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* const sum, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
|
|
||||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
|
inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* const sum, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
|
|
||||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add Scaled ================= //
|
// ================= Add Scaled ================= //
|
||||||
|
|
@ -466,31 +466,31 @@ inline void bgc_fp64_matrix2x3_multiply_by_real_number(BGC_FP64_Matrix2x3* const
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* vector)
|
inline void bgc_fp32_matrix2x3_multiply_by_vector2(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Vector2* vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* vector)
|
inline void bgc_fp64_matrix2x3_multiply_by_vector2(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Vector2* vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y;
|
||||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
// ========== Matrix Product 2z at 2y ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix2x2* const matrix2)
|
inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
|
|
||||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
|
||||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -502,16 +502,16 @@ inline void bgc_fp32_matrix2x3_multiply_by_matrix2x2(BGC_FP32_Matrix2x3* const p
|
||||||
product->r3c2 = r3c2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix2x2* const matrix2)
|
inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix2x2* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
|
|
||||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
|
||||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -523,36 +523,36 @@ inline void bgc_fp64_matrix2x3_multiply_by_matrix2x2(BGC_FP64_Matrix2x3* const p
|
||||||
product->r3c2 = r3c2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
// ========== Matrix Product 2z at 3y ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
|
inline void bgc_fp32_matrix2x3_multiply_by_matrix3x2(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix2x3* const matrix, const BGC_FP32_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
product->r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
product->r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
product->r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
|
||||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
product->r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
|
||||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
product->r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
|
inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix2x3* const matrix, const BGC_FP64_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1;
|
||||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2;
|
||||||
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
product->r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1;
|
||||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2;
|
||||||
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
product->r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3;
|
||||||
|
|
||||||
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
product->r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1;
|
||||||
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
product->r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2;
|
||||||
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
product->r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Divide =================== //
|
// =================== Divide =================== //
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* const matrix);
|
||||||
extern inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
|
extern inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
|
||||||
extern inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
|
extern inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix1, BGC_FP32_Matrix3x2* const matrix2);
|
extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix, BGC_FP32_Matrix3x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix1, BGC_FP64_Matrix3x2* const matrix2);
|
extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix, BGC_FP64_Matrix3x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
|
extern inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* const destination, const BGC_FP32_Matrix3x2* const source);
|
||||||
extern inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
|
extern inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* const destination, const BGC_FP64_Matrix3x2* const source);
|
||||||
|
|
@ -27,8 +27,8 @@ extern inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* const column,
|
||||||
extern inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
|
extern inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* const matrix, const int column_number, const BGC_FP32_Vector2* const column);
|
||||||
extern inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
|
extern inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* const matrix, const int column_number, const BGC_FP64_Vector2* const column);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2);
|
extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x2* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2);
|
extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x2* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const basic_matrix, const BGC_FP32_Matrix3x2* const scalable_matrix, const float scale);
|
extern inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const basic_matrix, const BGC_FP32_Matrix3x2* const scalable_matrix, const float scale);
|
||||||
extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const basic_matrix, const BGC_FP64_Matrix3x2* const scalable_matrix, const double scale);
|
extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const basic_matrix, const BGC_FP64_Matrix3x2* const scalable_matrix, const double scale);
|
||||||
|
|
@ -45,11 +45,11 @@ extern inline void bgc_fp64_matrix3x2_multiply_by_real_number(BGC_FP64_Matrix3x2
|
||||||
extern inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector);
|
extern inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector);
|
||||||
extern inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector);
|
extern inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix2x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix2x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x3* const matriy);
|
||||||
|
|
||||||
extern inline int bgc_fp32_matrix3x2_divide_by_real_number(BGC_FP32_Matrix3x2* const quotient, const BGC_FP32_Matrix3x2* const dividend, const float divisor);
|
extern inline int bgc_fp32_matrix3x2_divide_by_real_number(BGC_FP32_Matrix3x2* const quotient, const BGC_FP32_Matrix3x2* const dividend, const float divisor);
|
||||||
extern inline int bgc_fp64_matrix3x2_divide_by_real_number(BGC_FP64_Matrix3x2* const quotient, const BGC_FP64_Matrix3x2* const dividend, const double divisor);
|
extern inline int bgc_fp64_matrix3x2_divide_by_real_number(BGC_FP64_Matrix3x2* const quotient, const BGC_FP64_Matrix3x2* const dividend, const double divisor);
|
||||||
|
|
|
||||||
|
|
@ -56,58 +56,58 @@ inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* const destination, const
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix1, BGC_FP32_Matrix3x2* const matrix2)
|
inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* const matrix, BGC_FP32_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matriy->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matriy->r1c2;
|
||||||
const float r1c3 = matrix2->r1c3;
|
const float r1c3 = matriy->r1c3;
|
||||||
|
|
||||||
const float r2c1 = matrix2->r2c1;
|
const float r2c1 = matriy->r2c1;
|
||||||
const float r2c2 = matrix2->r2c2;
|
const float r2c2 = matriy->r2c2;
|
||||||
const float r2c3 = matrix2->r2c3;
|
const float r2c3 = matriy->r2c3;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
matrix2->r1c3 = matrix1->r1c3;
|
matriy->r1c3 = matrix->r1c3;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
matrix2->r2c3 = matrix1->r2c3;
|
matriy->r2c3 = matrix->r2c3;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
matrix1->r1c3 = r1c3;
|
matrix->r1c3 = r1c3;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
matrix1->r2c3 = r2c3;
|
matrix->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix1, BGC_FP64_Matrix3x2* const matrix2)
|
inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* const matrix, BGC_FP64_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matriy->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matriy->r1c2;
|
||||||
const double r1c3 = matrix2->r1c3;
|
const double r1c3 = matriy->r1c3;
|
||||||
|
|
||||||
const double r2c1 = matrix2->r2c1;
|
const double r2c1 = matriy->r2c1;
|
||||||
const double r2c2 = matrix2->r2c2;
|
const double r2c2 = matriy->r2c2;
|
||||||
const double r2c3 = matrix2->r2c3;
|
const double r2c3 = matriy->r2c3;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
matrix2->r1c3 = matrix1->r1c3;
|
matriy->r1c3 = matrix->r1c3;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
matrix2->r2c3 = matrix1->r2c3;
|
matriy->r2c3 = matrix->r2c3;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
matrix1->r1c3 = r1c3;
|
matrix->r1c3 = r1c3;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
matrix1->r2c3 = r2c3;
|
matrix->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
@ -164,46 +164,46 @@ inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* const row, const BGC_FP
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
row->x3 = matrix->r1c3;
|
row->z = matrix->r1c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
row->x3 = matrix->r2c3;
|
row->z = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
row->x3 = 0.0f;
|
row->z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x2* const matrix, const int row_number)
|
inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x2* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
row->x3 = matrix->r1c3;
|
row->z = matrix->r1c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
row->x3 = matrix->r2c3;
|
row->z = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
row->x3 = 0.0f;
|
row->z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Set Row =================== //
|
// ================== Set Row =================== //
|
||||||
|
|
@ -212,17 +212,17 @@ inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* const matrix, const i
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
matrix->r1c3 = row->x3;
|
matrix->r1c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
matrix->r2c3 = row->x3;
|
matrix->r2c3 = row->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,17 +230,17 @@ inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* const matrix, const i
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
matrix->r1c3 = row->x3;
|
matrix->r1c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
matrix->r2c3 = row->x3;
|
matrix->r2c3 = row->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,54 +250,54 @@ inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* const column, const
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c3;
|
column->x = matrix->r1c3;
|
||||||
column->x2 = matrix->r2c3;
|
column->y = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0f;
|
column->x = 0.0f;
|
||||||
column->x2 = 0.0f;
|
column->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix3x2* const matrix, const int column_number)
|
inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* const column, const BGC_FP64_Matrix3x2* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c3;
|
column->x = matrix->r1c3;
|
||||||
column->x2 = matrix->r2c3;
|
column->y = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0;
|
column->x = 0.0;
|
||||||
column->x2 = 0.0;
|
column->y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Set Column ================= //
|
// ================= Set Column ================= //
|
||||||
|
|
@ -306,22 +306,22 @@ inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* const matrix, cons
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = column->x1;
|
matrix->r1c3 = column->x;
|
||||||
matrix->r2c3 = column->x2;
|
matrix->r2c3 = column->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,47 +329,47 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* const matrix, cons
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = column->x1;
|
matrix->r1c3 = column->x;
|
||||||
matrix->r2c3 = column->x2;
|
matrix->r2c3 = column->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x2* const matrix2)
|
inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* const sum, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x2* const matrix2)
|
inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* const sum, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x2* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add Scaled ================= //
|
// ================= Add Scaled ================= //
|
||||||
|
|
@ -472,47 +472,47 @@ inline void bgc_fp64_matrix3x2_multiply_by_real_number(BGC_FP64_Matrix3x2* const
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector)
|
inline void bgc_fp32_matrix3x2_multiply_by_vector3(BGC_FP32_Vector2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector)
|
inline void bgc_fp64_matrix3x2_multiply_by_vector3(BGC_FP64_Vector2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3y at 2z ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
|
inline void bgc_fp32_matrix3x2_multiply_by_matrix2x3(BGC_FP32_Matrix2x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
|
|
||||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
|
inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
product->r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
product->r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
|
|
||||||
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
product->r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
product->r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x2 ========= //
|
// ========== Matrix Product 3y at 3y ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
|
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const product, const BGC_FP32_Matrix3x2* const matrix, const BGC_FP32_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -523,15 +523,15 @@ inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* const p
|
||||||
product->r2c3 = r2c3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
|
inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2* const product, const BGC_FP64_Matrix3x2* const matrix, const BGC_FP64_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ extern inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* const ma
|
||||||
extern inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
|
extern inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
|
||||||
extern inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
|
extern inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix1, BGC_FP32_Matrix3x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix, BGC_FP32_Matrix3x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix1, BGC_FP64_Matrix3x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix, BGC_FP64_Matrix3x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
|
extern inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* const destination, const BGC_FP64_Matrix3x3* const source);
|
||||||
extern inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
|
extern inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* const destination, const BGC_FP32_Matrix3x3* const source);
|
||||||
|
|
@ -51,8 +51,8 @@ extern inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* const column,
|
||||||
extern inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column);
|
extern inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* const matrix, const int column_number, const BGC_FP32_Vector3* const column);
|
||||||
extern inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column);
|
extern inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* const matrix, const int column_number, const BGC_FP64_Vector3* const column);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const basic_matrix, const BGC_FP32_Matrix3x3* const scalable_matrix, const float scale);
|
extern inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const basic_matrix, const BGC_FP32_Matrix3x3* const scalable_matrix, const float scale);
|
||||||
extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const basic_matrix, const BGC_FP64_Matrix3x3* const scalable_matrix, const double scale);
|
extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const basic_matrix, const BGC_FP64_Matrix3x3* const scalable_matrix, const double scale);
|
||||||
|
|
@ -78,11 +78,11 @@ extern inline void _bgc_fp64_restrict_matrix3x3_multiply_by_vector3(BGC_FP64_Vec
|
||||||
extern inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector);
|
extern inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector);
|
||||||
extern inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector);
|
extern inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix2x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix2x3* const matriy);
|
||||||
|
|
||||||
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2);
|
extern inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy);
|
||||||
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2);
|
extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy);
|
||||||
|
|
||||||
extern inline int bgc_fp32_matrix3x3_divide_by_real_number(BGC_FP32_Matrix3x3* const quotient, const BGC_FP32_Matrix3x3* const dividend, const float divisor);
|
extern inline int bgc_fp32_matrix3x3_divide_by_real_number(BGC_FP32_Matrix3x3* const quotient, const BGC_FP32_Matrix3x3* const dividend, const float divisor);
|
||||||
extern inline int bgc_fp64_matrix3x3_divide_by_real_number(BGC_FP64_Matrix3x3* const quotient, const BGC_FP64_Matrix3x3* const dividend, const double divisor);
|
extern inline int bgc_fp64_matrix3x3_divide_by_real_number(BGC_FP64_Matrix3x3* const quotient, const BGC_FP64_Matrix3x3* const dividend, const double divisor);
|
||||||
|
|
|
||||||
|
|
@ -136,82 +136,82 @@ inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* const destination, const
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix1, BGC_FP32_Matrix3x3* const matrix2)
|
inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* const matrix, BGC_FP32_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix2->r1c1;
|
const float r1c1 = matriy->r1c1;
|
||||||
const float r1c2 = matrix2->r1c2;
|
const float r1c2 = matriy->r1c2;
|
||||||
const float r1c3 = matrix2->r1c3;
|
const float r1c3 = matriy->r1c3;
|
||||||
|
|
||||||
const float r2c1 = matrix2->r2c1;
|
const float r2c1 = matriy->r2c1;
|
||||||
const float r2c2 = matrix2->r2c2;
|
const float r2c2 = matriy->r2c2;
|
||||||
const float r2c3 = matrix2->r2c3;
|
const float r2c3 = matriy->r2c3;
|
||||||
|
|
||||||
const float r3c1 = matrix2->r3c1;
|
const float r3c1 = matriy->r3c1;
|
||||||
const float r3c2 = matrix2->r3c2;
|
const float r3c2 = matriy->r3c2;
|
||||||
const float r3c3 = matrix2->r3c3;
|
const float r3c3 = matriy->r3c3;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
matrix2->r1c3 = matrix1->r1c3;
|
matriy->r1c3 = matrix->r1c3;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
matrix2->r2c3 = matrix1->r2c3;
|
matriy->r2c3 = matrix->r2c3;
|
||||||
|
|
||||||
matrix2->r3c1 = matrix1->r3c1;
|
matriy->r3c1 = matrix->r3c1;
|
||||||
matrix2->r3c2 = matrix1->r3c2;
|
matriy->r3c2 = matrix->r3c2;
|
||||||
matrix2->r3c3 = matrix1->r3c3;
|
matriy->r3c3 = matrix->r3c3;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
matrix1->r1c3 = r1c3;
|
matrix->r1c3 = r1c3;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
matrix1->r2c3 = r2c3;
|
matrix->r2c3 = r2c3;
|
||||||
|
|
||||||
matrix1->r3c1 = r3c1;
|
matrix->r3c1 = r3c1;
|
||||||
matrix1->r3c2 = r3c2;
|
matrix->r3c2 = r3c2;
|
||||||
matrix1->r3c3 = r3c3;
|
matrix->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix1, BGC_FP64_Matrix3x3* const matrix2)
|
inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* const matrix, BGC_FP64_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix2->r1c1;
|
const double r1c1 = matriy->r1c1;
|
||||||
const double r1c2 = matrix2->r1c2;
|
const double r1c2 = matriy->r1c2;
|
||||||
const double r1c3 = matrix2->r1c3;
|
const double r1c3 = matriy->r1c3;
|
||||||
|
|
||||||
const double r2c1 = matrix2->r2c1;
|
const double r2c1 = matriy->r2c1;
|
||||||
const double r2c2 = matrix2->r2c2;
|
const double r2c2 = matriy->r2c2;
|
||||||
const double r2c3 = matrix2->r2c3;
|
const double r2c3 = matriy->r2c3;
|
||||||
|
|
||||||
const double r3c1 = matrix2->r3c1;
|
const double r3c1 = matriy->r3c1;
|
||||||
const double r3c2 = matrix2->r3c2;
|
const double r3c2 = matriy->r3c2;
|
||||||
const double r3c3 = matrix2->r3c3;
|
const double r3c3 = matriy->r3c3;
|
||||||
|
|
||||||
matrix2->r1c1 = matrix1->r1c1;
|
matriy->r1c1 = matrix->r1c1;
|
||||||
matrix2->r1c2 = matrix1->r1c2;
|
matriy->r1c2 = matrix->r1c2;
|
||||||
matrix2->r1c3 = matrix1->r1c3;
|
matriy->r1c3 = matrix->r1c3;
|
||||||
|
|
||||||
matrix2->r2c1 = matrix1->r2c1;
|
matriy->r2c1 = matrix->r2c1;
|
||||||
matrix2->r2c2 = matrix1->r2c2;
|
matriy->r2c2 = matrix->r2c2;
|
||||||
matrix2->r2c3 = matrix1->r2c3;
|
matriy->r2c3 = matrix->r2c3;
|
||||||
|
|
||||||
matrix2->r3c1 = matrix1->r3c1;
|
matriy->r3c1 = matrix->r3c1;
|
||||||
matrix2->r3c2 = matrix1->r3c2;
|
matriy->r3c2 = matrix->r3c2;
|
||||||
matrix2->r3c3 = matrix1->r3c3;
|
matriy->r3c3 = matrix->r3c3;
|
||||||
|
|
||||||
matrix1->r1c1 = r1c1;
|
matrix->r1c1 = r1c1;
|
||||||
matrix1->r1c2 = r1c2;
|
matrix->r1c2 = r1c2;
|
||||||
matrix1->r1c3 = r1c3;
|
matrix->r1c3 = r1c3;
|
||||||
|
|
||||||
matrix1->r2c1 = r2c1;
|
matrix->r2c1 = r2c1;
|
||||||
matrix1->r2c2 = r2c2;
|
matrix->r2c2 = r2c2;
|
||||||
matrix1->r2c3 = r2c3;
|
matrix->r2c3 = r2c3;
|
||||||
|
|
||||||
matrix1->r3c1 = r3c1;
|
matrix->r3c1 = r3c1;
|
||||||
matrix1->r3c2 = r3c2;
|
matrix->r3c2 = r3c2;
|
||||||
matrix1->r3c3 = r3c3;
|
matrix->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
@ -426,62 +426,62 @@ inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* const row, const BGC_FP
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
row->x3 = matrix->r1c3;
|
row->z = matrix->r1c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
row->x3 = matrix->r2c3;
|
row->z = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3)
|
if (row_number == 3)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r3c1;
|
row->x = matrix->r3c1;
|
||||||
row->x2 = matrix->r3c2;
|
row->y = matrix->r3c2;
|
||||||
row->x3 = matrix->r3c3;
|
row->z = matrix->r3c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0f;
|
row->x = 0.0f;
|
||||||
row->x2 = 0.0f;
|
row->y = 0.0f;
|
||||||
row->x3 = 0.0f;
|
row->z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x3* const matrix, const int row_number)
|
inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* const row, const BGC_FP64_Matrix3x3* const matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r1c1;
|
row->x = matrix->r1c1;
|
||||||
row->x2 = matrix->r1c2;
|
row->y = matrix->r1c2;
|
||||||
row->x3 = matrix->r1c3;
|
row->z = matrix->r1c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r2c1;
|
row->x = matrix->r2c1;
|
||||||
row->x2 = matrix->r2c2;
|
row->y = matrix->r2c2;
|
||||||
row->x3 = matrix->r2c3;
|
row->z = matrix->r2c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3)
|
if (row_number == 3)
|
||||||
{
|
{
|
||||||
row->x1 = matrix->r3c1;
|
row->x = matrix->r3c1;
|
||||||
row->x2 = matrix->r3c2;
|
row->y = matrix->r3c2;
|
||||||
row->x3 = matrix->r3c3;
|
row->z = matrix->r3c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
row->x1 = 0.0;
|
row->x = 0.0;
|
||||||
row->x2 = 0.0;
|
row->y = 0.0;
|
||||||
row->x3 = 0.0;
|
row->z = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Set Row =================== //
|
// ================== Set Row =================== //
|
||||||
|
|
@ -490,25 +490,25 @@ inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* const matrix, const i
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
matrix->r1c3 = row->x3;
|
matrix->r1c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
matrix->r2c3 = row->x3;
|
matrix->r2c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3)
|
if (row_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = row->x1;
|
matrix->r3c1 = row->x;
|
||||||
matrix->r3c2 = row->x2;
|
matrix->r3c2 = row->y;
|
||||||
matrix->r3c3 = row->x3;
|
matrix->r3c3 = row->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -516,25 +516,25 @@ inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* const matrix, const i
|
||||||
{
|
{
|
||||||
if (row_number == 1)
|
if (row_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = row->x1;
|
matrix->r1c1 = row->x;
|
||||||
matrix->r1c2 = row->x2;
|
matrix->r1c2 = row->y;
|
||||||
matrix->r1c3 = row->x3;
|
matrix->r1c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2)
|
if (row_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r2c1 = row->x1;
|
matrix->r2c1 = row->x;
|
||||||
matrix->r2c2 = row->x2;
|
matrix->r2c2 = row->y;
|
||||||
matrix->r2c3 = row->x3;
|
matrix->r2c3 = row->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 3)
|
if (row_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r3c1 = row->x1;
|
matrix->r3c1 = row->x;
|
||||||
matrix->r3c2 = row->x2;
|
matrix->r3c2 = row->y;
|
||||||
matrix->r3c3 = row->x3;
|
matrix->r3c3 = row->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -544,62 +544,62 @@ inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* const column, const
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
column->x3 = matrix->r3c1;
|
column->z = matrix->r3c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
column->x3 = matrix->r3c2;
|
column->z = matrix->r3c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c3;
|
column->x = matrix->r1c3;
|
||||||
column->x2 = matrix->r2c3;
|
column->y = matrix->r2c3;
|
||||||
column->x3 = matrix->r3c3;
|
column->z = matrix->r3c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0f;
|
column->x = 0.0f;
|
||||||
column->x2 = 0.0f;
|
column->y = 0.0f;
|
||||||
column->x3 = 0.0f;
|
column->z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix3x3* const matrix, const int column_number)
|
inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* const column, const BGC_FP64_Matrix3x3* const matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c1;
|
column->x = matrix->r1c1;
|
||||||
column->x2 = matrix->r2c1;
|
column->y = matrix->r2c1;
|
||||||
column->x3 = matrix->r3c1;
|
column->z = matrix->r3c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c2;
|
column->x = matrix->r1c2;
|
||||||
column->x2 = matrix->r2c2;
|
column->y = matrix->r2c2;
|
||||||
column->x3 = matrix->r3c2;
|
column->z = matrix->r3c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
column->x1 = matrix->r1c3;
|
column->x = matrix->r1c3;
|
||||||
column->x2 = matrix->r2c3;
|
column->y = matrix->r2c3;
|
||||||
column->x3 = matrix->r3c3;
|
column->z = matrix->r3c3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
column->x1 = 0.0;
|
column->x = 0.0;
|
||||||
column->x2 = 0.0;
|
column->y = 0.0;
|
||||||
column->x3 = 0.0;
|
column->z = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Set Column ================= //
|
// ================= Set Column ================= //
|
||||||
|
|
@ -608,25 +608,25 @@ inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* const matrix, cons
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
matrix->r3c1 = column->x3;
|
matrix->r3c1 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
matrix->r3c2 = column->x3;
|
matrix->r3c2 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = column->x1;
|
matrix->r1c3 = column->x;
|
||||||
matrix->r2c3 = column->x2;
|
matrix->r2c3 = column->y;
|
||||||
matrix->r3c3 = column->x3;
|
matrix->r3c3 = column->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -634,58 +634,58 @@ inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* const matrix, cons
|
||||||
{
|
{
|
||||||
if (column_number == 1)
|
if (column_number == 1)
|
||||||
{
|
{
|
||||||
matrix->r1c1 = column->x1;
|
matrix->r1c1 = column->x;
|
||||||
matrix->r2c1 = column->x2;
|
matrix->r2c1 = column->y;
|
||||||
matrix->r3c1 = column->x3;
|
matrix->r3c1 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2)
|
if (column_number == 2)
|
||||||
{
|
{
|
||||||
matrix->r1c2 = column->x1;
|
matrix->r1c2 = column->x;
|
||||||
matrix->r2c2 = column->x2;
|
matrix->r2c2 = column->y;
|
||||||
matrix->r3c2 = column->x3;
|
matrix->r3c2 = column->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 3)
|
if (column_number == 3)
|
||||||
{
|
{
|
||||||
matrix->r1c3 = column->x1;
|
matrix->r1c3 = column->x;
|
||||||
matrix->r2c3 = column->x2;
|
matrix->r2c3 = column->y;
|
||||||
matrix->r3c3 = column->x3;
|
matrix->r3c3 = column->z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
|
inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* const sum, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
|
||||||
|
|
||||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
|
||||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
sum->r3c3 = matrix->r3c3 + matriy->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
|
inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* const sum, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
sum->r1c1 = matrix->r1c1 + matriy->r1c1;
|
||||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
sum->r1c2 = matrix->r1c2 + matriy->r1c2;
|
||||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
sum->r1c3 = matrix->r1c3 + matriy->r1c3;
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
sum->r2c1 = matrix->r2c1 + matriy->r2c1;
|
||||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
sum->r2c2 = matrix->r2c2 + matriy->r2c2;
|
||||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
sum->r2c3 = matrix->r2c3 + matriy->r2c3;
|
||||||
|
|
||||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
sum->r3c1 = matrix->r3c1 + matriy->r3c1;
|
||||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
sum->r3c2 = matrix->r3c2 + matriy->r3c2;
|
||||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
sum->r3c3 = matrix->r3c3 + matriy->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add Scaled ================= //
|
// ================= Add Scaled ================= //
|
||||||
|
|
@ -820,118 +820,118 @@ inline void bgc_fp64_matrix3x3_multiply_by_real_number(BGC_FP64_Matrix3x3* const
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
|
inline void bgc_fp32_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
const float x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
const float y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
const float z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
|
inline void bgc_fp64_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
const double x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
const double y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
const double z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Right Dual Vector Product ========== //
|
// ========= Right Dual Vector Product ========== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
|
inline void bgc_fp32_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
|
||||||
{
|
{
|
||||||
const float real_x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
|
const float real_x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
|
||||||
const float real_x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
|
const float real_y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
|
||||||
const float real_x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
|
const float real_z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
|
||||||
|
|
||||||
const float dual_x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
|
const float dual_x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
|
||||||
const float dual_x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
|
const float dual_y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
|
||||||
const float dual_x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
|
const float dual_z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
|
inline void bgc_fp64_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
|
||||||
{
|
{
|
||||||
const double real_x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
|
const double real_x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
|
||||||
const double real_x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
|
const double real_y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
|
||||||
const double real_x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
|
const double real_z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
|
||||||
|
|
||||||
const double dual_x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
|
const double dual_x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
|
||||||
const double dual_x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
|
const double dual_y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
|
||||||
const double dual_x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
|
const double dual_z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======= Restrict Right Vector Product ======== //
|
// ======= Restrict Right Vector Product ======== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
|
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_vector3(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
|
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_vector3(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
product->x = matrix->r1c1 * vector->x + matrix->r1c2 * vector->y + matrix->r1c3 * vector->z;
|
||||||
product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
product->y = matrix->r2c1 * vector->x + matrix->r2c2 * vector->y + matrix->r2c3 * vector->z;
|
||||||
product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
product->z = matrix->r3c1 * vector->x + matrix->r3c2 * vector->y + matrix->r3c3 * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========= Right Dual Vector Product ========== //
|
// ========= Right Dual Vector Product ========== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
|
inline void _bgc_fp32_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_DualVector3* const vector)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
|
product->real_part.x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
|
||||||
product->real_part.x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
|
product->real_part.y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
|
||||||
product->real_part.x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
|
product->real_part.z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
|
||||||
|
|
||||||
product->real_part.x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
|
product->real_part.x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
|
||||||
product->real_part.x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
|
product->real_part.y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
|
||||||
product->real_part.x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
|
product->real_part.z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
|
inline void _bgc_fp64_restrict_matrix3x3_multiply_by_dual_vector3(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_DualVector3* const vector)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = matrix->r1c1 * vector->real_part.x1 + matrix->r1c2 * vector->real_part.x2 + matrix->r1c3 * vector->real_part.x3;
|
product->real_part.x = matrix->r1c1 * vector->real_part.x + matrix->r1c2 * vector->real_part.y + matrix->r1c3 * vector->real_part.z;
|
||||||
product->real_part.x2 = matrix->r2c1 * vector->real_part.x1 + matrix->r2c2 * vector->real_part.x2 + matrix->r2c3 * vector->real_part.x3;
|
product->real_part.y = matrix->r2c1 * vector->real_part.x + matrix->r2c2 * vector->real_part.y + matrix->r2c3 * vector->real_part.z;
|
||||||
product->real_part.x3 = matrix->r3c1 * vector->real_part.x1 + matrix->r3c2 * vector->real_part.x2 + matrix->r3c3 * vector->real_part.x3;
|
product->real_part.z = matrix->r3c1 * vector->real_part.x + matrix->r3c2 * vector->real_part.y + matrix->r3c3 * vector->real_part.z;
|
||||||
|
|
||||||
product->real_part.x1 = matrix->r1c1 * vector->dual_part.x1 + matrix->r1c2 * vector->dual_part.x2 + matrix->r1c3 * vector->dual_part.x3;
|
product->real_part.x = matrix->r1c1 * vector->dual_part.x + matrix->r1c2 * vector->dual_part.y + matrix->r1c3 * vector->dual_part.z;
|
||||||
product->real_part.x2 = matrix->r2c1 * vector->dual_part.x1 + matrix->r2c2 * vector->dual_part.x2 + matrix->r2c3 * vector->dual_part.x3;
|
product->real_part.y = matrix->r2c1 * vector->dual_part.x + matrix->r2c2 * vector->dual_part.y + matrix->r2c3 * vector->dual_part.z;
|
||||||
product->real_part.x3 = matrix->r3c1 * vector->dual_part.x1 + matrix->r3c2 * vector->dual_part.x2 + matrix->r3c3 * vector->dual_part.x3;
|
product->real_part.z = matrix->r3c1 * vector->dual_part.x + matrix->r3c2 * vector->dual_part.y + matrix->r3c3 * vector->dual_part.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 2x3 ========= //
|
// ========== Matrix Product 3z at 2z ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix2x3* const matrix2)
|
inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
|
|
||||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
|
||||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -943,16 +943,16 @@ inline void bgc_fp32_matrix3x3_multiply_by_matrix2x3(BGC_FP32_Matrix2x3* const p
|
||||||
product->r3c2 = r3c2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix2x3* const matrix2)
|
inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix2x3* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
|
|
||||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
|
||||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -964,21 +964,21 @@ inline void bgc_fp64_matrix3x3_multiply_by_matrix2x3(BGC_FP64_Matrix2x3* const p
|
||||||
product->r3c2 = r3c2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 3x3 ========= //
|
// ========== Matrix Product 3z at 3z ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix1, const BGC_FP32_Matrix3x3* const matrix2)
|
inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const product, const BGC_FP32_Matrix3x3* const matrix, const BGC_FP32_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const float r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const float r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
const float r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
|
||||||
|
|
||||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const float r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const float r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
const float r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
|
||||||
|
|
||||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
const float r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
|
||||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
const float r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
|
||||||
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
const float r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3 + matrix->r3c3 * matriy->r3c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
@ -993,19 +993,19 @@ inline void bgc_fp32_matrix3x3_multiply_by_matrix3x3(BGC_FP32_Matrix3x3* const p
|
||||||
product->r3c3 = r3c3;
|
product->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix1, const BGC_FP64_Matrix3x3* const matrix2)
|
inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3* const product, const BGC_FP64_Matrix3x3* const matrix, const BGC_FP64_Matrix3x3* const matriy)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const double r1c1 = matrix->r1c1 * matriy->r1c1 + matrix->r1c2 * matriy->r2c1 + matrix->r1c3 * matriy->r3c1;
|
||||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
const double r1c2 = matrix->r1c1 * matriy->r1c2 + matrix->r1c2 * matriy->r2c2 + matrix->r1c3 * matriy->r3c2;
|
||||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
const double r1c3 = matrix->r1c1 * matriy->r1c3 + matrix->r1c2 * matriy->r2c3 + matrix->r1c3 * matriy->r3c3;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const double r2c1 = matrix->r2c1 * matriy->r1c1 + matrix->r2c2 * matriy->r2c1 + matrix->r2c3 * matriy->r3c1;
|
||||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
const double r2c2 = matrix->r2c1 * matriy->r1c2 + matrix->r2c2 * matriy->r2c2 + matrix->r2c3 * matriy->r3c2;
|
||||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
const double r2c3 = matrix->r2c1 * matriy->r1c3 + matrix->r2c2 * matriy->r2c3 + matrix->r2c3 * matriy->r3c3;
|
||||||
|
|
||||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
const double r3c1 = matrix->r3c1 * matriy->r1c1 + matrix->r3c2 * matriy->r2c1 + matrix->r3c3 * matriy->r3c1;
|
||||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
const double r3c2 = matrix->r3c1 * matriy->r1c2 + matrix->r3c2 * matriy->r2c2 + matrix->r3c3 * matriy->r3c2;
|
||||||
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
const double r3c3 = matrix->r3c1 * matriy->r1c3 + matrix->r3c2 * matriy->r2c3 + matrix->r3c3 * matriy->r3c3;
|
||||||
|
|
||||||
product->r1c1 = r1c1;
|
product->r1c1 = r1c1;
|
||||||
product->r1c2 = r1c2;
|
product->r1c2 = r1c2;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ extern inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* const quaterni
|
||||||
extern inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* const quaternion);
|
extern inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* const quaternion);
|
||||||
extern inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* const quaternion);
|
extern inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* const quaternion);
|
||||||
|
|
||||||
extern inline void bgc_fp32_quaternion_set_values(BGC_FP32_Quaternion* const quaternion, const float s0, const float x1, const float x2, const float x3);
|
extern inline void bgc_fp32_quaternion_set_values(BGC_FP32_Quaternion* const quaternion, const float s, const float x, const float y, const float z);
|
||||||
extern inline void bgc_fp64_quaternion_set_values(BGC_FP64_Quaternion* const quaternion, const double s0, const double x1, const double x2, const double x3);
|
extern inline void bgc_fp64_quaternion_set_values(BGC_FP64_Quaternion* const quaternion, const double s, const double x, const double y, const double z);
|
||||||
|
|
||||||
extern inline float bgc_fp32_quaternion_get_square_magnitude(const BGC_FP32_Quaternion* const quaternion);
|
extern inline float bgc_fp32_quaternion_get_square_magnitude(const BGC_FP32_Quaternion* const quaternion);
|
||||||
extern inline double bgc_fp64_quaternion_get_square_magnitude(const BGC_FP64_Quaternion* const quaternion);
|
extern inline double bgc_fp64_quaternion_get_square_magnitude(const BGC_FP64_Quaternion* const quaternion);
|
||||||
|
|
@ -158,13 +158,13 @@ extern inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* const
|
||||||
|
|
||||||
int bgc_fp32_quaternion_get_power(BGC_FP32_Quaternion* const power, const BGC_FP32_Quaternion* const base, const float exponent)
|
int bgc_fp32_quaternion_get_power(BGC_FP32_Quaternion* const power, const BGC_FP32_Quaternion* const base, const float exponent)
|
||||||
{
|
{
|
||||||
const float s0s0 = base->s0 * base->s0;
|
const float ss = base->s * base->s;
|
||||||
const float x1x1 = base->x1 * base->x1;
|
const float xx = base->x * base->x;
|
||||||
const float x2x2 = base->x2 * base->x2;
|
const float yy = base->y * base->y;
|
||||||
const float x3x3 = base->x3 * base->x3;
|
const float zz = base->z * base->z;
|
||||||
|
|
||||||
const float square_vector = x1x1 + (x2x2 + x3x3);
|
const float square_vector = xx + (yy + zz);
|
||||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
const float square_modulus = (ss + xx) + (yy + zz);
|
||||||
|
|
||||||
// isnan(square_modulus) means checking for NaN value at square_modulus
|
// isnan(square_modulus) means checking for NaN value at square_modulus
|
||||||
if (isnan(square_modulus)) {
|
if (isnan(square_modulus)) {
|
||||||
|
|
@ -172,40 +172,40 @@ int bgc_fp32_quaternion_get_power(BGC_FP32_Quaternion* const power, const BGC_FP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
if (base->s0 < 0.0f) {
|
if (base->s < 0.0f) {
|
||||||
return BGC_FAILURE;
|
return BGC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
power->s0 = powf(base->s0, exponent);
|
power->s = powf(base->s, exponent);
|
||||||
power->x1 = 0.0f;
|
power->x = 0.0f;
|
||||||
power->x2 = 0.0f;
|
power->y = 0.0f;
|
||||||
power->x3 = 0.0f;
|
power->z = 0.0f;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float vector_modulus = sqrtf(square_vector);
|
const float vector_modulus = sqrtf(square_vector);
|
||||||
const float power_angle = atan2f(vector_modulus, base->s0) * exponent;
|
const float power_angle = atan2f(vector_modulus, base->s) * exponent;
|
||||||
const float power_modulus = powf(square_modulus, 0.5f * exponent);
|
const float power_modulus = powf(square_modulus, 0.5f * exponent);
|
||||||
const float multiplier = power_modulus * sinf(power_angle) / vector_modulus;
|
const float multiplier = power_modulus * sinf(power_angle) / vector_modulus;
|
||||||
|
|
||||||
power->s0 = power_modulus * cosf(power_angle);
|
power->s = power_modulus * cosf(power_angle);
|
||||||
power->x1 = base->x1 * multiplier;
|
power->x = base->x * multiplier;
|
||||||
power->x2 = base->x2 * multiplier;
|
power->y = base->y * multiplier;
|
||||||
power->x3 = base->x3 * multiplier;
|
power->z = base->z * multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bgc_fp64_quaternion_get_power(BGC_FP64_Quaternion* const power, const BGC_FP64_Quaternion* const base, const double exponent)
|
int bgc_fp64_quaternion_get_power(BGC_FP64_Quaternion* const power, const BGC_FP64_Quaternion* const base, const double exponent)
|
||||||
{
|
{
|
||||||
const double s0s0 = base->s0 * base->s0;
|
const double ss = base->s * base->s;
|
||||||
const double x1x1 = base->x1 * base->x1;
|
const double xx = base->x * base->x;
|
||||||
const double x2x2 = base->x2 * base->x2;
|
const double yy = base->y * base->y;
|
||||||
const double x3x3 = base->x3 * base->x3;
|
const double zz = base->z * base->z;
|
||||||
|
|
||||||
const double square_vector = x1x1 + (x2x2 + x3x3);
|
const double square_vector = xx + (yy + zz);
|
||||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
const double square_modulus = (ss + xx) + (yy + zz);
|
||||||
|
|
||||||
// isnan(square_modulus) means checking for NaN value at square_modulus
|
// isnan(square_modulus) means checking for NaN value at square_modulus
|
||||||
if (isnan(square_modulus)) {
|
if (isnan(square_modulus)) {
|
||||||
|
|
@ -213,27 +213,27 @@ int bgc_fp64_quaternion_get_power(BGC_FP64_Quaternion* const power, const BGC_FP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
if (base->s0 < 0.0) {
|
if (base->s < 0.0) {
|
||||||
return BGC_FAILURE;
|
return BGC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
power->s0 = pow(base->s0, exponent);
|
power->s = pow(base->s, exponent);
|
||||||
power->x1 = 0.0;
|
power->x = 0.0;
|
||||||
power->x2 = 0.0;
|
power->y = 0.0;
|
||||||
power->x3 = 0.0;
|
power->z = 0.0;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double vector_modulus = sqrt(square_vector);
|
const double vector_modulus = sqrt(square_vector);
|
||||||
const double power_angle = atan2(vector_modulus, base->s0) * exponent;
|
const double power_angle = atan2(vector_modulus, base->s) * exponent;
|
||||||
const double power_modulus = pow(square_modulus, 0.5 * exponent);
|
const double power_modulus = pow(square_modulus, 0.5 * exponent);
|
||||||
const double multiplier = power_modulus * sin(power_angle) / vector_modulus;
|
const double multiplier = power_modulus * sin(power_angle) / vector_modulus;
|
||||||
|
|
||||||
power->s0 = power_modulus * cos(power_angle);
|
power->s = power_modulus * cos(power_angle);
|
||||||
power->x1 = base->x1 * multiplier;
|
power->x = base->x * multiplier;
|
||||||
power->x2 = base->x2 * multiplier;
|
power->y = base->y * multiplier;
|
||||||
power->x3 = base->x3 * multiplier;
|
power->z = base->z * multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,28 +12,28 @@
|
||||||
|
|
||||||
inline void bgc_fp32_rigid_pose3_reset(BGC_FP32_RigidPose3* const pose)
|
inline void bgc_fp32_rigid_pose3_reset(BGC_FP32_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
pose->_versor.real_part.s0 = 1.0f;
|
pose->_versor.real_part.s = 1.0f;
|
||||||
pose->_versor.real_part.x1 = 0.0f;
|
pose->_versor.real_part.x = 0.0f;
|
||||||
pose->_versor.real_part.x2 = 0.0f;
|
pose->_versor.real_part.y = 0.0f;
|
||||||
pose->_versor.real_part.x3 = 0.0f;
|
pose->_versor.real_part.z = 0.0f;
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = 0.0f;
|
pose->_versor.dual_part.s = 0.0f;
|
||||||
pose->_versor.dual_part.x1 = 0.0f;
|
pose->_versor.dual_part.x = 0.0f;
|
||||||
pose->_versor.dual_part.x2 = 0.0f;
|
pose->_versor.dual_part.y = 0.0f;
|
||||||
pose->_versor.dual_part.x3 = 0.0f;
|
pose->_versor.dual_part.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_reset(BGC_FP64_RigidPose3* const pose)
|
inline void bgc_fp64_rigid_pose3_reset(BGC_FP64_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
pose->_versor.real_part.s0 = 1.0;
|
pose->_versor.real_part.s = 1.0;
|
||||||
pose->_versor.real_part.x1 = 0.0;
|
pose->_versor.real_part.x = 0.0;
|
||||||
pose->_versor.real_part.x2 = 0.0;
|
pose->_versor.real_part.y = 0.0;
|
||||||
pose->_versor.real_part.x3 = 0.0;
|
pose->_versor.real_part.z = 0.0;
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = 0.0;
|
pose->_versor.dual_part.s = 0.0;
|
||||||
pose->_versor.dual_part.x1 = 0.0;
|
pose->_versor.dual_part.x = 0.0;
|
||||||
pose->_versor.dual_part.x2 = 0.0;
|
pose->_versor.dual_part.y = 0.0;
|
||||||
pose->_versor.dual_part.x3 = 0.0;
|
pose->_versor.dual_part.z = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Normalize ================== //
|
// ================= Normalize ================== //
|
||||||
|
|
@ -182,7 +182,7 @@ inline void bgc_fp64_rigid_pose3_convert_to_fp32(BGC_FP32_RigidPose3* const dest
|
||||||
|
|
||||||
inline void bgc_fp32_rigid_pose3_shorten(BGC_FP32_RigidPose3* const pose)
|
inline void bgc_fp32_rigid_pose3_shorten(BGC_FP32_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
if (pose->_versor.real_part.s0 < 0.0f) {
|
if (pose->_versor.real_part.s < 0.0f) {
|
||||||
bgc_fp32_quaternion_revert(&pose->_versor.real_part);
|
bgc_fp32_quaternion_revert(&pose->_versor.real_part);
|
||||||
bgc_fp32_quaternion_revert(&pose->_versor.dual_part);
|
bgc_fp32_quaternion_revert(&pose->_versor.dual_part);
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +190,7 @@ inline void bgc_fp32_rigid_pose3_shorten(BGC_FP32_RigidPose3* const pose)
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_shorten(BGC_FP64_RigidPose3* const pose)
|
inline void bgc_fp64_rigid_pose3_shorten(BGC_FP64_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
if (pose->_versor.real_part.s0 < 0.0) {
|
if (pose->_versor.real_part.s < 0.0) {
|
||||||
bgc_fp64_quaternion_revert(&pose->_versor.real_part);
|
bgc_fp64_quaternion_revert(&pose->_versor.real_part);
|
||||||
bgc_fp64_quaternion_revert(&pose->_versor.dual_part);
|
bgc_fp64_quaternion_revert(&pose->_versor.dual_part);
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +200,7 @@ inline void bgc_fp64_rigid_pose3_shorten(BGC_FP64_RigidPose3* const pose)
|
||||||
|
|
||||||
inline void bgc_fp32_rigid_pose3_get_shortened(BGC_FP32_RigidPose3* const shortened, const BGC_FP32_RigidPose3* const pose)
|
inline void bgc_fp32_rigid_pose3_get_shortened(BGC_FP32_RigidPose3* const shortened, const BGC_FP32_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
if (pose->_versor.real_part.s0 < 0.0f) {
|
if (pose->_versor.real_part.s < 0.0f) {
|
||||||
bgc_fp32_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
|
bgc_fp32_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
|
||||||
bgc_fp32_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
|
bgc_fp32_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@ inline void bgc_fp32_rigid_pose3_get_shortened(BGC_FP32_RigidPose3* const shorte
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_get_shortened(BGC_FP64_RigidPose3* const shortened, const BGC_FP64_RigidPose3* const pose)
|
inline void bgc_fp64_rigid_pose3_get_shortened(BGC_FP64_RigidPose3* const shortened, const BGC_FP64_RigidPose3* const pose)
|
||||||
{
|
{
|
||||||
if (pose->_versor.real_part.s0 < 0.0) {
|
if (pose->_versor.real_part.s < 0.0) {
|
||||||
bgc_fp64_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
|
bgc_fp64_quaternion_get_reverse(&shortened->_versor.real_part, &pose->_versor.real_part);
|
||||||
bgc_fp64_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
|
bgc_fp64_quaternion_get_reverse(&shortened->_versor.dual_part, &pose->_versor.dual_part);
|
||||||
}
|
}
|
||||||
|
|
@ -351,9 +351,9 @@ inline void bgc_fp32_rigid_pose3_get_shift(BGC_FP32_Vector3* const shift, const
|
||||||
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
|
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
|
||||||
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
|
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
|
||||||
|
|
||||||
shift->x1 = 2.0f * ((dual->x1 * real->s0 + dual->x3 * real->x2) - (dual->s0 * real->x1 + dual->x2 * real->x3));
|
shift->x = 2.0f * ((dual->x * real->s + dual->z * real->y) - (dual->s * real->x + dual->y * real->z));
|
||||||
shift->x2 = 2.0f * ((dual->x2 * real->s0 + dual->x1 * real->x3) - (dual->s0 * real->x2 + dual->x3 * real->x1));
|
shift->y = 2.0f * ((dual->y * real->s + dual->x * real->z) - (dual->s * real->y + dual->z * real->x));
|
||||||
shift->x3 = 2.0f * ((dual->x3 * real->s0 + dual->x2 * real->x1) - (dual->s0 * real->x3 + dual->x1 * real->x2));
|
shift->z = 2.0f * ((dual->z * real->s + dual->y * real->x) - (dual->s * real->z + dual->x * real->y));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_get_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
|
inline void bgc_fp64_rigid_pose3_get_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
|
||||||
|
|
@ -361,9 +361,9 @@ inline void bgc_fp64_rigid_pose3_get_shift(BGC_FP64_Vector3* const shift, const
|
||||||
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
|
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
|
||||||
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
|
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
|
||||||
|
|
||||||
shift->x1 = 2.0 * ((dual->x1 * real->s0 + dual->x3 * real->x2) - (dual->s0 * real->x1 + dual->x2 * real->x3));
|
shift->x = 2.0 * ((dual->x * real->s + dual->z * real->y) - (dual->s * real->x + dual->y * real->z));
|
||||||
shift->x2 = 2.0 * ((dual->x2 * real->s0 + dual->x1 * real->x3) - (dual->s0 * real->x2 + dual->x3 * real->x1));
|
shift->y = 2.0 * ((dual->y * real->s + dual->x * real->z) - (dual->s * real->y + dual->z * real->x));
|
||||||
shift->x3 = 2.0 * ((dual->x3 * real->s0 + dual->x2 * real->x1) - (dual->s0 * real->x3 + dual->x1 * real->x2));
|
shift->z = 2.0 * ((dual->z * real->s + dual->y * real->x) - (dual->s * real->z + dual->x * real->y));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Get Reverse Shift ============= //
|
// ============= Get Reverse Shift ============= //
|
||||||
|
|
@ -373,9 +373,9 @@ inline void bgc_fp32_rigid_pose3_get_reverse_shift(BGC_FP32_Vector3* const shift
|
||||||
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
|
const BGC_FP32_Quaternion* const real = &pose->_versor.real_part;
|
||||||
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
|
const BGC_FP32_Quaternion* const dual = &pose->_versor.dual_part;
|
||||||
|
|
||||||
shift->x1 = 2.0f * ((dual->s0 * real->x1 - dual->x1 * real->s0) + (dual->x3 * real->x2 - dual->x2 * real->x3));
|
shift->x = 2.0f * ((dual->s * real->x - dual->x * real->s) + (dual->z * real->y - dual->y * real->z));
|
||||||
shift->x2 = 2.0f * ((dual->s0 * real->x2 - dual->x2 * real->s0) + (dual->x1 * real->x3 - dual->x3 * real->x1));
|
shift->y = 2.0f * ((dual->s * real->y - dual->y * real->s) + (dual->x * real->z - dual->z * real->x));
|
||||||
shift->x3 = 2.0f * ((dual->s0 * real->x3 - dual->x3 * real->s0) + (dual->x2 * real->x1 - dual->x1 * real->x2));
|
shift->z = 2.0f * ((dual->s * real->z - dual->z * real->s) + (dual->y * real->x - dual->x * real->y));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_get_reverse_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
|
inline void bgc_fp64_rigid_pose3_get_reverse_shift(BGC_FP64_Vector3* const shift, const BGC_FP64_RigidPose3* const pose)
|
||||||
|
|
@ -383,9 +383,9 @@ inline void bgc_fp64_rigid_pose3_get_reverse_shift(BGC_FP64_Vector3* const shift
|
||||||
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
|
const BGC_FP64_Quaternion* const real = &pose->_versor.real_part;
|
||||||
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
|
const BGC_FP64_Quaternion* const dual = &pose->_versor.dual_part;
|
||||||
|
|
||||||
shift->x1 = 2.0 * ((dual->s0 * real->x1 - dual->x1 * real->s0) + (dual->x3 * real->x2 - dual->x2 * real->x3));
|
shift->x = 2.0 * ((dual->s * real->x - dual->x * real->s) + (dual->z * real->y - dual->y * real->z));
|
||||||
shift->x2 = 2.0 * ((dual->s0 * real->x2 - dual->x2 * real->s0) + (dual->x1 * real->x3 - dual->x3 * real->x1));
|
shift->y = 2.0 * ((dual->s * real->y - dual->y * real->s) + (dual->x * real->z - dual->z * real->x));
|
||||||
shift->x3 = 2.0 * ((dual->s0 * real->x3 - dual->x3 * real->s0) + (dual->x2 * real->x1 - dual->x1 * real->x2));
|
shift->z = 2.0 * ((dual->s * real->z - dual->z * real->s) + (dual->y * real->x - dual->x * real->y));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Get Affine3 ================= //
|
// ================ Get Affine3 ================= //
|
||||||
|
|
@ -439,10 +439,10 @@ inline void bgc_fp32_rigid_pose3_set_position(BGC_FP32_RigidPose3* const pose, c
|
||||||
|
|
||||||
bgc_fp32_quaternion_copy(&pose->_versor.real_part, versor);
|
bgc_fp32_quaternion_copy(&pose->_versor.real_part, versor);
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = -0.5f * (shift->x1 * versor->x1 + shift->x2 * versor->x2 + shift->x3 * versor->x3);
|
pose->_versor.dual_part.s = -0.5f * (shift->x * versor->x + shift->y * versor->y + shift->z * versor->z);
|
||||||
pose->_versor.dual_part.x1 = -0.5f * (shift->x3 * versor->x2 - shift->x2 * versor->x3 - shift->x1 * versor->s0);
|
pose->_versor.dual_part.x = -0.5f * (shift->z * versor->y - shift->y * versor->z - shift->x * versor->s);
|
||||||
pose->_versor.dual_part.x2 = -0.5f * (shift->x1 * versor->x3 - shift->x3 * versor->x1 - shift->x2 * versor->s0);
|
pose->_versor.dual_part.y = -0.5f * (shift->x * versor->z - shift->z * versor->x - shift->y * versor->s);
|
||||||
pose->_versor.dual_part.x3 = -0.5f * (shift->x2 * versor->x1 - shift->x1 * versor->x2 - shift->x3 * versor->s0);
|
pose->_versor.dual_part.z = -0.5f * (shift->y * versor->x - shift->x * versor->y - shift->z * versor->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_set_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
|
inline void bgc_fp64_rigid_pose3_set_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
|
||||||
|
|
@ -452,10 +452,10 @@ inline void bgc_fp64_rigid_pose3_set_position(BGC_FP64_RigidPose3* const pose, c
|
||||||
|
|
||||||
bgc_fp64_quaternion_copy(&pose->_versor.real_part, versor);
|
bgc_fp64_quaternion_copy(&pose->_versor.real_part, versor);
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = -0.5 * (shift->x1 * versor->x1 + shift->x2 * versor->x2 + shift->x3 * versor->x3);
|
pose->_versor.dual_part.s = -0.5 * (shift->x * versor->x + shift->y * versor->y + shift->z * versor->z);
|
||||||
pose->_versor.dual_part.x1 = -0.5 * (shift->x3 * versor->x2 - shift->x2 * versor->x3 - shift->x1 * versor->s0);
|
pose->_versor.dual_part.x = -0.5 * (shift->z * versor->y - shift->y * versor->z - shift->x * versor->s);
|
||||||
pose->_versor.dual_part.x2 = -0.5 * (shift->x1 * versor->x3 - shift->x3 * versor->x1 - shift->x2 * versor->s0);
|
pose->_versor.dual_part.y = -0.5 * (shift->x * versor->z - shift->z * versor->x - shift->y * versor->s);
|
||||||
pose->_versor.dual_part.x3 = -0.5 * (shift->x2 * versor->x1 - shift->x1 * versor->x2 - shift->x3 * versor->s0);
|
pose->_versor.dual_part.z = -0.5 * (shift->y * versor->x - shift->x * versor->y - shift->z * versor->s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========== Get Reverse Position3 ============ //
|
// =========== Get Reverse Position3 ============ //
|
||||||
|
|
@ -481,10 +481,10 @@ inline void bgc_fp32_rigid_pose3_set_reverse_position(BGC_FP32_RigidPose3* const
|
||||||
|
|
||||||
bgc_fp32_quaternion_get_conjugate(&pose->_versor.real_part, versor);
|
bgc_fp32_quaternion_get_conjugate(&pose->_versor.real_part, versor);
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = -0.5f * (versor->x1 * shift->x1 + versor->x2 * shift->x2 + versor->x3 * shift->x3);
|
pose->_versor.dual_part.s = -0.5f * (versor->x * shift->x + versor->y * shift->y + versor->z * shift->z);
|
||||||
pose->_versor.dual_part.x1 = -0.5f * (versor->s0 * shift->x1 + versor->x3 * shift->x2 - versor->x2 * shift->x3);
|
pose->_versor.dual_part.x = -0.5f * (versor->s * shift->x + versor->z * shift->y - versor->y * shift->z);
|
||||||
pose->_versor.dual_part.x2 = -0.5f * (versor->s0 * shift->x2 + versor->x1 * shift->x3 - versor->x3 * shift->x1);
|
pose->_versor.dual_part.y = -0.5f * (versor->s * shift->y + versor->x * shift->z - versor->z * shift->x);
|
||||||
pose->_versor.dual_part.x3 = -0.5f * (versor->s0 * shift->x3 + versor->x2 * shift->x1 - versor->x1 * shift->x2);
|
pose->_versor.dual_part.z = -0.5f * (versor->s * shift->z + versor->y * shift->x - versor->x * shift->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_rigid_pose3_set_reverse_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
|
inline void bgc_fp64_rigid_pose3_set_reverse_position(BGC_FP64_RigidPose3* const pose, const BGC_FP64_Position3* const position)
|
||||||
|
|
@ -494,10 +494,10 @@ inline void bgc_fp64_rigid_pose3_set_reverse_position(BGC_FP64_RigidPose3* const
|
||||||
|
|
||||||
bgc_fp64_quaternion_get_conjugate(&pose->_versor.real_part, versor);
|
bgc_fp64_quaternion_get_conjugate(&pose->_versor.real_part, versor);
|
||||||
|
|
||||||
pose->_versor.dual_part.s0 = -0.5f * (versor->x1 * shift->x1 + versor->x2 * shift->x2 + versor->x3 * shift->x3);
|
pose->_versor.dual_part.s = -0.5f * (versor->x * shift->x + versor->y * shift->y + versor->z * shift->z);
|
||||||
pose->_versor.dual_part.x1 = -0.5f * (versor->s0 * shift->x1 + versor->x3 * shift->x2 - versor->x2 * shift->x3);
|
pose->_versor.dual_part.x = -0.5f * (versor->s * shift->x + versor->z * shift->y - versor->y * shift->z);
|
||||||
pose->_versor.dual_part.x2 = -0.5f * (versor->s0 * shift->x2 + versor->x1 * shift->x3 - versor->x3 * shift->x1);
|
pose->_versor.dual_part.y = -0.5f * (versor->s * shift->y + versor->x * shift->z - versor->z * shift->x);
|
||||||
pose->_versor.dual_part.x3 = -0.5f * (versor->s0 * shift->x3 + versor->x2 * shift->x1 - versor->x1 * shift->x2);
|
pose->_versor.dual_part.z = -0.5f * (versor->s * shift->z + versor->y * shift->x - versor->x * shift->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Transform Vector ============== //
|
// ============== Transform Vector ============== //
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ extern inline void bgc_fp64_slerp3_get_phase_both_matrices(BGC_FP64_Matrix3x3* c
|
||||||
|
|
||||||
void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const augment)
|
void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const augment)
|
||||||
{
|
{
|
||||||
const float square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
|
const float square_vector = augment->_versor.x * augment->_versor.x + augment->_versor.y * augment->_versor.y + augment->_versor.z * augment->_versor.z;
|
||||||
|
|
||||||
if (isnan(square_vector)) {
|
if (isnan(square_vector)) {
|
||||||
bgc_fp32_slerp3_reset(slerp);
|
bgc_fp32_slerp3_reset(slerp);
|
||||||
|
|
@ -31,15 +31,15 @@ void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
slerp->_cosine_weight.s0 = start->_versor.s0;
|
slerp->_cosine_weight.s = start->_versor.s;
|
||||||
slerp->_cosine_weight.x1 = start->_versor.x1;
|
slerp->_cosine_weight.x = start->_versor.x;
|
||||||
slerp->_cosine_weight.x2 = start->_versor.x2;
|
slerp->_cosine_weight.y = start->_versor.y;
|
||||||
slerp->_cosine_weight.x3 = start->_versor.x3;
|
slerp->_cosine_weight.z = start->_versor.z;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = 0.0f;
|
slerp->_sine_weight.s = 0.0f;
|
||||||
slerp->_sine_weight.x1 = 0.0f;
|
slerp->_sine_weight.x = 0.0f;
|
||||||
slerp->_sine_weight.x2 = 0.0f;
|
slerp->_sine_weight.y = 0.0f;
|
||||||
slerp->_sine_weight.x3 = 0.0f;
|
slerp->_sine_weight.z = 0.0f;
|
||||||
|
|
||||||
slerp->radians = 0.0f;
|
slerp->radians = 0.0f;
|
||||||
return;
|
return;
|
||||||
|
|
@ -47,24 +47,24 @@ void bgc_fp32_slerp3_make(BGC_FP32_Slerp3* const slerp, const BGC_FP32_Turn3* co
|
||||||
|
|
||||||
const float vector_modulus = sqrtf(square_vector);
|
const float vector_modulus = sqrtf(square_vector);
|
||||||
|
|
||||||
slerp->radians = atan2f(vector_modulus, augment->_versor.s0);
|
slerp->radians = atan2f(vector_modulus, augment->_versor.s);
|
||||||
|
|
||||||
const float multiplier = 1.0f / vector_modulus;
|
const float multiplier = 1.0f / vector_modulus;
|
||||||
|
|
||||||
slerp->_cosine_weight.s0 = start->_versor.s0;
|
slerp->_cosine_weight.s = start->_versor.s;
|
||||||
slerp->_cosine_weight.x1 = start->_versor.x1;
|
slerp->_cosine_weight.x = start->_versor.x;
|
||||||
slerp->_cosine_weight.x2 = start->_versor.x2;
|
slerp->_cosine_weight.y = start->_versor.y;
|
||||||
slerp->_cosine_weight.x3 = start->_versor.x3;
|
slerp->_cosine_weight.z = start->_versor.z;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
slerp->_sine_weight.s = -multiplier * (augment->_versor.x * start->_versor.x + augment->_versor.y * start->_versor.y + augment->_versor.z * start->_versor.z);
|
||||||
slerp->_sine_weight.x1 = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
slerp->_sine_weight.x = multiplier * (augment->_versor.x * start->_versor.s + augment->_versor.y * start->_versor.z - augment->_versor.z * start->_versor.y);
|
||||||
slerp->_sine_weight.x2 = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
slerp->_sine_weight.y = multiplier * (augment->_versor.y * start->_versor.s - augment->_versor.x * start->_versor.z + augment->_versor.z * start->_versor.x);
|
||||||
slerp->_sine_weight.x3 = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
slerp->_sine_weight.z = multiplier * (augment->_versor.z * start->_versor.s - augment->_versor.y * start->_versor.x + augment->_versor.x * start->_versor.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const augment)
|
void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const augment)
|
||||||
{
|
{
|
||||||
const double square_vector = augment->_versor.x1 * augment->_versor.x1 + augment->_versor.x2 * augment->_versor.x2 + augment->_versor.x3 * augment->_versor.x3;
|
const double square_vector = augment->_versor.x * augment->_versor.x + augment->_versor.y * augment->_versor.y + augment->_versor.z * augment->_versor.z;
|
||||||
|
|
||||||
if (isnan(square_vector)) {
|
if (isnan(square_vector)) {
|
||||||
bgc_fp64_slerp3_reset(slerp);
|
bgc_fp64_slerp3_reset(slerp);
|
||||||
|
|
@ -72,15 +72,15 @@ void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* co
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
slerp->_cosine_weight.s0 = start->_versor.s0;
|
slerp->_cosine_weight.s = start->_versor.s;
|
||||||
slerp->_cosine_weight.x1 = start->_versor.x1;
|
slerp->_cosine_weight.x = start->_versor.x;
|
||||||
slerp->_cosine_weight.x2 = start->_versor.x2;
|
slerp->_cosine_weight.y = start->_versor.y;
|
||||||
slerp->_cosine_weight.x3 = start->_versor.x3;
|
slerp->_cosine_weight.z = start->_versor.z;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = 0.0;
|
slerp->_sine_weight.s = 0.0;
|
||||||
slerp->_sine_weight.x1 = 0.0;
|
slerp->_sine_weight.x = 0.0;
|
||||||
slerp->_sine_weight.x2 = 0.0;
|
slerp->_sine_weight.y = 0.0;
|
||||||
slerp->_sine_weight.x3 = 0.0;
|
slerp->_sine_weight.z = 0.0;
|
||||||
|
|
||||||
slerp->radians = 0.0;
|
slerp->radians = 0.0;
|
||||||
return;
|
return;
|
||||||
|
|
@ -88,17 +88,17 @@ void bgc_fp64_slerp3_make(BGC_FP64_Slerp3* const slerp, const BGC_FP64_Turn3* co
|
||||||
|
|
||||||
const double vector_modulus = sqrt(square_vector);
|
const double vector_modulus = sqrt(square_vector);
|
||||||
|
|
||||||
slerp->radians = atan2(vector_modulus, augment->_versor.s0);
|
slerp->radians = atan2(vector_modulus, augment->_versor.s);
|
||||||
|
|
||||||
const double multiplier = 1.0 / vector_modulus;
|
const double multiplier = 1.0 / vector_modulus;
|
||||||
|
|
||||||
slerp->_cosine_weight.s0 = start->_versor.s0;
|
slerp->_cosine_weight.s = start->_versor.s;
|
||||||
slerp->_cosine_weight.x1 = start->_versor.x1;
|
slerp->_cosine_weight.x = start->_versor.x;
|
||||||
slerp->_cosine_weight.x2 = start->_versor.x2;
|
slerp->_cosine_weight.y = start->_versor.y;
|
||||||
slerp->_cosine_weight.x3 = start->_versor.x3;
|
slerp->_cosine_weight.z = start->_versor.z;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = -multiplier * (augment->_versor.x1 * start->_versor.x1 + augment->_versor.x2 * start->_versor.x2 + augment->_versor.x3 * start->_versor.x3);
|
slerp->_sine_weight.s = -multiplier * (augment->_versor.x * start->_versor.x + augment->_versor.y * start->_versor.y + augment->_versor.z * start->_versor.z);
|
||||||
slerp->_sine_weight.x1 = multiplier * (augment->_versor.x1 * start->_versor.s0 + augment->_versor.x2 * start->_versor.x3 - augment->_versor.x3 * start->_versor.x2);
|
slerp->_sine_weight.x = multiplier * (augment->_versor.x * start->_versor.s + augment->_versor.y * start->_versor.z - augment->_versor.z * start->_versor.y);
|
||||||
slerp->_sine_weight.x2 = multiplier * (augment->_versor.x2 * start->_versor.s0 - augment->_versor.x1 * start->_versor.x3 + augment->_versor.x3 * start->_versor.x1);
|
slerp->_sine_weight.y = multiplier * (augment->_versor.y * start->_versor.s - augment->_versor.x * start->_versor.z + augment->_versor.z * start->_versor.x);
|
||||||
slerp->_sine_weight.x3 = multiplier * (augment->_versor.x3 * start->_versor.s0 - augment->_versor.x2 * start->_versor.x1 + augment->_versor.x1 * start->_versor.x2);
|
slerp->_sine_weight.z = multiplier * (augment->_versor.z * start->_versor.s - augment->_versor.y * start->_versor.x + augment->_versor.x * start->_versor.y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,30 +9,30 @@
|
||||||
|
|
||||||
inline void bgc_fp32_slerp3_reset(BGC_FP32_Slerp3* const slerp)
|
inline void bgc_fp32_slerp3_reset(BGC_FP32_Slerp3* const slerp)
|
||||||
{
|
{
|
||||||
slerp->_cosine_weight.s0 = 1.0f;
|
slerp->_cosine_weight.s = 1.0f;
|
||||||
slerp->_cosine_weight.x1 = 0.0f;
|
slerp->_cosine_weight.x = 0.0f;
|
||||||
slerp->_cosine_weight.x2 = 0.0f;
|
slerp->_cosine_weight.y = 0.0f;
|
||||||
slerp->_cosine_weight.x3 = 0.0f;
|
slerp->_cosine_weight.z = 0.0f;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = 0.0f;
|
slerp->_sine_weight.s = 0.0f;
|
||||||
slerp->_sine_weight.x1 = 0.0f;
|
slerp->_sine_weight.x = 0.0f;
|
||||||
slerp->_sine_weight.x2 = 0.0f;
|
slerp->_sine_weight.y = 0.0f;
|
||||||
slerp->_sine_weight.x3 = 0.0f;
|
slerp->_sine_weight.z = 0.0f;
|
||||||
|
|
||||||
slerp->radians = 0.0f;
|
slerp->radians = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_slerp3_reset(BGC_FP64_Slerp3* const slerp)
|
inline void bgc_fp64_slerp3_reset(BGC_FP64_Slerp3* const slerp)
|
||||||
{
|
{
|
||||||
slerp->_cosine_weight.s0 = 1.0;
|
slerp->_cosine_weight.s = 1.0;
|
||||||
slerp->_cosine_weight.x1 = 0.0;
|
slerp->_cosine_weight.x = 0.0;
|
||||||
slerp->_cosine_weight.x2 = 0.0;
|
slerp->_cosine_weight.y = 0.0;
|
||||||
slerp->_cosine_weight.x3 = 0.0;
|
slerp->_cosine_weight.z = 0.0;
|
||||||
|
|
||||||
slerp->_sine_weight.s0 = 0.0;
|
slerp->_sine_weight.s = 0.0;
|
||||||
slerp->_sine_weight.x1 = 0.0;
|
slerp->_sine_weight.x = 0.0;
|
||||||
slerp->_sine_weight.x2 = 0.0;
|
slerp->_sine_weight.y = 0.0;
|
||||||
slerp->_sine_weight.x3 = 0.0;
|
slerp->_sine_weight.z = 0.0;
|
||||||
|
|
||||||
slerp->radians = 0.0;
|
slerp->radians = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ extern inline void bgc_fp64_turn2_reset(BGC_FP64_Turn2* const turn);
|
||||||
extern void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* const turn);
|
extern void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* const turn);
|
||||||
extern void _bgc_fp64_turn2_normalize(BGC_FP64_Turn2* const turn);
|
extern void _bgc_fp64_turn2_normalize(BGC_FP64_Turn2* const turn);
|
||||||
|
|
||||||
extern inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x1, const float x2);
|
extern inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x, const float y);
|
||||||
extern inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x1, const double x2);
|
extern inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x, const double y);
|
||||||
|
|
||||||
extern inline void bgc_fp32_turn2_set_angle(BGC_FP32_Turn2* const turn, const float angle, const int angle_unit);
|
extern inline void bgc_fp32_turn2_set_angle(BGC_FP32_Turn2* const turn, const float angle, const int angle_unit);
|
||||||
extern inline void bgc_fp64_turn2_set_angle(BGC_FP64_Turn2* const turn, const double angle, const int angle_unit);
|
extern inline void bgc_fp64_turn2_set_angle(BGC_FP64_Turn2* const turn, const double angle, const int angle_unit);
|
||||||
|
|
|
||||||
|
|
@ -101,18 +101,18 @@ inline int bgc_fp64_turn2_is_idle(const BGC_FP64_Turn2* const turn)
|
||||||
|
|
||||||
// ==================== Set ===================== //
|
// ==================== Set ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x1, const float x2)
|
inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x, const float y)
|
||||||
{
|
{
|
||||||
turn->_cos = x1;
|
turn->_cos = x;
|
||||||
turn->_sin = x2;
|
turn->_sin = y;
|
||||||
|
|
||||||
_bgc_fp32_turn2_normalize(turn);
|
_bgc_fp32_turn2_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x1, const double x2)
|
inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x, const double y)
|
||||||
{
|
{
|
||||||
turn->_cos = x1;
|
turn->_cos = x;
|
||||||
turn->_sin = x2;
|
turn->_sin = y;
|
||||||
|
|
||||||
_bgc_fp64_turn2_normalize(turn);
|
_bgc_fp64_turn2_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
@ -347,40 +347,40 @@ inline void bgc_fp64_turn2_get_reverse_matrix(BGC_FP64_Matrix2x2* const matrix,
|
||||||
|
|
||||||
inline void bgc_fp32_turn2_vector(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_turn2_vector(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const float x1 = turn->_cos * vector->x1 - turn->_sin * vector->x2;
|
const float x = turn->_cos * vector->x - turn->_sin * vector->y;
|
||||||
const float x2 = turn->_sin * vector->x1 + turn->_cos * vector->x2;
|
const float y = turn->_sin * vector->x + turn->_cos * vector->y;
|
||||||
|
|
||||||
turned_vector->x1 = x1;
|
turned_vector->x = x;
|
||||||
turned_vector->x2 = x2;
|
turned_vector->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn2_vector(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_turn2_vector(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const double x1 = turn->_cos * vector->x1 - turn->_sin * vector->x2;
|
const double x = turn->_cos * vector->x - turn->_sin * vector->y;
|
||||||
const double x2 = turn->_sin * vector->x1 + turn->_cos * vector->x2;
|
const double y = turn->_sin * vector->x + turn->_cos * vector->y;
|
||||||
|
|
||||||
turned_vector->x1 = x1;
|
turned_vector->x = x;
|
||||||
turned_vector->x2 = x2;
|
turned_vector->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Turn Vector Backward ============ //
|
// ============ Turn Vector Backward ============ //
|
||||||
|
|
||||||
inline void bgc_fp32_turn2_vector_back(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_turn2_vector_back(BGC_FP32_Vector2* const turned_vector, const BGC_FP32_Turn2* const turn, const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const float x1 = turn->_sin * vector->x2 + turn->_cos * vector->x1;
|
const float x = turn->_sin * vector->y + turn->_cos * vector->x;
|
||||||
const float x2 = turn->_cos * vector->x2 - turn->_sin * vector->x1;
|
const float y = turn->_cos * vector->y - turn->_sin * vector->x;
|
||||||
|
|
||||||
turned_vector->x1 = x1;
|
turned_vector->x = x;
|
||||||
turned_vector->x2 = x2;
|
turned_vector->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn2_vector_back(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_turn2_vector_back(BGC_FP64_Vector2* const turned_vector, const BGC_FP64_Turn2* const turn, const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
const double x1 = turn->_sin * vector->x2 + turn->_cos * vector->x1;
|
const double x = turn->_sin * vector->y + turn->_cos * vector->x;
|
||||||
const double x2 = turn->_cos * vector->x2 - turn->_sin * vector->x1;
|
const double y = turn->_cos * vector->y - turn->_sin * vector->x;
|
||||||
|
|
||||||
turned_vector->x1 = x1;
|
turned_vector->x = x;
|
||||||
turned_vector->x2 = x2;
|
turned_vector->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Are Close ================= //
|
// ================== Are Close ================= //
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ extern inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn);
|
||||||
extern inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn);
|
extern inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn);
|
||||||
extern inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn);
|
extern inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn);
|
||||||
|
|
||||||
extern inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s0, const float x1, const float x2, const float x3);
|
extern inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s, const float x, const float y, const float z);
|
||||||
extern inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s0, const double x1, const double x2, const double x3);
|
extern inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s, const double x, const double y, const double z);
|
||||||
|
|
||||||
extern inline void bgc_fp32_turn3_get_quaternion(BGC_FP32_Quaternion* const quaternion, const BGC_FP32_Turn3* const turn);
|
extern inline void bgc_fp32_turn3_get_quaternion(BGC_FP32_Quaternion* const quaternion, const BGC_FP32_Turn3* const turn);
|
||||||
extern inline void bgc_fp64_turn3_get_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Turn3* const turn);
|
extern inline void bgc_fp64_turn3_get_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Turn3* const turn);
|
||||||
|
|
@ -82,7 +82,7 @@ extern inline int bgc_fp64_turn3_are_close(const BGC_FP64_Turn3* const turn1, co
|
||||||
|
|
||||||
float bgc_fp32_turn3_get_rotation(BGC_FP32_Vector3* const axis, const BGC_FP32_Turn3* const turn, const int angle_unit)
|
float bgc_fp32_turn3_get_rotation(BGC_FP32_Vector3* const axis, const BGC_FP32_Turn3* const turn, const int angle_unit)
|
||||||
{
|
{
|
||||||
const float square_vector_modulus = turn->_versor.x1 * turn->_versor.x1 + turn->_versor.x2 * turn->_versor.x2 + turn->_versor.x3 * turn->_versor.x3;
|
const float square_vector_modulus = turn->_versor.x * turn->_versor.x + turn->_versor.y * turn->_versor.y + turn->_versor.z * turn->_versor.z;
|
||||||
|
|
||||||
if (square_vector_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
if (square_vector_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
bgc_fp32_vector3_reset(axis);
|
bgc_fp32_vector3_reset(axis);
|
||||||
|
|
@ -93,16 +93,16 @@ float bgc_fp32_turn3_get_rotation(BGC_FP32_Vector3* const axis, const BGC_FP32_T
|
||||||
|
|
||||||
const float multiplier = 1.0f / vector_modulus;
|
const float multiplier = 1.0f / vector_modulus;
|
||||||
|
|
||||||
axis->x1 = turn->_versor.x1 * multiplier;
|
axis->x = turn->_versor.x * multiplier;
|
||||||
axis->x2 = turn->_versor.x2 * multiplier;
|
axis->y = turn->_versor.y * multiplier;
|
||||||
axis->x3 = turn->_versor.x3 * multiplier;
|
axis->z = turn->_versor.z * multiplier;
|
||||||
|
|
||||||
return 2.0f * atan2f(vector_modulus, turn->_versor.s0);
|
return 2.0f * atan2f(vector_modulus, turn->_versor.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_Turn3* const turn, const int angle_unit)
|
double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_Turn3* const turn, const int angle_unit)
|
||||||
{
|
{
|
||||||
const double square_vector_modulus = turn->_versor.x1 * turn->_versor.x1 + turn->_versor.x2 * turn->_versor.x2 + turn->_versor.x3 * turn->_versor.x3;
|
const double square_vector_modulus = turn->_versor.x * turn->_versor.x + turn->_versor.y * turn->_versor.y + turn->_versor.z * turn->_versor.z;
|
||||||
|
|
||||||
if (square_vector_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
if (square_vector_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
bgc_fp64_vector3_reset(axis);
|
bgc_fp64_vector3_reset(axis);
|
||||||
|
|
@ -113,18 +113,18 @@ double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_
|
||||||
|
|
||||||
const double multiplier = 1.0 / vector_modulus;
|
const double multiplier = 1.0 / vector_modulus;
|
||||||
|
|
||||||
axis->x1 = turn->_versor.x1 * multiplier;
|
axis->x = turn->_versor.x * multiplier;
|
||||||
axis->x2 = turn->_versor.x2 * multiplier;
|
axis->y = turn->_versor.y * multiplier;
|
||||||
axis->x3 = turn->_versor.x3 * multiplier;
|
axis->z = turn->_versor.z * multiplier;
|
||||||
|
|
||||||
return 2.0 * atan2(vector_modulus, turn->_versor.s0);
|
return 2.0 * atan2(vector_modulus, turn->_versor.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Set Rotation ================ //
|
// ================ Set Rotation ================ //
|
||||||
|
|
||||||
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, const float x2, const float x3, const float angle, const int angle_unit)
|
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x, const float y, const float z, const float angle, const int angle_unit)
|
||||||
{
|
{
|
||||||
const float square_vector = x1 * x1 + x2 * x2 + x3 * x3;
|
const float square_vector = x * x + y * y + z * z;
|
||||||
|
|
||||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
bgc_fp32_turn3_reset(turn);
|
bgc_fp32_turn3_reset(turn);
|
||||||
|
|
@ -142,14 +142,14 @@ void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, con
|
||||||
|
|
||||||
const float multiplier = sine / sqrtf(square_vector);
|
const float multiplier = sine / sqrtf(square_vector);
|
||||||
|
|
||||||
bgc_fp32_quaternion_set_values(&turn->_versor, cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier);
|
bgc_fp32_quaternion_set_values(&turn->_versor, cosf(half_angle), x * multiplier, y * multiplier, z * multiplier);
|
||||||
|
|
||||||
_bgc_fp32_turn3_normalize(turn);
|
_bgc_fp32_turn3_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, const double x2, const double x3, const double angle, const int angle_unit)
|
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x, const double y, const double z, const double angle, const int angle_unit)
|
||||||
{
|
{
|
||||||
const double square_vector = x1 * x1 + x2 * x2 + x3 * x3;
|
const double square_vector = x * x + y * y + z * z;
|
||||||
|
|
||||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
if (square_vector <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
bgc_fp64_turn3_reset(turn);
|
bgc_fp64_turn3_reset(turn);
|
||||||
|
|
@ -167,7 +167,7 @@ void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, co
|
||||||
|
|
||||||
const double multiplier = sine / sqrt(square_vector);
|
const double multiplier = sine / sqrt(square_vector);
|
||||||
|
|
||||||
bgc_fp64_quaternion_set_values(&turn->_versor, cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier);
|
bgc_fp64_quaternion_set_values(&turn->_versor, cos(half_angle), x * multiplier, y * multiplier, z * multiplier);
|
||||||
|
|
||||||
_bgc_fp64_turn3_normalize(turn);
|
_bgc_fp64_turn3_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ int bgc_fp32_turn3_find_direction_difference(BGC_FP32_Turn3* const turn, const B
|
||||||
|
|
||||||
const float vector_multiplier = sinf(angle) / axis_modulus;
|
const float vector_multiplier = sinf(angle) / axis_modulus;
|
||||||
|
|
||||||
bgc_fp32_turn3_set_values(turn, cosf(angle), axis.x1 * vector_multiplier, axis.x2 * vector_multiplier, axis.x3 * vector_multiplier);
|
bgc_fp32_turn3_set_values(turn, cosf(angle), axis.x * vector_multiplier, axis.y * vector_multiplier, axis.z * vector_multiplier);
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +251,7 @@ int bgc_fp64_turn3_find_direction_difference(BGC_FP64_Turn3* const turn, const B
|
||||||
|
|
||||||
const double vector_multiplier = sin(angle) / axis_modulus;
|
const double vector_multiplier = sin(angle) / axis_modulus;
|
||||||
|
|
||||||
bgc_fp64_turn3_set_values(turn, cos(angle), axis.x1 * vector_multiplier, axis.x2 * vector_multiplier, axis.x3 * vector_multiplier);
|
bgc_fp64_turn3_set_values(turn, cos(angle), axis.x * vector_multiplier, axis.y * vector_multiplier, axis.z * vector_multiplier);
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -332,18 +332,18 @@ static inline void _bgc_fp32_turn3_get_turning_quaternion(BGC_FP32_Quaternion* c
|
||||||
if (axis_square_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
if (axis_square_modulus <= BGC_FP32_SQUARE_EPSILON) {
|
||||||
// unit_start and unit_end are co-directional, angle = 180 degrees
|
// unit_start and unit_end are co-directional, angle = 180 degrees
|
||||||
if (dot_product >= 0.0f) {
|
if (dot_product >= 0.0f) {
|
||||||
quaternion->s0 = 1.0f;
|
quaternion->s = 1.0f;
|
||||||
quaternion->x1 = 0.0f;
|
quaternion->x = 0.0f;
|
||||||
quaternion->x2 = 0.0f;
|
quaternion->y = 0.0f;
|
||||||
quaternion->x3 = 0.0f;
|
quaternion->z = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unit_start and unit_end are opposite, angle = 180 degrees
|
// unit_start and unit_end are opposite, angle = 180 degrees
|
||||||
quaternion->s0 = 0.0f;
|
quaternion->s = 0.0f;
|
||||||
quaternion->x1 = unit_orthogonal->x1;
|
quaternion->x = unit_orthogonal->x;
|
||||||
quaternion->x2 = unit_orthogonal->x2;
|
quaternion->y = unit_orthogonal->y;
|
||||||
quaternion->x3 = unit_orthogonal->x3;
|
quaternion->z = unit_orthogonal->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -353,10 +353,10 @@ static inline void _bgc_fp32_turn3_get_turning_quaternion(BGC_FP32_Quaternion* c
|
||||||
|
|
||||||
const float multiplier = sinf(angle) / axis_modulus;
|
const float multiplier = sinf(angle) / axis_modulus;
|
||||||
|
|
||||||
quaternion->s0 = cosf(angle);
|
quaternion->s = cosf(angle);
|
||||||
quaternion->x1 = axis.x1 * multiplier;
|
quaternion->x = axis.x * multiplier;
|
||||||
quaternion->x2 = axis.x2 * multiplier;
|
quaternion->y = axis.y * multiplier;
|
||||||
quaternion->x3 = axis.x3 * multiplier;
|
quaternion->z = axis.z * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Vector3* const unit_start, const BGC_FP64_Vector3* const unit_end, const BGC_FP64_Vector3* const unit_orthogonal)
|
static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* const quaternion, const BGC_FP64_Vector3* const unit_start, const BGC_FP64_Vector3* const unit_end, const BGC_FP64_Vector3* const unit_orthogonal)
|
||||||
|
|
@ -373,18 +373,18 @@ static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* c
|
||||||
if (axis_square_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
if (axis_square_modulus <= BGC_FP64_SQUARE_EPSILON) {
|
||||||
// unit_start and unit_end are co-directional, angle = 180 degrees
|
// unit_start and unit_end are co-directional, angle = 180 degrees
|
||||||
if (dot_product >= 0.0) {
|
if (dot_product >= 0.0) {
|
||||||
quaternion->s0 = 1.0;
|
quaternion->s = 1.0;
|
||||||
quaternion->x1 = 0.0;
|
quaternion->x = 0.0;
|
||||||
quaternion->x2 = 0.0;
|
quaternion->y = 0.0;
|
||||||
quaternion->x3 = 0.0;
|
quaternion->z = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unit_start and unit_end are opposite, angle = 180 degrees
|
// unit_start and unit_end are opposite, angle = 180 degrees
|
||||||
quaternion->s0 = 0.0;
|
quaternion->s = 0.0;
|
||||||
quaternion->x1 = unit_orthogonal->x1;
|
quaternion->x = unit_orthogonal->x;
|
||||||
quaternion->x2 = unit_orthogonal->x2;
|
quaternion->y = unit_orthogonal->y;
|
||||||
quaternion->x3 = unit_orthogonal->x3;
|
quaternion->z = unit_orthogonal->z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -394,10 +394,10 @@ static inline void _bgc_fp64_turn3_get_turning_quaternion(BGC_FP64_Quaternion* c
|
||||||
|
|
||||||
const double multiplier = sin(angle) / axis_modulus;
|
const double multiplier = sin(angle) / axis_modulus;
|
||||||
|
|
||||||
quaternion->s0 = cos(angle);
|
quaternion->s = cos(angle);
|
||||||
quaternion->x1 = axis.x1 * multiplier;
|
quaternion->x = axis.x * multiplier;
|
||||||
quaternion->x2 = axis.x2 * multiplier;
|
quaternion->y = axis.y * multiplier;
|
||||||
quaternion->x3 = axis.x3 * multiplier;
|
quaternion->z = axis.z * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Make Pair Difference ============ //
|
// ============ Make Pair Difference ============ //
|
||||||
|
|
@ -492,7 +492,7 @@ int bgc_fp64_turn3_find_pair_difference(
|
||||||
|
|
||||||
void bgc_fp32_turn3_get_power(BGC_FP32_Turn3* const power, const BGC_FP32_Turn3* const base, const float exponent)
|
void bgc_fp32_turn3_get_power(BGC_FP32_Turn3* const power, const BGC_FP32_Turn3* const base, const float exponent)
|
||||||
{
|
{
|
||||||
const float square_vector = base->_versor.x1 * base->_versor.x1 + base->_versor.x2 * base->_versor.x2 + base->_versor.x3 * base->_versor.x3;
|
const float square_vector = base->_versor.x * base->_versor.x + base->_versor.y * base->_versor.y + base->_versor.z * base->_versor.z;
|
||||||
|
|
||||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON || square_vector != square_vector) {
|
if (square_vector <= BGC_FP32_SQUARE_EPSILON || square_vector != square_vector) {
|
||||||
bgc_fp32_turn3_reset(power);
|
bgc_fp32_turn3_reset(power);
|
||||||
|
|
@ -501,16 +501,16 @@ void bgc_fp32_turn3_get_power(BGC_FP32_Turn3* const power, const BGC_FP32_Turn3*
|
||||||
|
|
||||||
const float vector_modulus = sqrtf(square_vector);
|
const float vector_modulus = sqrtf(square_vector);
|
||||||
|
|
||||||
const float angle = atan2f(vector_modulus, base->_versor.s0) * exponent;
|
const float angle = atan2f(vector_modulus, base->_versor.s) * exponent;
|
||||||
|
|
||||||
const float multiplier = sinf(angle) / vector_modulus;
|
const float multiplier = sinf(angle) / vector_modulus;
|
||||||
|
|
||||||
bgc_fp32_turn3_set_values(power, cosf(angle), base->_versor.x1 * multiplier, base->_versor.x2 * multiplier, base->_versor.x3 * multiplier);
|
bgc_fp32_turn3_set_values(power, cosf(angle), base->_versor.x * multiplier, base->_versor.y * multiplier, base->_versor.z * multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgc_fp64_turn3_get_power(BGC_FP64_Turn3* const power, const BGC_FP64_Turn3* const base, const double exponent)
|
void bgc_fp64_turn3_get_power(BGC_FP64_Turn3* const power, const BGC_FP64_Turn3* const base, const double exponent)
|
||||||
{
|
{
|
||||||
const double square_vector = base->_versor.x1 * base->_versor.x1 + base->_versor.x2 * base->_versor.x2 + base->_versor.x3 * base->_versor.x3;
|
const double square_vector = base->_versor.x * base->_versor.x + base->_versor.y * base->_versor.y + base->_versor.z * base->_versor.z;
|
||||||
|
|
||||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON || square_vector != square_vector) {
|
if (square_vector <= BGC_FP64_SQUARE_EPSILON || square_vector != square_vector) {
|
||||||
bgc_fp64_turn3_reset(power);
|
bgc_fp64_turn3_reset(power);
|
||||||
|
|
@ -519,23 +519,23 @@ void bgc_fp64_turn3_get_power(BGC_FP64_Turn3* const power, const BGC_FP64_Turn3*
|
||||||
|
|
||||||
const double vector_modulus = sqrt(square_vector);
|
const double vector_modulus = sqrt(square_vector);
|
||||||
|
|
||||||
const double angle = atan2(vector_modulus, base->_versor.s0) * exponent;
|
const double angle = atan2(vector_modulus, base->_versor.s) * exponent;
|
||||||
|
|
||||||
const double multiplier = sin(angle) / vector_modulus;
|
const double multiplier = sin(angle) / vector_modulus;
|
||||||
|
|
||||||
bgc_fp64_turn3_set_values(power, cos(angle), base->_versor.x1 * multiplier, base->_versor.x2 * multiplier, base->_versor.x3 * multiplier);
|
bgc_fp64_turn3_set_values(power, cos(angle), base->_versor.x * multiplier, base->_versor.y * multiplier, base->_versor.z * multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Sphere Interpolation ============ //
|
// ============ Sphere Interpolation ============ //
|
||||||
|
|
||||||
void bgc_fp32_turn3_spherically_interpolate(BGC_FP32_Turn3* const interpolation, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const end, const float phase)
|
void bgc_fp32_turn3_spherically_interpolate(BGC_FP32_Turn3* const interpolation, const BGC_FP32_Turn3* const start, const BGC_FP32_Turn3* const end, const float phase)
|
||||||
{
|
{
|
||||||
const float delta_s0 = (end->_versor.s0 * start->_versor.s0 + end->_versor.x1 * start->_versor.x1) + (end->_versor.x2 * start->_versor.x2 + end->_versor.x3 * start->_versor.x3);
|
const float delta_s = (end->_versor.s * start->_versor.s + end->_versor.x * start->_versor.x) + (end->_versor.y * start->_versor.y + end->_versor.z * start->_versor.z);
|
||||||
const float delta_x1 = (end->_versor.x1 * start->_versor.s0 + end->_versor.x3 * start->_versor.x2) - (end->_versor.s0 * start->_versor.x1 + end->_versor.x2 * start->_versor.x3);
|
const float delta_x = (end->_versor.x * start->_versor.s + end->_versor.z * start->_versor.y) - (end->_versor.s * start->_versor.x + end->_versor.y * start->_versor.z);
|
||||||
const float delta_x2 = (end->_versor.x2 * start->_versor.s0 + end->_versor.x1 * start->_versor.x3) - (end->_versor.s0 * start->_versor.x2 + end->_versor.x3 * start->_versor.x1);
|
const float delta_y = (end->_versor.y * start->_versor.s + end->_versor.x * start->_versor.z) - (end->_versor.s * start->_versor.y + end->_versor.z * start->_versor.x);
|
||||||
const float delta_x3 = (end->_versor.x3 * start->_versor.s0 + end->_versor.x2 * start->_versor.x1) - (end->_versor.s0 * start->_versor.x3 + end->_versor.x1 * start->_versor.x2);
|
const float delta_z = (end->_versor.z * start->_versor.s + end->_versor.y * start->_versor.x) - (end->_versor.s * start->_versor.z + end->_versor.x * start->_versor.y);
|
||||||
|
|
||||||
const float square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
|
const float square_vector = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z;
|
||||||
|
|
||||||
// square_vector != square_vector means checking for NaN value at square_vector
|
// square_vector != square_vector means checking for NaN value at square_vector
|
||||||
if (square_vector <= BGC_FP32_SQUARE_EPSILON || isnan(square_vector)) {
|
if (square_vector <= BGC_FP32_SQUARE_EPSILON || isnan(square_vector)) {
|
||||||
|
|
@ -545,32 +545,32 @@ void bgc_fp32_turn3_spherically_interpolate(BGC_FP32_Turn3* const interpolation,
|
||||||
|
|
||||||
// Calculating of the turning which fits the phase:
|
// Calculating of the turning which fits the phase:
|
||||||
const float vector_modulus = sqrtf(square_vector);
|
const float vector_modulus = sqrtf(square_vector);
|
||||||
const float angle = atan2f(vector_modulus, delta_s0) * phase;
|
const float angle = atan2f(vector_modulus, delta_s) * phase;
|
||||||
const float multiplier = sinf(angle) / vector_modulus;
|
const float multiplier = sinf(angle) / vector_modulus;
|
||||||
|
|
||||||
const float turn_s0 = cosf(angle);
|
const float turn_s = cosf(angle);
|
||||||
const float turn_x1 = delta_x1 * multiplier;
|
const float turn_x = delta_x * multiplier;
|
||||||
const float turn_x2 = delta_x2 * multiplier;
|
const float turn_y = delta_y * multiplier;
|
||||||
const float turn_x3 = delta_x3 * multiplier;
|
const float turn_z = delta_z * multiplier;
|
||||||
|
|
||||||
// Combining of starting orientation with the turning
|
// Combining of starting orientation with the turning
|
||||||
bgc_fp32_turn3_set_values(
|
bgc_fp32_turn3_set_values(
|
||||||
interpolation,
|
interpolation,
|
||||||
(turn_s0 * start->_versor.s0 - turn_x1 * start->_versor.x1) - (turn_x2 * start->_versor.x2 + turn_x3 * start->_versor.x3),
|
(turn_s * start->_versor.s - turn_x * start->_versor.x) - (turn_y * start->_versor.y + turn_z * start->_versor.z),
|
||||||
(turn_x1 * start->_versor.s0 + turn_s0 * start->_versor.x1) - (turn_x3 * start->_versor.x2 - turn_x2 * start->_versor.x3),
|
(turn_x * start->_versor.s + turn_s * start->_versor.x) - (turn_z * start->_versor.y - turn_y * start->_versor.z),
|
||||||
(turn_x2 * start->_versor.s0 + turn_s0 * start->_versor.x2) - (turn_x1 * start->_versor.x3 - turn_x3 * start->_versor.x1),
|
(turn_y * start->_versor.s + turn_s * start->_versor.y) - (turn_x * start->_versor.z - turn_z * start->_versor.x),
|
||||||
(turn_x3 * start->_versor.s0 + turn_s0 * start->_versor.x3) - (turn_x2 * start->_versor.x1 - turn_x1 * start->_versor.x2)
|
(turn_z * start->_versor.s + turn_s * start->_versor.z) - (turn_y * start->_versor.x - turn_x * start->_versor.y)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bgc_fp64_turn3_spherically_interpolate(BGC_FP64_Turn3* const interpolation, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const end, const double phase)
|
void bgc_fp64_turn3_spherically_interpolate(BGC_FP64_Turn3* const interpolation, const BGC_FP64_Turn3* const start, const BGC_FP64_Turn3* const end, const double phase)
|
||||||
{
|
{
|
||||||
const double delta_s0 = (end->_versor.s0 * start->_versor.s0 + end->_versor.x1 * start->_versor.x1) + (end->_versor.x2 * start->_versor.x2 + end->_versor.x3 * start->_versor.x3);
|
const double delta_s = (end->_versor.s * start->_versor.s + end->_versor.x * start->_versor.x) + (end->_versor.y * start->_versor.y + end->_versor.z * start->_versor.z);
|
||||||
const double delta_x1 = (end->_versor.x1 * start->_versor.s0 + end->_versor.x3 * start->_versor.x2) - (end->_versor.s0 * start->_versor.x1 + end->_versor.x2 * start->_versor.x3);
|
const double delta_x = (end->_versor.x * start->_versor.s + end->_versor.z * start->_versor.y) - (end->_versor.s * start->_versor.x + end->_versor.y * start->_versor.z);
|
||||||
const double delta_x2 = (end->_versor.x2 * start->_versor.s0 + end->_versor.x1 * start->_versor.x3) - (end->_versor.s0 * start->_versor.x2 + end->_versor.x3 * start->_versor.x1);
|
const double delta_y = (end->_versor.y * start->_versor.s + end->_versor.x * start->_versor.z) - (end->_versor.s * start->_versor.y + end->_versor.z * start->_versor.x);
|
||||||
const double delta_x3 = (end->_versor.x3 * start->_versor.s0 + end->_versor.x2 * start->_versor.x1) - (end->_versor.s0 * start->_versor.x3 + end->_versor.x1 * start->_versor.x2);
|
const double delta_z = (end->_versor.z * start->_versor.s + end->_versor.y * start->_versor.x) - (end->_versor.s * start->_versor.z + end->_versor.x * start->_versor.y);
|
||||||
|
|
||||||
const double square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
|
const double square_vector = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z;
|
||||||
|
|
||||||
// square_vector != square_vector means checking for NaN value at square_vector
|
// square_vector != square_vector means checking for NaN value at square_vector
|
||||||
if (square_vector <= BGC_FP64_SQUARE_EPSILON || isnan(square_vector)) {
|
if (square_vector <= BGC_FP64_SQUARE_EPSILON || isnan(square_vector)) {
|
||||||
|
|
@ -580,20 +580,20 @@ void bgc_fp64_turn3_spherically_interpolate(BGC_FP64_Turn3* const interpolation,
|
||||||
|
|
||||||
// Calculating of the turning which fits the phase:
|
// Calculating of the turning which fits the phase:
|
||||||
const double vector_modulus = sqrt(square_vector);
|
const double vector_modulus = sqrt(square_vector);
|
||||||
const double angle = atan2(vector_modulus, delta_s0) * phase;
|
const double angle = atan2(vector_modulus, delta_s) * phase;
|
||||||
const double multiplier = sin(angle) / vector_modulus;
|
const double multiplier = sin(angle) / vector_modulus;
|
||||||
|
|
||||||
const double turn_s0 = cos(angle);
|
const double turn_s = cos(angle);
|
||||||
const double turn_x1 = delta_x1 * multiplier;
|
const double turn_x = delta_x * multiplier;
|
||||||
const double turn_x2 = delta_x2 * multiplier;
|
const double turn_y = delta_y * multiplier;
|
||||||
const double turn_x3 = delta_x3 * multiplier;
|
const double turn_z = delta_z * multiplier;
|
||||||
|
|
||||||
// Combining of starting orientation with the turning
|
// Combining of starting orientation with the turning
|
||||||
bgc_fp64_turn3_set_values(
|
bgc_fp64_turn3_set_values(
|
||||||
interpolation,
|
interpolation,
|
||||||
(turn_s0 * start->_versor.s0 - turn_x1 * start->_versor.x1) - (turn_x2 * start->_versor.x2 + turn_x3 * start->_versor.x3),
|
(turn_s * start->_versor.s - turn_x * start->_versor.x) - (turn_y * start->_versor.y + turn_z * start->_versor.z),
|
||||||
(turn_x1 * start->_versor.s0 + turn_s0 * start->_versor.x1) - (turn_x3 * start->_versor.x2 - turn_x2 * start->_versor.x3),
|
(turn_x * start->_versor.s + turn_s * start->_versor.x) - (turn_z * start->_versor.y - turn_y * start->_versor.z),
|
||||||
(turn_x2 * start->_versor.s0 + turn_s0 * start->_versor.x2) - (turn_x1 * start->_versor.x3 - turn_x3 * start->_versor.x1),
|
(turn_y * start->_versor.s + turn_s * start->_versor.y) - (turn_x * start->_versor.z - turn_z * start->_versor.x),
|
||||||
(turn_x3 * start->_versor.s0 + turn_s0 * start->_versor.x3) - (turn_x2 * start->_versor.x1 - turn_x1 * start->_versor.x2)
|
(turn_z * start->_versor.s + turn_s * start->_versor.z) - (turn_y * start->_versor.x - turn_x * start->_versor.y)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,18 @@ extern const BGC_FP64_Turn3 BGC_FP64_IDLE_TURN3;
|
||||||
|
|
||||||
inline void bgc_fp32_turn3_reset(BGC_FP32_Turn3* const turn)
|
inline void bgc_fp32_turn3_reset(BGC_FP32_Turn3* const turn)
|
||||||
{
|
{
|
||||||
turn->_versor.s0 = 1.0f;
|
turn->_versor.s = 1.0f;
|
||||||
turn->_versor.x1 = 0.0f;
|
turn->_versor.x = 0.0f;
|
||||||
turn->_versor.x2 = 0.0f;
|
turn->_versor.y = 0.0f;
|
||||||
turn->_versor.x3 = 0.0f;
|
turn->_versor.z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn)
|
inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn)
|
||||||
{
|
{
|
||||||
turn->_versor.s0 = 1.0;
|
turn->_versor.s = 1.0;
|
||||||
turn->_versor.x1 = 0.0;
|
turn->_versor.x = 0.0;
|
||||||
turn->_versor.x2 = 0.0;
|
turn->_versor.y = 0.0;
|
||||||
turn->_versor.x3 = 0.0;
|
turn->_versor.z = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Private: Normalize ============= //
|
// ============= Private: Normalize ============= //
|
||||||
|
|
@ -61,19 +61,19 @@ inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
|
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||||
turn->_versor.s0 = 1.0f;
|
turn->_versor.s = 1.0f;
|
||||||
turn->_versor.x1 = 0.0f;
|
turn->_versor.x = 0.0f;
|
||||||
turn->_versor.x2 = 0.0f;
|
turn->_versor.y = 0.0f;
|
||||||
turn->_versor.x3 = 0.0f;
|
turn->_versor.z = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float multiplier = sqrtf(1.0f / square_magnitude);
|
const float multiplier = sqrtf(1.0f / square_magnitude);
|
||||||
|
|
||||||
turn->_versor.s0 *= multiplier;
|
turn->_versor.s *= multiplier;
|
||||||
turn->_versor.x1 *= multiplier;
|
turn->_versor.x *= multiplier;
|
||||||
turn->_versor.x2 *= multiplier;
|
turn->_versor.y *= multiplier;
|
||||||
turn->_versor.x3 *= multiplier;
|
turn->_versor.z *= multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
|
inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
|
||||||
|
|
@ -85,32 +85,32 @@ inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
|
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||||
turn->_versor.s0 = 1.0;
|
turn->_versor.s = 1.0;
|
||||||
turn->_versor.x1 = 0.0;
|
turn->_versor.x = 0.0;
|
||||||
turn->_versor.x2 = 0.0;
|
turn->_versor.y = 0.0;
|
||||||
turn->_versor.x3 = 0.0;
|
turn->_versor.z = 0.0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double multiplier = sqrt(1.0 / square_magnitude);
|
const double multiplier = sqrt(1.0 / square_magnitude);
|
||||||
|
|
||||||
turn->_versor.s0 *= multiplier;
|
turn->_versor.s *= multiplier;
|
||||||
turn->_versor.x1 *= multiplier;
|
turn->_versor.x *= multiplier;
|
||||||
turn->_versor.x2 *= multiplier;
|
turn->_versor.y *= multiplier;
|
||||||
turn->_versor.x3 *= multiplier;
|
turn->_versor.z *= multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Set Values ================= //
|
// ================= Set Values ================= //
|
||||||
|
|
||||||
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s0, const float x1, const float x2, const float x3)
|
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s, const float x, const float y, const float z)
|
||||||
{
|
{
|
||||||
bgc_fp32_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
|
bgc_fp32_quaternion_set_values(&turn->_versor, s, x, y, z);
|
||||||
_bgc_fp32_turn3_normalize(turn);
|
_bgc_fp32_turn3_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s0, const double x1, const double x2, const double x3)
|
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s, const double x, const double y, const double z)
|
||||||
{
|
{
|
||||||
bgc_fp64_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
|
bgc_fp64_quaternion_set_values(&turn->_versor, s, x, y, z);
|
||||||
_bgc_fp64_turn3_normalize(turn);
|
_bgc_fp64_turn3_normalize(turn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,9 +148,9 @@ double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_
|
||||||
|
|
||||||
// ================ Set Rotation ================ //
|
// ================ Set Rotation ================ //
|
||||||
|
|
||||||
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, const float x2, const float x3, const float angle, const int angle_unit);
|
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x, const float y, const float z, const float angle, const int angle_unit);
|
||||||
|
|
||||||
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, const double x2, const double x3, const double angle, const int angle_unit);
|
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x, const double y, const double z, const double angle, const int angle_unit);
|
||||||
|
|
||||||
// ========= Find Direction Difference ========== //
|
// ========= Find Direction Difference ========== //
|
||||||
|
|
||||||
|
|
@ -231,21 +231,21 @@ inline void bgc_fp64_turn3_convert_to_fp32(BGC_FP32_Turn3* const destination, co
|
||||||
|
|
||||||
inline void bgc_fp32_turn3_shorten(BGC_FP32_Turn3* const turn)
|
inline void bgc_fp32_turn3_shorten(BGC_FP32_Turn3* const turn)
|
||||||
{
|
{
|
||||||
if (turn->_versor.s0 < 0.0f) {
|
if (turn->_versor.s < 0.0f) {
|
||||||
bgc_fp32_quaternion_revert(&turn->_versor);
|
bgc_fp32_quaternion_revert(&turn->_versor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_turn3_shorten(BGC_FP64_Turn3* const turn)
|
inline void bgc_fp64_turn3_shorten(BGC_FP64_Turn3* const turn)
|
||||||
{
|
{
|
||||||
if (turn->_versor.s0 < 0.0) {
|
if (turn->_versor.s < 0.0) {
|
||||||
bgc_fp64_quaternion_revert(&turn->_versor);
|
bgc_fp64_quaternion_revert(&turn->_versor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const BGC_FP32_Turn3* const turn)
|
inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const BGC_FP32_Turn3* const turn)
|
||||||
{
|
{
|
||||||
if (turn->_versor.s0 >= 0.0f) {
|
if (turn->_versor.s >= 0.0f) {
|
||||||
bgc_fp32_quaternion_copy(&shortened->_versor, &turn->_versor);
|
bgc_fp32_quaternion_copy(&shortened->_versor, &turn->_versor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -255,7 +255,7 @@ inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const
|
||||||
|
|
||||||
inline void bgc_fp64_turn3_get_shortened(BGC_FP64_Turn3* const shortened, const BGC_FP64_Turn3* const turn)
|
inline void bgc_fp64_turn3_get_shortened(BGC_FP64_Turn3* const shortened, const BGC_FP64_Turn3* const turn)
|
||||||
{
|
{
|
||||||
if (turn->_versor.s0 >= 0.0) {
|
if (turn->_versor.s >= 0.0) {
|
||||||
bgc_fp64_quaternion_copy(&shortened->_versor, &turn->_versor);
|
bgc_fp64_quaternion_copy(&shortened->_versor, &turn->_versor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,24 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float x1, x2;
|
float x, y;
|
||||||
} BGC_FP32_Vector2;
|
} BGC_FP32_Vector2;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double x1, x2;
|
double x, y;
|
||||||
} BGC_FP64_Vector2;
|
} BGC_FP64_Vector2;
|
||||||
|
|
||||||
// ================== Vector3 =================== //
|
// ================== Vector3 =================== //
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float x1, x2, x3;
|
float x, y, z;
|
||||||
} BGC_FP32_Vector3;
|
} BGC_FP32_Vector3;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double x1, x2, x3;
|
double x, y, z;
|
||||||
} BGC_FP64_Vector3;
|
} BGC_FP64_Vector3;
|
||||||
|
|
||||||
// ================== Matrix2x2 ================= //
|
// ================== Matrix2x2 ================= //
|
||||||
|
|
@ -128,11 +128,11 @@ typedef struct
|
||||||
// ================= Quaternion ================= //
|
// ================= Quaternion ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float s0, x1, x2, x3;
|
float s, x, y, z;
|
||||||
} BGC_FP32_Quaternion;
|
} BGC_FP32_Quaternion;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double s0, x1, x2, x3;
|
double s, x, y, z;
|
||||||
} BGC_FP64_Quaternion;
|
} BGC_FP64_Quaternion;
|
||||||
|
|
||||||
// =================== Turn3 ==================== //
|
// =================== Turn3 ==================== //
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector);
|
extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector);
|
||||||
extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector);
|
extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x1, const float x2);
|
extern inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
|
||||||
extern inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x1, const double x2);
|
extern inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
|
||||||
|
|
||||||
extern inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector);
|
extern inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector);
|
||||||
extern inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector);
|
extern inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector);
|
||||||
|
|
|
||||||
|
|
@ -11,40 +11,40 @@
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = 0.0f;
|
vector->x = 0.0f;
|
||||||
vector->x2 = 0.0f;
|
vector->y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = 0.0;
|
vector->x = 0.0;
|
||||||
vector->x2 = 0.0;
|
vector->y = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Set ===================== //
|
// ==================== Set ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x1, const float x2)
|
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y)
|
||||||
{
|
{
|
||||||
destination->x1 = x1;
|
destination->x = x;
|
||||||
destination->x2 = x2;
|
destination->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x1, const double x2)
|
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y)
|
||||||
{
|
{
|
||||||
destination->x1 = x1;
|
destination->x = x;
|
||||||
destination->x2 = x2;
|
destination->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Modulus =================== //
|
// ================== Modulus =================== //
|
||||||
|
|
||||||
inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector)
|
inline float bgc_fp32_vector2_get_squared_length(const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2;
|
return vector->x * vector->x + vector->y * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector)
|
inline double bgc_fp64_vector2_get_squared_length(const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2;
|
return vector->x * vector->x + vector->y * vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float bgc_fp32_vector2_get_length(const BGC_FP32_Vector2* const vector)
|
inline float bgc_fp32_vector2_get_length(const BGC_FP32_Vector2* const vector)
|
||||||
|
|
@ -83,160 +83,160 @@ inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* const vector)
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source)
|
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source)
|
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2)
|
inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
const float x1 = vector2->x1;
|
const float x = vector2->x;
|
||||||
const float x2 = vector2->x2;
|
const float y = vector2->y;
|
||||||
|
|
||||||
vector2->x1 = vector1->x1;
|
vector2->x = vector1->x;
|
||||||
vector2->x2 = vector1->x2;
|
vector2->y = vector1->y;
|
||||||
|
|
||||||
vector1->x1 = x1;
|
vector1->x = x;
|
||||||
vector1->x2 = x2;
|
vector1->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* const vector2)
|
inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
const double x1 = vector2->x1;
|
const double x = vector2->x;
|
||||||
const double x2 = vector2->x2;
|
const double y = vector2->y;
|
||||||
|
|
||||||
vector2->x1 = vector1->x1;
|
vector2->x = vector1->x;
|
||||||
vector2->x2 = vector1->x2;
|
vector2->y = vector1->y;
|
||||||
|
|
||||||
vector1->x1 = x1;
|
vector1->x = x;
|
||||||
vector1->x2 = x2;
|
vector1->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_convert_to_fp64(BGC_FP64_Vector2* const destination, const BGC_FP32_Vector2* const source)
|
inline void bgc_fp32_vector2_convert_to_fp64(BGC_FP64_Vector2* const destination, const BGC_FP32_Vector2* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_convert_to_fp32(BGC_FP32_Vector2* const destination, const BGC_FP64_Vector2* const source)
|
inline void bgc_fp64_vector2_convert_to_fp32(BGC_FP32_Vector2* const destination, const BGC_FP64_Vector2* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = (float)source->x1;
|
destination->x = (float)source->x;
|
||||||
destination->x2 = (float)source->x2;
|
destination->y = (float)source->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_add(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
inline void bgc_fp32_vector2_add(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
sum->x1 = vector1->x1 + vector2->x1;
|
sum->x = vector1->x + vector2->x;
|
||||||
sum->x2 = vector1->x2 + vector2->x2;
|
sum->y = vector1->y + vector2->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_add(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
inline void bgc_fp64_vector2_add(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
sum->x1 = vector1->x1 + vector2->x1;
|
sum->x = vector1->x + vector2->x;
|
||||||
sum->x2 = vector1->x2 + vector2->x2;
|
sum->y = vector1->y + vector2->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add Scaled ================= //
|
// ================= Add Scaled ================= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_add_scaled(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
|
inline void bgc_fp32_vector2_add_scaled(BGC_FP32_Vector2* const sum, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
|
||||||
{
|
{
|
||||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
sum->x = basic_vector->x + scalable_vector->x * scale;
|
||||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
sum->y = basic_vector->y + scalable_vector->y * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
|
inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* const sum, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
|
||||||
{
|
{
|
||||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
sum->x = basic_vector->x + scalable_vector->x * scale;
|
||||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
sum->y = basic_vector->y + scalable_vector->y * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const minuend, const BGC_FP32_Vector2* const subtrahend)
|
inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const minuend, const BGC_FP32_Vector2* const subtrahend)
|
||||||
{
|
{
|
||||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
difference->x = minuend->x - subtrahend->x;
|
||||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
difference->y = minuend->y - subtrahend->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const minuend, const BGC_FP64_Vector2* const subtrahend)
|
inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const minuend, const BGC_FP64_Vector2* const subtrahend)
|
||||||
{
|
{
|
||||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
difference->x = minuend->x - subtrahend->x;
|
||||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
difference->y = minuend->y - subtrahend->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Subtract Scaled =============== //
|
// ============== Subtract Scaled =============== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_subtract_scaled(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
|
inline void bgc_fp32_vector2_subtract_scaled(BGC_FP32_Vector2* const difference, const BGC_FP32_Vector2* const basic_vector, const BGC_FP32_Vector2* const scalable_vector, const float scale)
|
||||||
{
|
{
|
||||||
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
|
difference->x = basic_vector->x - scalable_vector->x * scale;
|
||||||
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
|
difference->y = basic_vector->y - scalable_vector->y * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_subtract_scaled(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
|
inline void bgc_fp64_vector2_subtract_scaled(BGC_FP64_Vector2* const difference, const BGC_FP64_Vector2* const basic_vector, const BGC_FP64_Vector2* const scalable_vector, const double scale)
|
||||||
{
|
{
|
||||||
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
|
difference->x = basic_vector->x - scalable_vector->x * scale;
|
||||||
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
|
difference->y = basic_vector->y - scalable_vector->y * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_multiply_by_real_number(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const multiplicand, const float multiplier)
|
inline void bgc_fp32_vector2_multiply_by_real_number(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const multiplicand, const float multiplier)
|
||||||
{
|
{
|
||||||
product->x1 = multiplicand->x1 * multiplier;
|
product->x = multiplicand->x * multiplier;
|
||||||
product->x2 = multiplicand->x2 * multiplier;
|
product->y = multiplicand->y * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_multiply_by_real_number(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const multiplicand, const double multiplier)
|
inline void bgc_fp64_vector2_multiply_by_real_number(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const multiplicand, const double multiplier)
|
||||||
{
|
{
|
||||||
product->x1 = multiplicand->x1 * multiplier;
|
product->x = multiplicand->x * multiplier;
|
||||||
product->x2 = multiplicand->x2 * multiplier;
|
product->y = multiplicand->y * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_multiply_by_matrix2x2(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix2x2* const matrix)
|
inline void bgc_fp32_vector2_multiply_by_matrix2x2(BGC_FP32_Vector2* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix2x2* const matrix)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const float x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
|
||||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const float y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_multiply_by_matrix2x2(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix2x2* const matrix)
|
inline void bgc_fp64_vector2_multiply_by_matrix2x2(BGC_FP64_Vector2* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix2x2* const matrix)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const double x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
|
||||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const double y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_multiply_by_matrix3x2(BGC_FP32_Vector3* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix3x2* const matrix)
|
inline void bgc_fp32_vector2_multiply_by_matrix3x2(BGC_FP32_Vector3* const product, const BGC_FP32_Vector2* const vector, const BGC_FP32_Matrix3x2* const matrix)
|
||||||
{
|
{
|
||||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
|
||||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
|
||||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
product->z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_multiply_by_matrix3x2(BGC_FP64_Vector3* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix3x2* const matrix)
|
inline void bgc_fp64_vector2_multiply_by_matrix3x2(BGC_FP64_Vector3* const product, const BGC_FP64_Vector2* const vector, const BGC_FP64_Matrix3x2* const matrix)
|
||||||
{
|
{
|
||||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1;
|
||||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2;
|
||||||
product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
product->z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Divide =================== //
|
// =================== Divide =================== //
|
||||||
|
|
@ -267,28 +267,28 @@ inline int bgc_fp64_vector2_divide_by_real_number(BGC_FP64_Vector2* const quotie
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
|
mean->x = (vector1->x + vector2->x) * 0.5f;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f;
|
mean->y = (vector1->y + vector2->y) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5;
|
mean->x = (vector1->x + vector2->x) * 0.5;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5;
|
mean->y = (vector1->y + vector2->y) * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Mean of Three ================ //
|
// =============== Mean of Three ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_get_mean3(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2, const BGC_FP32_Vector2* const vector3)
|
inline void bgc_fp32_vector2_get_mean3(BGC_FP32_Vector2* const mean, const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2, const BGC_FP32_Vector2* const vector3)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
|
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP32_ONE_THIRD;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
|
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP32_ONE_THIRD;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_get_mean3(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2, const BGC_FP64_Vector2* const vector3)
|
inline void bgc_fp64_vector2_get_mean3(BGC_FP64_Vector2* const mean, const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2, const BGC_FP64_Vector2* const vector3)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
|
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP64_ONE_THIRD;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
|
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP64_ONE_THIRD;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Linear =================== //
|
// =================== Linear =================== //
|
||||||
|
|
@ -297,42 +297,42 @@ inline void bgc_fp32_vector2_interpolate(BGC_FP32_Vector2* const interpolation,
|
||||||
{
|
{
|
||||||
const float counter_phase = 1.0f - phase;
|
const float counter_phase = 1.0f - phase;
|
||||||
|
|
||||||
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
|
interpolation->x = first->x * counter_phase + second->x * phase;
|
||||||
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
|
interpolation->y = first->y * counter_phase + second->y * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_interpolate(BGC_FP64_Vector2* const interpolation, const BGC_FP64_Vector2* const first, const BGC_FP64_Vector2* const second, const double phase)
|
inline void bgc_fp64_vector2_interpolate(BGC_FP64_Vector2* const interpolation, const BGC_FP64_Vector2* const first, const BGC_FP64_Vector2* const second, const double phase)
|
||||||
{
|
{
|
||||||
const double counter_phase = 1.0 - phase;
|
const double counter_phase = 1.0 - phase;
|
||||||
|
|
||||||
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
|
interpolation->x = first->x * counter_phase + second->x * phase;
|
||||||
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
|
interpolation->y = first->y * counter_phase + second->y * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Negative ================== //
|
// ================== Negative ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = -vector->x1;
|
vector->x = -vector->x;
|
||||||
vector->x2 = -vector->x2;
|
vector->y = -vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = -vector->x1;
|
vector->x = -vector->x;
|
||||||
vector->x2 = -vector->x2;
|
vector->y = -vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp32_vector2_get_reverse(BGC_FP32_Vector2* const reverse, const BGC_FP32_Vector2* const vector)
|
inline void bgc_fp32_vector2_get_reverse(BGC_FP32_Vector2* const reverse, const BGC_FP32_Vector2* const vector)
|
||||||
{
|
{
|
||||||
reverse->x1 = -vector->x1;
|
reverse->x = -vector->x;
|
||||||
reverse->x2 = -vector->x2;
|
reverse->y = -vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector2_get_reverse(BGC_FP64_Vector2* const reverse, const BGC_FP64_Vector2* const vector)
|
inline void bgc_fp64_vector2_get_reverse(BGC_FP64_Vector2* const reverse, const BGC_FP64_Vector2* const vector)
|
||||||
{
|
{
|
||||||
reverse->x1 = -vector->x1;
|
reverse->x = -vector->x;
|
||||||
reverse->x2 = -vector->x2;
|
reverse->y = -vector->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Normalize ================== //
|
// ================= Normalize ================== //
|
||||||
|
|
@ -351,8 +351,8 @@ inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* const vector)
|
||||||
|
|
||||||
const float multiplier = sqrtf(1.0f / square_modulus);
|
const float multiplier = sqrtf(1.0f / square_modulus);
|
||||||
|
|
||||||
vector->x1 *= multiplier;
|
vector->x *= multiplier;
|
||||||
vector->x2 *= multiplier;
|
vector->y *= multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -371,8 +371,8 @@ inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* const vector)
|
||||||
|
|
||||||
const double multiplier = sqrt(1.0 / square_modulus);
|
const double multiplier = sqrt(1.0 / square_modulus);
|
||||||
|
|
||||||
vector->x1 *= multiplier;
|
vector->x *= multiplier;
|
||||||
vector->x2 *= multiplier;
|
vector->y *= multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -417,24 +417,24 @@ inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* const normalized, c
|
||||||
|
|
||||||
inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
|
return vector1->x * vector2->x + vector1->y * vector2->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
|
return vector1->x * vector2->x + vector1->y * vector2->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Get Cross Product ============== //
|
// ============= Get Cross Product ============== //
|
||||||
|
|
||||||
inline float bgc_fp32_vector2_get_cross_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
inline float bgc_fp32_vector2_get_cross_product(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
return vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector2_get_cross_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
inline double bgc_fp64_vector2_get_cross_product(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
return vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Get Angle ================== //
|
// ================= Get Angle ================== //
|
||||||
|
|
@ -447,18 +447,18 @@ double bgc_fp64_vector2_get_angle(const BGC_FP64_Vector2* const vector1, const B
|
||||||
|
|
||||||
inline float bgc_fp32_vector2_get_square_distance(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
inline float bgc_fp32_vector2_get_square_distance(const BGC_FP32_Vector2* const vector1, const BGC_FP32_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
const float dx1 = vector1->x1 - vector2->x1;
|
const float dx = vector1->x - vector2->x;
|
||||||
const float dx2 = vector1->x2 - vector2->x2;
|
const float dy = vector1->y - vector2->y;
|
||||||
|
|
||||||
return dx1 * dx1 + dx2 * dx2;
|
return dx * dx + dy * dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector2_get_square_distance(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
inline double bgc_fp64_vector2_get_square_distance(const BGC_FP64_Vector2* const vector1, const BGC_FP64_Vector2* const vector2)
|
||||||
{
|
{
|
||||||
const double dx1 = vector1->x1 - vector2->x1;
|
const double dx = vector1->x - vector2->x;
|
||||||
const double dx2 = vector1->x2 - vector2->x2;
|
const double dy = vector1->y - vector2->y;
|
||||||
|
|
||||||
return dx1 * dx1 + dx2 * dx2;
|
return dx * dx + dy * dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Distance ================== //
|
// ================== Distance ================== //
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
|
extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
|
||||||
extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector);
|
extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector);
|
||||||
|
|
||||||
extern inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x1, const float x2, const float x3);
|
extern inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
|
||||||
extern inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x1, const double x2, const double x3);
|
extern inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
|
||||||
|
|
||||||
extern inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector);
|
extern inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector);
|
||||||
extern inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector);
|
extern inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector);
|
||||||
|
|
|
||||||
|
|
@ -11,44 +11,44 @@
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector)
|
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = 0.0f;
|
vector->x = 0.0f;
|
||||||
vector->x2 = 0.0f;
|
vector->y = 0.0f;
|
||||||
vector->x3 = 0.0f;
|
vector->z = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector)
|
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = 0.0;
|
vector->x = 0.0;
|
||||||
vector->x2 = 0.0;
|
vector->y = 0.0;
|
||||||
vector->x3 = 0.0;
|
vector->z = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Set ===================== //
|
// ==================== Set ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x1, const float x2, const float x3)
|
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z)
|
||||||
{
|
{
|
||||||
destination->x1 = x1;
|
destination->x = x;
|
||||||
destination->x2 = x2;
|
destination->y = y;
|
||||||
destination->x3 = x3;
|
destination->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x1, const double x2, const double x3)
|
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z)
|
||||||
{
|
{
|
||||||
destination->x1 = x1;
|
destination->x = x;
|
||||||
destination->x2 = x2;
|
destination->y = y;
|
||||||
destination->x3 = x3;
|
destination->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Modulus =================== //
|
// ================== Modulus =================== //
|
||||||
|
|
||||||
inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector)
|
inline float bgc_fp32_vector3_get_squared_length(const BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
|
return vector->x * vector->x + vector->y * vector->y + vector->z * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector)
|
inline double bgc_fp64_vector3_get_squared_length(const BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
|
return vector->x * vector->x + vector->y * vector->y + vector->z * vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float bgc_fp32_vector3_get_length(const BGC_FP32_Vector3* const vector)
|
inline float bgc_fp32_vector3_get_length(const BGC_FP32_Vector3* const vector)
|
||||||
|
|
@ -87,246 +87,246 @@ inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* const vector)
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source)
|
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
destination->x3 = source->x3;
|
destination->z = source->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source)
|
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
destination->x3 = source->x3;
|
destination->z = source->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2)
|
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const float x1 = vector2->x1;
|
const float x = vector2->x;
|
||||||
const float x2 = vector2->x2;
|
const float y = vector2->y;
|
||||||
const float x3 = vector2->x3;
|
const float z = vector2->z;
|
||||||
|
|
||||||
vector2->x1 = vector1->x1;
|
vector2->x = vector1->x;
|
||||||
vector2->x2 = vector1->x2;
|
vector2->y = vector1->y;
|
||||||
vector2->x3 = vector1->x3;
|
vector2->z = vector1->z;
|
||||||
|
|
||||||
vector1->x1 = x1;
|
vector1->x = x;
|
||||||
vector1->x2 = x2;
|
vector1->y = y;
|
||||||
vector1->x3 = x3;
|
vector1->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2)
|
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const double x1 = vector2->x1;
|
const double x = vector2->x;
|
||||||
const double x2 = vector2->x2;
|
const double y = vector2->y;
|
||||||
const double x3 = vector2->x3;
|
const double z = vector2->z;
|
||||||
|
|
||||||
vector2->x1 = vector1->x1;
|
vector2->x = vector1->x;
|
||||||
vector2->x2 = vector1->x2;
|
vector2->y = vector1->y;
|
||||||
vector2->x3 = vector1->x3;
|
vector2->z = vector1->z;
|
||||||
|
|
||||||
vector1->x1 = x1;
|
vector1->x = x;
|
||||||
vector1->x2 = x2;
|
vector1->y = y;
|
||||||
vector1->x3 = x3;
|
vector1->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_convert_to_fp64(BGC_FP64_Vector3* const destination, const BGC_FP32_Vector3* const source)
|
inline void bgc_fp32_vector3_convert_to_fp64(BGC_FP64_Vector3* const destination, const BGC_FP32_Vector3* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = source->x1;
|
destination->x = source->x;
|
||||||
destination->x2 = source->x2;
|
destination->y = source->y;
|
||||||
destination->x3 = source->x3;
|
destination->z = source->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_convert_to_fp32(BGC_FP32_Vector3* const destination, const BGC_FP64_Vector3* const source)
|
inline void bgc_fp64_vector3_convert_to_fp32(BGC_FP32_Vector3* const destination, const BGC_FP64_Vector3* const source)
|
||||||
{
|
{
|
||||||
destination->x1 = (float)source->x1;
|
destination->x = (float)source->x;
|
||||||
destination->x2 = (float)source->x2;
|
destination->y = (float)source->y;
|
||||||
destination->x3 = (float)source->x3;
|
destination->z = (float)source->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_add(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline void bgc_fp32_vector3_add(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
sum->x1 = vector1->x1 + vector2->x1;
|
sum->x = vector1->x + vector2->x;
|
||||||
sum->x2 = vector1->x2 + vector2->x2;
|
sum->y = vector1->y + vector2->y;
|
||||||
sum->x3 = vector1->x3 + vector2->x3;
|
sum->z = vector1->z + vector2->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_add(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline void bgc_fp64_vector3_add(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
sum->x1 = vector1->x1 + vector2->x1;
|
sum->x = vector1->x + vector2->x;
|
||||||
sum->x2 = vector1->x2 + vector2->x2;
|
sum->y = vector1->y + vector2->y;
|
||||||
sum->x3 = vector1->x3 + vector2->x3;
|
sum->z = vector1->z + vector2->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add scaled ================= //
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_add_scaled(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
|
inline void bgc_fp32_vector3_add_scaled(BGC_FP32_Vector3* const sum, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
|
||||||
{
|
{
|
||||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
sum->x = basic_vector->x + scalable_vector->x * scale;
|
||||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
sum->y = basic_vector->y + scalable_vector->y * scale;
|
||||||
sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale;
|
sum->z = basic_vector->z + scalable_vector->z * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
|
inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* const sum, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
|
||||||
{
|
{
|
||||||
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
|
sum->x = basic_vector->x + scalable_vector->x * scale;
|
||||||
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
|
sum->y = basic_vector->y + scalable_vector->y * scale;
|
||||||
sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale;
|
sum->z = basic_vector->z + scalable_vector->z * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const minuend, const BGC_FP32_Vector3* const subtrahend)
|
inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const minuend, const BGC_FP32_Vector3* const subtrahend)
|
||||||
{
|
{
|
||||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
difference->x = minuend->x - subtrahend->x;
|
||||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
difference->y = minuend->y - subtrahend->y;
|
||||||
difference->x3 = minuend->x3 - subtrahend->x3;
|
difference->z = minuend->z - subtrahend->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const minuend, const BGC_FP64_Vector3* const subtrahend)
|
inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const minuend, const BGC_FP64_Vector3* const subtrahend)
|
||||||
{
|
{
|
||||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
difference->x = minuend->x - subtrahend->x;
|
||||||
difference->x2 = minuend->x2 - subtrahend->x2;
|
difference->y = minuend->y - subtrahend->y;
|
||||||
difference->x3 = minuend->x3 - subtrahend->x3;
|
difference->z = minuend->z - subtrahend->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Subtract Scaled =============== //
|
// ============== Subtract Scaled =============== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_subtract_scaled(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
|
inline void bgc_fp32_vector3_subtract_scaled(BGC_FP32_Vector3* const difference, const BGC_FP32_Vector3* const basic_vector, const BGC_FP32_Vector3* const scalable_vector, const float scale)
|
||||||
{
|
{
|
||||||
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
|
difference->x = basic_vector->x - scalable_vector->x * scale;
|
||||||
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
|
difference->y = basic_vector->y - scalable_vector->y * scale;
|
||||||
difference->x3 = basic_vector->x3 - scalable_vector->x3 * scale;
|
difference->z = basic_vector->z - scalable_vector->z * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_subtract_scaled(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
|
inline void bgc_fp64_vector3_subtract_scaled(BGC_FP64_Vector3* const difference, const BGC_FP64_Vector3* const basic_vector, const BGC_FP64_Vector3* const scalable_vector, const double scale)
|
||||||
{
|
{
|
||||||
difference->x1 = basic_vector->x1 - scalable_vector->x1 * scale;
|
difference->x = basic_vector->x - scalable_vector->x * scale;
|
||||||
difference->x2 = basic_vector->x2 - scalable_vector->x2 * scale;
|
difference->y = basic_vector->y - scalable_vector->y * scale;
|
||||||
difference->x3 = basic_vector->x3 - scalable_vector->x3 * scale;
|
difference->z = basic_vector->z - scalable_vector->z * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_multiply_by_real_number(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const multiplicand, const float multiplier)
|
inline void bgc_fp32_vector3_multiply_by_real_number(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const multiplicand, const float multiplier)
|
||||||
{
|
{
|
||||||
product->x1 = multiplicand->x1 * multiplier;
|
product->x = multiplicand->x * multiplier;
|
||||||
product->x2 = multiplicand->x2 * multiplier;
|
product->y = multiplicand->y * multiplier;
|
||||||
product->x3 = multiplicand->x3 * multiplier;
|
product->z = multiplicand->z * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_multiply_by_real_number(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const multiplicand, const double multiplier)
|
inline void bgc_fp64_vector3_multiply_by_real_number(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const multiplicand, const double multiplier)
|
||||||
{
|
{
|
||||||
product->x1 = multiplicand->x1 * multiplier;
|
product->x = multiplicand->x * multiplier;
|
||||||
product->x2 = multiplicand->x2 * multiplier;
|
product->y = multiplicand->y * multiplier;
|
||||||
product->x3 = multiplicand->x3 * multiplier;
|
product->z = multiplicand->z * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Multiply by Dual Number =========== //
|
// ========== Multiply by Dual Number =========== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
|
inline void bgc_fp32_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
|
||||||
{
|
{
|
||||||
const float real_x1 = multiplicand->x1 * multiplier->real_part;
|
const float real_x = multiplicand->x * multiplier->real_part;
|
||||||
const float real_x2 = multiplicand->x2 * multiplier->real_part;
|
const float real_y = multiplicand->y * multiplier->real_part;
|
||||||
const float real_x3 = multiplicand->x3 * multiplier->real_part;
|
const float real_z = multiplicand->z * multiplier->real_part;
|
||||||
|
|
||||||
const float dual_x1 = multiplicand->x1 * multiplier->dual_part;
|
const float dual_x = multiplicand->x * multiplier->dual_part;
|
||||||
const float dual_x2 = multiplicand->x2 * multiplier->dual_part;
|
const float dual_y = multiplicand->y * multiplier->dual_part;
|
||||||
const float dual_x3 = multiplicand->x3 * multiplier->dual_part;
|
const float dual_z = multiplicand->z * multiplier->dual_part;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->dual_part.x1 = dual_x1;
|
product->dual_part.x = dual_x;
|
||||||
product->dual_part.x2 = dual_x2;
|
product->dual_part.y = dual_y;
|
||||||
product->dual_part.x3 = dual_x3;
|
product->dual_part.z = dual_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
|
inline void bgc_fp64_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
|
||||||
{
|
{
|
||||||
const double real_x1 = multiplicand->x1 * multiplier->real_part;
|
const double real_x = multiplicand->x * multiplier->real_part;
|
||||||
const double real_x2 = multiplicand->x2 * multiplier->real_part;
|
const double real_y = multiplicand->y * multiplier->real_part;
|
||||||
const double real_x3 = multiplicand->x3 * multiplier->real_part;
|
const double real_z = multiplicand->z * multiplier->real_part;
|
||||||
|
|
||||||
const double dual_x1 = multiplicand->x1 * multiplier->dual_part;
|
const double dual_x = multiplicand->x * multiplier->dual_part;
|
||||||
const double dual_x2 = multiplicand->x2 * multiplier->dual_part;
|
const double dual_y = multiplicand->y * multiplier->dual_part;
|
||||||
const double dual_x3 = multiplicand->x3 * multiplier->dual_part;
|
const double dual_z = multiplicand->z * multiplier->dual_part;
|
||||||
|
|
||||||
product->real_part.x1 = real_x1;
|
product->real_part.x = real_x;
|
||||||
product->real_part.x2 = real_x2;
|
product->real_part.y = real_y;
|
||||||
product->real_part.x3 = real_x3;
|
product->real_part.z = real_z;
|
||||||
|
|
||||||
product->dual_part.x1 = dual_x1;
|
product->dual_part.x = dual_x;
|
||||||
product->dual_part.x2 = dual_x2;
|
product->dual_part.y = dual_y;
|
||||||
product->dual_part.x3 = dual_x3;
|
product->dual_part.z = dual_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== Restrict Multiply by Dual Number ====== //
|
// ====== Restrict Multiply by Dual Number ====== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
|
inline void _bgc_fp32_restrict_vector3_multiply_by_dual_number(BGC_FP32_DualVector3* restrict const product, const BGC_FP32_Vector3* const multiplicand, const BGC_FP32_DualNumber* const multiplier)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = multiplicand->x1 * multiplier->real_part;
|
product->real_part.x = multiplicand->x * multiplier->real_part;
|
||||||
product->real_part.x2 = multiplicand->x2 * multiplier->real_part;
|
product->real_part.y = multiplicand->y * multiplier->real_part;
|
||||||
product->real_part.x3 = multiplicand->x3 * multiplier->real_part;
|
product->real_part.z = multiplicand->z * multiplier->real_part;
|
||||||
|
|
||||||
product->dual_part.x1 = multiplicand->x1 * multiplier->dual_part;
|
product->dual_part.x = multiplicand->x * multiplier->dual_part;
|
||||||
product->dual_part.x2 = multiplicand->x2 * multiplier->dual_part;
|
product->dual_part.y = multiplicand->y * multiplier->dual_part;
|
||||||
product->dual_part.x3 = multiplicand->x3 * multiplier->dual_part;
|
product->dual_part.z = multiplicand->z * multiplier->dual_part;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
|
inline void _bgc_fp64_restrict_vector3_multiply_by_dual_number(BGC_FP64_DualVector3* restrict const product, const BGC_FP64_Vector3* const multiplicand, const BGC_FP64_DualNumber* const multiplier)
|
||||||
{
|
{
|
||||||
product->real_part.x1 = multiplicand->x1 * multiplier->real_part;
|
product->real_part.x = multiplicand->x * multiplier->real_part;
|
||||||
product->real_part.x2 = multiplicand->x2 * multiplier->real_part;
|
product->real_part.y = multiplicand->y * multiplier->real_part;
|
||||||
product->real_part.x3 = multiplicand->x3 * multiplier->real_part;
|
product->real_part.z = multiplicand->z * multiplier->real_part;
|
||||||
|
|
||||||
product->dual_part.x1 = multiplicand->x1 * multiplier->dual_part;
|
product->dual_part.x = multiplicand->x * multiplier->dual_part;
|
||||||
product->dual_part.x2 = multiplicand->x2 * multiplier->dual_part;
|
product->dual_part.y = multiplicand->y * multiplier->dual_part;
|
||||||
product->dual_part.x3 = multiplicand->x3 * multiplier->dual_part;
|
product->dual_part.z = multiplicand->z * multiplier->dual_part;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_multiply_by_matrix2x3(BGC_FP32_Vector2* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix2x3* const matrix)
|
inline void bgc_fp32_vector3_multiply_by_matrix2x3(BGC_FP32_Vector2* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix2x3* const matrix)
|
||||||
{
|
{
|
||||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
|
||||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_multiply_by_matrix2x3(BGC_FP64_Vector2* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix2x3* const matrix)
|
inline void bgc_fp64_vector3_multiply_by_matrix2x3(BGC_FP64_Vector2* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix2x3* const matrix)
|
||||||
{
|
{
|
||||||
product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
product->x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
|
||||||
product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
product->y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_multiply_by_matrix3x3(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
inline void bgc_fp32_vector3_multiply_by_matrix3x3(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector, const BGC_FP32_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
const float x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
|
||||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
const float y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
|
||||||
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
const float z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3 + vector->z * matrix->r3c3;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_multiply_by_matrix3x3(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
inline void bgc_fp64_vector3_multiply_by_matrix3x3(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector, const BGC_FP64_Matrix3x3* const matrix)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
const double x = vector->x * matrix->r1c1 + vector->y * matrix->r2c1 + vector->z * matrix->r3c1;
|
||||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
const double y = vector->x * matrix->r1c2 + vector->y * matrix->r2c2 + vector->z * matrix->r3c2;
|
||||||
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
const double z = vector->x * matrix->r1c3 + vector->y * matrix->r2c3 + vector->z * matrix->r3c3;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Divide =================== //
|
// =================== Divide =================== //
|
||||||
|
|
@ -357,32 +357,32 @@ inline int bgc_fp64_vector3_divide_by_real_number(BGC_FP64_Vector3* const quotie
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
|
mean->x = (vector1->x + vector2->x) * 0.5f;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f;
|
mean->y = (vector1->y + vector2->y) * 0.5f;
|
||||||
mean->x3 = (vector1->x3 + vector2->x3) * 0.5f;
|
mean->z = (vector1->z + vector2->z) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1) * 0.5;
|
mean->x = (vector1->x + vector2->x) * 0.5;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2) * 0.5;
|
mean->y = (vector1->y + vector2->y) * 0.5;
|
||||||
mean->x3 = (vector1->x3 + vector2->x3) * 0.5;
|
mean->z = (vector1->z + vector2->z) * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Average3 ================== //
|
// ================== Average3 ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_get_mean3(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const vector3)
|
inline void bgc_fp32_vector3_get_mean3(BGC_FP32_Vector3* const mean, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const vector3)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
|
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP32_ONE_THIRD;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
|
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP32_ONE_THIRD;
|
||||||
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD;
|
mean->z = (vector1->z + vector2->z + vector3->z) * BGC_FP32_ONE_THIRD;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_get_mean3(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const vector3)
|
inline void bgc_fp64_vector3_get_mean3(BGC_FP64_Vector3* const mean, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const vector3)
|
||||||
{
|
{
|
||||||
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
|
mean->x = (vector1->x + vector2->x + vector3->x) * BGC_FP64_ONE_THIRD;
|
||||||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
|
mean->y = (vector1->y + vector2->y + vector3->y) * BGC_FP64_ONE_THIRD;
|
||||||
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD;
|
mean->z = (vector1->z + vector2->z + vector3->z) * BGC_FP64_ONE_THIRD;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Linear =================== //
|
// =================== Linear =================== //
|
||||||
|
|
@ -391,48 +391,48 @@ inline void bgc_fp32_vector3_interpolate(BGC_FP32_Vector3* const interpolation,
|
||||||
{
|
{
|
||||||
const float counter_phase = 1.0f - phase;
|
const float counter_phase = 1.0f - phase;
|
||||||
|
|
||||||
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
|
interpolation->x = first->x * counter_phase + second->x * phase;
|
||||||
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
|
interpolation->y = first->y * counter_phase + second->y * phase;
|
||||||
interpolation->x3 = first->x3 * counter_phase + second->x3 * phase;
|
interpolation->z = first->z * counter_phase + second->z * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_interpolate(BGC_FP64_Vector3* const interpolation, const BGC_FP64_Vector3* const first, const BGC_FP64_Vector3* const second, const double phase)
|
inline void bgc_fp64_vector3_interpolate(BGC_FP64_Vector3* const interpolation, const BGC_FP64_Vector3* const first, const BGC_FP64_Vector3* const second, const double phase)
|
||||||
{
|
{
|
||||||
const double counter_phase = 1.0 - phase;
|
const double counter_phase = 1.0 - phase;
|
||||||
|
|
||||||
interpolation->x1 = first->x1 * counter_phase + second->x1 * phase;
|
interpolation->x = first->x * counter_phase + second->x * phase;
|
||||||
interpolation->x2 = first->x2 * counter_phase + second->x2 * phase;
|
interpolation->y = first->y * counter_phase + second->y * phase;
|
||||||
interpolation->x3 = first->x3 * counter_phase + second->x3 * phase;
|
interpolation->z = first->z * counter_phase + second->z * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Negative ================== //
|
// ================== Negative ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* const vector)
|
inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = -vector->x1;
|
vector->x = -vector->x;
|
||||||
vector->x2 = -vector->x2;
|
vector->y = -vector->y;
|
||||||
vector->x3 = -vector->x3;
|
vector->z = -vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* const vector)
|
inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
vector->x1 = -vector->x1;
|
vector->x = -vector->x;
|
||||||
vector->x2 = -vector->x2;
|
vector->y = -vector->y;
|
||||||
vector->x3 = -vector->x3;
|
vector->z = -vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_get_reverse(BGC_FP32_Vector3* const reverse, const BGC_FP32_Vector3* const vector)
|
inline void bgc_fp32_vector3_get_reverse(BGC_FP32_Vector3* const reverse, const BGC_FP32_Vector3* const vector)
|
||||||
{
|
{
|
||||||
reverse->x1 = -vector->x1;
|
reverse->x = -vector->x;
|
||||||
reverse->x2 = -vector->x2;
|
reverse->y = -vector->y;
|
||||||
reverse->x3 = -vector->x3;
|
reverse->z = -vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_get_reverse(BGC_FP64_Vector3* const reverse, const BGC_FP64_Vector3* const vector)
|
inline void bgc_fp64_vector3_get_reverse(BGC_FP64_Vector3* const reverse, const BGC_FP64_Vector3* const vector)
|
||||||
{
|
{
|
||||||
reverse->x1 = -vector->x1;
|
reverse->x = -vector->x;
|
||||||
reverse->x2 = -vector->x2;
|
reverse->y = -vector->y;
|
||||||
reverse->x3 = -vector->x3;
|
reverse->z = -vector->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Normalize ================== //
|
// ================= Normalize ================== //
|
||||||
|
|
@ -451,9 +451,9 @@ inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* const vector)
|
||||||
|
|
||||||
const float multiplier = sqrtf(1.0f / square_modulus);
|
const float multiplier = sqrtf(1.0f / square_modulus);
|
||||||
|
|
||||||
vector->x1 *= multiplier;
|
vector->x *= multiplier;
|
||||||
vector->x2 *= multiplier;
|
vector->y *= multiplier;
|
||||||
vector->x3 *= multiplier;
|
vector->z *= multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -472,9 +472,9 @@ inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* const vector)
|
||||||
|
|
||||||
const double multiplier = sqrt(1.0 / square_modulus);
|
const double multiplier = sqrt(1.0 / square_modulus);
|
||||||
|
|
||||||
vector->x1 *= multiplier;
|
vector->x *= multiplier;
|
||||||
vector->x2 *= multiplier;
|
vector->y *= multiplier;
|
||||||
vector->x3 *= multiplier;
|
vector->z *= multiplier;
|
||||||
|
|
||||||
return BGC_SUCCESS;
|
return BGC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
@ -519,68 +519,68 @@ inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* const normalized, c
|
||||||
|
|
||||||
inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
|
return vector1->x * vector2->x + vector1->y * vector2->y + vector1->z * vector2->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
|
return vector1->x * vector2->x + vector1->y * vector2->y + vector1->z * vector2->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Triple Product =============== //
|
// =============== Triple Product =============== //
|
||||||
|
|
||||||
inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const vector3)
|
inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2, const BGC_FP32_Vector3* const vector3)
|
||||||
{
|
{
|
||||||
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
|
return vector1->x * (vector2->y * vector3->z - vector2->z * vector3->y)
|
||||||
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
|
+ vector1->y * (vector2->z * vector3->x - vector2->x * vector3->z)
|
||||||
+ vector1->x3 * (vector2->x1 * vector3->x2 - vector2->x2 * vector3->x1);
|
+ vector1->z * (vector2->x * vector3->y - vector2->y * vector3->x);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const vector3)
|
inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2, const BGC_FP64_Vector3* const vector3)
|
||||||
{
|
{
|
||||||
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
|
return vector1->x * (vector2->y * vector3->z - vector2->z * vector3->y)
|
||||||
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
|
+ vector1->y * (vector2->z * vector3->x - vector2->x * vector3->z)
|
||||||
+ vector1->x3 * (vector2->x1 * vector3->x2 - vector2->x2 * vector3->x1);
|
+ vector1->z * (vector2->x * vector3->y - vector2->y * vector3->x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========== Restrict Cross Product =========== //
|
// =========== Restrict Cross Product =========== //
|
||||||
|
|
||||||
inline void _bgc_fp32_restrict_vector3_get_cross_product(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline void _bgc_fp32_restrict_vector3_get_cross_product(BGC_FP32_Vector3* restrict const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
product->x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
product->x = vector1->y * vector2->z - vector1->z * vector2->y;
|
||||||
product->x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
product->y = vector1->z * vector2->x - vector1->x * vector2->z;
|
||||||
product->x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
product->z = vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _bgc_fp64_restrict_vector3_get_cross_product(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline void _bgc_fp64_restrict_vector3_get_cross_product(BGC_FP64_Vector3* restrict const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
product->x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
product->x = vector1->y * vector2->z - vector1->z * vector2->y;
|
||||||
product->x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
product->y = vector1->z * vector2->x - vector1->x * vector2->z;
|
||||||
product->x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
product->z = vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Cross Product ================ //
|
// =============== Cross Product ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_vector3_get_cross_product(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline void bgc_fp32_vector3_get_cross_product(BGC_FP32_Vector3* const product, const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
const float x = vector1->y * vector2->z - vector1->z * vector2->y;
|
||||||
const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
const float y = vector1->z * vector2->x - vector1->x * vector2->z;
|
||||||
const float x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
const float z = vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* const product, const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
|
const double x = vector1->y * vector2->z - vector1->z * vector2->y;
|
||||||
const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
|
const double y = vector1->z * vector2->x - vector1->x * vector2->z;
|
||||||
const double x3 = vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
|
const double z = vector1->x * vector2->y - vector1->y * vector2->x;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x = x;
|
||||||
product->x2 = x2;
|
product->y = y;
|
||||||
product->x3 = x3;
|
product->z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Double Cross Product ============ //
|
// ============ Double Cross Product ============ //
|
||||||
|
|
@ -591,9 +591,9 @@ inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* const product, c
|
||||||
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
|
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
|
||||||
const float ab = bgc_fp32_vector3_get_dot_product(vector1, vector2);
|
const float ab = bgc_fp32_vector3_get_dot_product(vector1, vector2);
|
||||||
|
|
||||||
product->x1 = vector2->x1 * ac - vector3->x1 * ab;
|
product->x = vector2->x * ac - vector3->x * ab;
|
||||||
product->x2 = vector2->x2 * ac - vector3->x2 * ab;
|
product->y = vector2->y * ac - vector3->y * ab;
|
||||||
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
|
product->z = vector2->z * ac - vector3->z * ab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [a x [b x c]] = b * (a, c) - c * (a, b)
|
// [a x [b x c]] = b * (a, c) - c * (a, b)
|
||||||
|
|
@ -602,9 +602,9 @@ inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* const product, c
|
||||||
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
|
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
|
||||||
const double ab = bgc_fp64_vector3_get_dot_product(vector1, vector2);
|
const double ab = bgc_fp64_vector3_get_dot_product(vector1, vector2);
|
||||||
|
|
||||||
product->x1 = vector2->x1 * ac - vector3->x1 * ab;
|
product->x = vector2->x * ac - vector3->x * ab;
|
||||||
product->x2 = vector2->x2 * ac - vector3->x2 * ab;
|
product->y = vector2->y * ac - vector3->y * ab;
|
||||||
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
|
product->z = vector2->z * ac - vector3->z * ab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== Alternative Double Cross Product ====== //
|
// ====== Alternative Double Cross Product ====== //
|
||||||
|
|
@ -615,9 +615,9 @@ inline void bgc_fp32_vector3_get_alternative_double_cross(BGC_FP32_Vector3* cons
|
||||||
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
|
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
|
||||||
const float bc = bgc_fp32_vector3_get_dot_product(vector2, vector3);
|
const float bc = bgc_fp32_vector3_get_dot_product(vector2, vector3);
|
||||||
|
|
||||||
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
|
product->x = vector2->x * ac - vector1->x * bc;
|
||||||
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
|
product->y = vector2->y * ac - vector1->y * bc;
|
||||||
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
|
product->z = vector2->z * ac - vector1->z * bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [[a x b] x c] = - [c x [a x b]] = -(a * (b, c) - b * (a, c)) = b * (a, c) - a * (b, c)
|
// [[a x b] x c] = - [c x [a x b]] = -(a * (b, c) - b * (a, c)) = b * (a, c) - a * (b, c)
|
||||||
|
|
@ -626,9 +626,9 @@ inline void bgc_fp64_vector3_get_alternative_double_cross(BGC_FP64_Vector3* cons
|
||||||
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
|
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
|
||||||
const double bc = bgc_fp64_vector3_get_dot_product(vector2, vector3);
|
const double bc = bgc_fp64_vector3_get_dot_product(vector2, vector3);
|
||||||
|
|
||||||
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
|
product->x = vector2->x * ac - vector1->x * bc;
|
||||||
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
|
product->y = vector2->y * ac - vector1->y * bc;
|
||||||
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
|
product->z = vector2->z * ac - vector1->z * bc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Angle ==================== //
|
// =================== Angle ==================== //
|
||||||
|
|
@ -641,20 +641,20 @@ double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* const vector1, const B
|
||||||
|
|
||||||
inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* const vector1, const BGC_FP32_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const float dx1 = (vector1->x1 - vector2->x1);
|
const float dx = (vector1->x - vector2->x);
|
||||||
const float dx2 = (vector1->x2 - vector2->x2);
|
const float dy = (vector1->y - vector2->y);
|
||||||
const float dx3 = (vector1->x3 - vector2->x3);
|
const float dz = (vector1->z - vector2->z);
|
||||||
|
|
||||||
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* const vector1, const BGC_FP64_Vector3* const vector2)
|
||||||
{
|
{
|
||||||
const double dx1 = (vector1->x1 - vector2->x1);
|
const double dx = (vector1->x - vector2->x);
|
||||||
const double dx2 = (vector1->x2 - vector2->x2);
|
const double dy = (vector1->y - vector2->y);
|
||||||
const double dx3 = (vector1->x3 - vector2->x3);
|
const double dz = (vector1->z - vector2->z);
|
||||||
|
|
||||||
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Distance ================== //
|
// ================== Distance ================== //
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,17 @@
|
||||||
|
|
||||||
### Prefixes
|
### Prefixes
|
||||||
|
|
||||||
The library uses prefixes in names of types, constants and functions.
|
C programming language does not have namespaces, thus prefixes often play role
|
||||||
|
of namespaces in C code.
|
||||||
|
|
||||||
|
The library uses prefixes in names of types, constants and functions to avoid
|
||||||
|
name conflict with of othr libraries.
|
||||||
|
|
||||||
The main prefix is **BGC** which means **B**asic **G**eometric **C**omputations.
|
The main prefix is **BGC** which means **B**asic **G**eometric **C**omputations.
|
||||||
|
|
||||||
The structure types have prefix in the form **Bgc**. For example: BgcVector3FP64,
|
The structure types and contstans have prefix in the form **Bgc**. For example:
|
||||||
BgcVersorFP32, BgcMatrix2x2FP32.
|
BgcVector3FP64, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
|
||||||
|
BGC_FP64_TWO_PI.
|
||||||
|
|
||||||
The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32,
|
The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32,
|
||||||
BGC_TWO_PI_FP64.
|
BGC_TWO_PI_FP64.
|
||||||
|
|
@ -31,29 +36,19 @@ Thus there are two suffixes of types:
|
||||||
* **FP64** - means **F**loating **P**oint, **64** bit, which corresponds to the
|
* **FP64** - means **F**loating **P**oint, **64** bit, which corresponds to the
|
||||||
**double** type of the C language.
|
**double** type of the C language.
|
||||||
|
|
||||||
The types of structures which are based in the **float** type have **FP32** as
|
The constants and the types of structures which are based in the **float** type
|
||||||
the type prefix: BgcVector3FP32, BgcMatrix3x2FP32, BgcQuaternionFP32.
|
have **FP32** as the type prefix: BGC_FP32_Vector3, BGC_FP32_Matrix3x2,
|
||||||
|
BGC_FP32_Quaternion, BGC_FP32_PI, BGC_FP32_EPSILON.
|
||||||
|
|
||||||
The types of structures which are based in the **double** type have **FP64** as
|
The constants and the types of structures which are based in the **double** type
|
||||||
the type prefix: BgcVector2FP64, BgcMatrix2x3FP64, BgcVersorFP64.
|
have **FP64** as the type prefix: BGC_FP64_Vector2, BGC_FP64_Matrix2x3,
|
||||||
|
BGC_FP64_Turn3, BGC_FP64_HALF_PI, BGC_FP64_ONE_THIRD.
|
||||||
The constants of the **float** type have **_FP32** as the type suffix:
|
|
||||||
BGC_PI_FP32, BGC_EPSYLON_FP32.
|
|
||||||
|
|
||||||
The constants of the **double** type have **_FP64** as the type suffix:
|
|
||||||
BGC_HALF_PI_FP64, BGC_ONE_THIRD_FP64.
|
|
||||||
|
|
||||||
The functions which works with data of the **float** type have **_fp32** as
|
The functions which works with data of the **float** type have **_fp32** as
|
||||||
the type suffix: bgc_vector2_get_modulus_fp64, bgc_radians_to_degrees_fp32.
|
the type suffix: bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
|
||||||
|
|
||||||
The functions which works with data of the **double** type have **_fp64** as
|
The functions which works with data of the **double** type have **_fp64** as
|
||||||
the type suffix: bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
|
the type suffix: bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
|
||||||
|
|
||||||
## Entities
|
|
||||||
|
|
||||||
- [Angles](angle-eng.md)
|
|
||||||
- [Vectors 2D](vector2-eng.md)
|
|
||||||
- [Vectors 3D](vector3-eng.md)
|
|
||||||
- [Quaternions](quaternion-eng.md)
|
|
||||||
- [Versors](versor-eng.md)
|
|
||||||
|
|
||||||
|
Using of such prefixes of a basic type allows to enhance the library with new
|
||||||
|
basic types in future.
|
||||||
|
|
@ -4,26 +4,27 @@
|
||||||
|
|
||||||
### Префиксы
|
### Префиксы
|
||||||
|
|
||||||
Библиотека использует префиксы в названиях типов, констант и функций.
|
В языке программирования C (Си) нет пространств имён, потому роль пространств
|
||||||
|
имён играют префиксы в названиях.
|
||||||
|
|
||||||
|
Библиотека использует префиксы в названиях типов, констант и функций для
|
||||||
|
того, чтобы избежать конфликтов в названиях констант, типов и функций с другими
|
||||||
|
библиотеками.
|
||||||
|
|
||||||
Основным префиксом является **BGC** (сокращение от **B**asic **G**eometric
|
Основным префиксом является **BGC** (сокращение от **B**asic **G**eometric
|
||||||
**C**omputations / Базовые Геометрие Вычисления).
|
**C**omputations / Базовые Геометрие Вычисления).
|
||||||
|
|
||||||
Для структур данных префикс имеет вид **Bgc**, например: BgcVector3FP64,
|
Для констант и структур данных префикс имеет вид **BGC_**, например:
|
||||||
BgcVersorFP32, BgcMatrix2x2FP32.
|
BgcVector3FP64, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
|
||||||
|
BGC_FP64_TWO_PI.
|
||||||
|
|
||||||
Константы имеют префикс в виде **BGC_**, например: BGC_EPSYLON_FP32,
|
Функции имеют префикс в виде **bgc_**, например: bgc_fp32_turn3_combine,
|
||||||
BGC_TWO_PI_FP64.
|
bgc_fp64_matrix3x3_subtract.
|
||||||
|
|
||||||
Функции имеют префикс в виде **bgc_**, например: bgc_versor_combine_fp32,
|
После префикса библиотеки идёт префикс базового типа.
|
||||||
bgc_matrix3x3_subtract_fp64.
|
|
||||||
|
|
||||||
### Cуффиксы
|
Библиотека использует два типа чисел с плавающей запятой: **float** и **double**
|
||||||
|
(типы **binary32** и **binary64** стандарта **IEEE 754**).
|
||||||
Названия констант, типов и функций оканчиваются суффиксом, указывающим на
|
|
||||||
базовый тип. Библиотека использует два типа чисел с плавающей запятой:
|
|
||||||
**float** и **double** (типы **binary32** и **binary64** стандарта
|
|
||||||
**IEEE 754**).
|
|
||||||
|
|
||||||
Поэтому в библиотеке есть два префикса типа:
|
Поэтому в библиотеке есть два префикса типа:
|
||||||
|
|
||||||
|
|
@ -33,27 +34,19 @@ bgc_matrix3x3_subtract_fp64.
|
||||||
* **FP64** - означает **F**loating **P**oint **64** bit, то есть, число с
|
* **FP64** - означает **F**loating **P**oint **64** bit, то есть, число с
|
||||||
плавающей запятой, 64 бита, что соответствует типу **double** языка Си.
|
плавающей запятой, 64 бита, что соответствует типу **double** языка Си.
|
||||||
|
|
||||||
Типы структур, использующие тип **float** имеют суффикс **FP32**:
|
Типы структур и константы, основанные на типе **float** имеют префикс **FP32_**:
|
||||||
BgcVector3FP32, BgcMatrix3x2FP32, BgcQuaternionFP32
|
BGC_FP32_Vector3, BGC_FP32_Matrix3x2, BGC_FP32_Quaternion, BGC_FP32_PI,
|
||||||
|
BGC_FP32_EPSILON.
|
||||||
|
|
||||||
Типы структур, использующие тип **double** имеют суффикс **FP64**:
|
Типы структур и константы, основанные на типе **double** имеют префикс
|
||||||
BgcVector2FP64, BgcMatrix2x3FP64, BgcVersorFP64
|
**FP64_**: BGC_FP64_Vector2, BGC_FP64_Matrix2x3, BGC_FP64_Turn3,
|
||||||
|
BGC_FP64_HALF_PI, BGC_FP64_ONE_THIRD.
|
||||||
Константы типа **float** имеют суффикс **_FP32**: BGC_PI_FP32, BGC_EPSYLON_FP32.
|
|
||||||
|
|
||||||
Константы типа **double** имеют суффикс **_FP64**: BGC_HALF_PI_FP64,
|
|
||||||
BGC_ONE_THIRD_FP64.
|
|
||||||
|
|
||||||
Функции, которые работают с данными типа **float** имеют суффикс **_fp32**:
|
Функции, которые работают с данными типа **float** имеют суффикс **_fp32**:
|
||||||
bcg_vector2_get_modulus_fp32, bgc_radians_to_degrees_fp32.
|
bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
|
||||||
|
|
||||||
Функции, которые работают с данными типа **double** имеют суффикс **_fp64**:
|
Функции, которые работают с данными типа **double** имеют суффикс **_fp64**:
|
||||||
bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
|
bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
|
||||||
|
|
||||||
## Сущности
|
Использование подобных префиксов позволяет расширять библиотеку используя новые
|
||||||
|
новые базовые типы в будущем.
|
||||||
- [Углы](angle-rus.md)
|
|
||||||
- [2D векторы](vector2-rus.md)
|
|
||||||
- [3D векторы](vector2-rus.md)
|
|
||||||
- [Кватернионы](quaternion-rus.md)
|
|
||||||
- [Версоры](versor-rus.md)
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
# Three-dimensional vectors
|
# Three-dimensional vectors
|
||||||
|
|
||||||
There are two types of 3D vectors in the library:
|
There are two types of 3D vectors in the library:
|
||||||
- **BgcVector3FP32** - vector using single-precision floating-point numbers
|
- **BGC_FP32_Vector3** - vector using single-precision floating-point numbers
|
||||||
- **BgcVector3FP64** - vector using double-precision floating-point numbers
|
- **BGC_FP64_Vector3** - vector using double-precision floating-point numbers
|
||||||
|
|
||||||
Structure definitions:
|
Structure definitions:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float x1, x2, x3;
|
float x, y, z;
|
||||||
} BgcVector3FP32;
|
} BGC_FP32_Vector3;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double x1, x2, x3;
|
double x, y, z;
|
||||||
} BgcVector3FP64;
|
} BGC_FP64_Vector3;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,32 @@
|
||||||
# Трёхмерные векторы векторы
|
# Трёхмерные векторы векторы
|
||||||
|
|
||||||
В библиотеке есть два типа двумерных векторов:
|
В библиотеке есть два типа трёхмерных векторов:
|
||||||
- **BgcVector3FP32** - вектор с использованием чисел с плавающей запятой одинарной точности
|
- **BGC_FP32_Vector3** - вектор с использованием чисел с плавающей запятой
|
||||||
- **BgcVector3FP64** - вектор с использованием чисел с плавающей запятой двойной точности
|
одинарной точности
|
||||||
|
- **BGC_FP64_Vector3** - вектор с использованием чисел с плавающей запятой
|
||||||
|
двойной точности
|
||||||
|
|
||||||
Определения структур:
|
Определения структур:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float x1, x2, x3;
|
float x, y, z;
|
||||||
} BgcVector3FP32;
|
} BGC_FP32_Vector3;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double x1, x2, x3;
|
double x, y, z;
|
||||||
} BgcVector3FP64;
|
} BGC_FP64_Vector3;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Функции
|
## Функции
|
||||||
|
|
||||||
| Функции для BgcVector3FP32 | Функции для BgcVector3FP64 |
|
| Функции для BgcVector3FP32 | Функции для BgcVector3FP64 |
|
||||||
|:-------------------------------------------------------------:|:-------------------------------------------------------------:|
|
|:-------------------------------------------------------------:|:-------------------------------------------------------------:|
|
||||||
| [bgc_vector3_reset_fp32](vector3/reset-rus.md) | [bgc_vector3_reset_fp64](vector3/reset-rus.md) |
|
| [bgc_fp32_vector3_reset](vector3/reset-rus.md) | [bgc_fp64_vector3_reset](vector3/reset-rus.md) |
|
||||||
| [bgc_vector3_set_values_fp32](vector3/set-values-rus.md) | [bgc_vector3_set_values_fp64](vector3/set-values-rus.md) |
|
| [bgc_fp32_vector3_set_values](vector3/set-values-rus.md) | [bgc_fp64_vector3_set_values](vector3/set-values-rus.md) |
|
||||||
| [bgc_vector3_copy_fp32](vector3/copy-rus.md) | [bgc_vector3_copy_fp64](vector3/copy-rus.md) |
|
| [bgc_fp32_vector3_copy](vector3/copy-rus.md) | [bgc_fp64_vector3_copy](vector3/copy-rus.md) |
|
||||||
| [bgc_vector3_swap_fp32](vector3/swap-rus.md) | [bgc_vector3_swap_fp64](vector3/swap-rus.md) |
|
| [bgc_fp32_vector3_swap](vector3/swap-rus.md) | [bgc_fp64_vector3_swap](vector3/swap-rus.md) |
|
||||||
|
|
||||||
[Документация](intro-rus.md)
|
[Документация](intro-rus.md)
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,39 @@
|
||||||
# Copying
|
# Copying
|
||||||
|
|
||||||
The copy functions allow you to copy the coordinate values of one vector to another vector.
|
The copy functions allow you to copy the coordinate values of one vector
|
||||||
|
to another vector.
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to);
|
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source);
|
||||||
```
|
```
|
||||||
|
|
||||||
Function for **BgcVector3FP64**:
|
Function for **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to);
|
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
|
||||||
```
|
```
|
||||||
|
|
||||||
Each of these functions is equivalent to the following lines of code:
|
Each of these functions is equivalent to the following lines of code:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
to->x1 = from->x1;
|
destination->x = source->x;
|
||||||
to->x2 = from->x2;
|
destination->y = source->y;
|
||||||
to->x3 = from->x3;
|
destination->z = source->z;
|
||||||
```
|
```
|
||||||
|
|
||||||
The **from** and **to** parameters must not be invalid pointers. The NULL (0) value is also considered invalid.
|
The **source** and **destination** parameters must not be invalid pointers.
|
||||||
|
The NULL (0) value is also considered invalid.
|
||||||
|
|
||||||
The **from** parameter must be a pointer to a three-dimensional vector whose coordinates are to be copied. The coordinates of the **from** vector will not change after the function call.
|
The **source** parameter must be a pointer to a three-dimensional vector whose
|
||||||
|
coordinates are to be copied. The coordinates of the **source** vector will
|
||||||
|
not change after the function call.
|
||||||
|
|
||||||
The **to** parameter must be a pointer to a three-dimensional vector whose coordinates are to be changed. The coordinates of the **to** vector will become the same as those of the **from** vector after the function call.
|
The **destination** parameter must be a pointer to a three-dimensional vector
|
||||||
|
whose coordinates are to be changed. The coordinates of the **destination**
|
||||||
|
vector will become the same as those of the **source** vector after the function
|
||||||
|
call.
|
||||||
|
|
||||||
Example of use:
|
Example of use:
|
||||||
|
|
||||||
|
|
@ -36,13 +43,15 @@ Example of use:
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector1, my_vector3;
|
BGC_FP32_Vector3 my_vector1, my_vector2;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1);
|
my_vector1.x = -2.0f;
|
||||||
|
my_vector1.y = 7.4f;
|
||||||
|
my_vector1.z = 1.8f;
|
||||||
|
|
||||||
bgc_vector3_copy_fp32(&my_vector1, &my_vector3);
|
bgc_fp32_vector3_copy(&my_vector2, &my_vector1);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,38 @@
|
||||||
# Копирование
|
# Копирование
|
||||||
|
|
||||||
Функции копирования позволяют скопировать значения координат одного вектора в другой вектор.
|
Ôóíêöèè êîïèðîâàíèÿ ïîçâîëÿþò ñêîïèðîâàòü çíà÷åíèÿ êîîðäèíàò îäíîãî âåêòîðà
|
||||||
|
â äðóãîé âåêòîð.
|
||||||
|
|
||||||
Функция для **BgcVector3FP32**:
|
Ôóíêöèÿ äëÿ **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to);
|
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source);
|
||||||
```
|
```
|
||||||
|
|
||||||
Функция для **BgcVector3FP64**:
|
Ôóíêöèÿ äëÿ **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to);
|
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
|
||||||
```
|
```
|
||||||
|
|
||||||
Каждая из данных функции эквивалентна следующим строкам кода:
|
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
to->x1 = from->x1;
|
destination->x = source->x;
|
||||||
to->x2 = from->x2;
|
destination->y = source->y;
|
||||||
to->x3 = from->x3;
|
destination->z = source->z;
|
||||||
```
|
```
|
||||||
|
|
||||||
Параметры **from** и **to** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным.
|
Ïàðàìåòðû **source** è **destination** íå äîëæíû áûòü íåêîððåêòíûìè óêàçàòåëÿìè.
|
||||||
|
Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
|
||||||
|
|
||||||
Параметр **from** должен быть указателем на трёхмерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции.
|
Ïàðàìåòð **source** äîëæåí áûòü óêàçàòåëåì íà òð¸õìåðíûé âåêòîð, êîîðäèíàòû
|
||||||
|
êîòîðîãî äîëæíû áûòü ñêîïèðîâàíû. Êîîðäèíàòû âåêòîðà **source** íå èçìåíÿòñÿ
|
||||||
|
ïîñëå âûçîâà ôóíêöèè.
|
||||||
|
|
||||||
Параметр **to** должен быть указателем на трёхмерный вектор, координаты которого должны быть изменены. Координаты вектора **to** после вызова функции станут такими же, как и у вектора **from**.
|
Ïàðàìåòð **destination** äîëæåí áûòü óêàçàòåëåì íà òð¸õìåðíûé âåêòîð, êîîðäèíàòû
|
||||||
|
êîòîðîãî äîëæíû áûòü èçìåíåíû. Êîîðäèíàòû âåêòîðà **destination** ïîñëå âûçîâà
|
||||||
|
ôóíêöèè ñòàíóò òàêèìè æå, êàê è ó âåêòîðà **source**.
|
||||||
|
|
||||||
Пример применения:
|
Пример применения:
|
||||||
|
|
||||||
|
|
@ -36,13 +42,15 @@ to->x3 = from->x3;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector1, my_vector3;
|
BGC_FP32_Vector3 my_vector1, my_vector2;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1);
|
my_vector1.x = -2.0f;
|
||||||
|
my_vector1.y = 7.4f;
|
||||||
|
my_vector1.z = 1.8f;
|
||||||
|
|
||||||
bgc_vector3_copy_fp32(&my_vector1, &my_vector3);
|
bgc_fp32_vector3_copy(&my_vector2, &my_vector1);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,30 @@
|
||||||
|
|
||||||
These functions set all coordinates of 3D vectors to 0.
|
These functions set all coordinates of 3D vectors to 0.
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector);
|
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
|
||||||
```
|
```
|
||||||
|
|
||||||
Function for **BgcVector3FP64**:
|
Function for **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector);
|
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
|
||||||
```
|
```
|
||||||
|
|
||||||
Each of these functions is equivalent to the following lines of code:
|
Each of these functions is equivalent to the following lines of code:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
vector->x1 = 0;
|
vector->x = 0;
|
||||||
vector->x2 = 0;
|
vector->y = 0;
|
||||||
vector->x3 = 0;
|
vector->z = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid.
|
You should not pass invalid pointers to these functions. The NULL (0) value is
|
||||||
|
also considered invalid.
|
||||||
|
|
||||||
|
This function is good for setting up the initial state of a 3D vector.
|
||||||
|
|
||||||
Example of use:
|
Example of use:
|
||||||
|
|
||||||
|
|
@ -32,11 +35,11 @@ Example of use:
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector;
|
BGC_FP32_Vector3 my_vector;
|
||||||
|
|
||||||
bgc_vector3_reset_fp32(&my_vector);
|
bgc_fp32_vector3_reset(&my_vector);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,30 @@
|
||||||
|
|
||||||
Функции устанавливают значение 0 всем координатам трёхмерных векторов.
|
Функции устанавливают значение 0 всем координатам трёхмерных векторов.
|
||||||
|
|
||||||
Ôóíêöèÿ äëÿ **BgcVector3FP32**:
|
Ôóíêöèÿ äëÿ **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector);
|
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
|
||||||
```
|
```
|
||||||
|
|
||||||
Ôóíêöèÿ äëÿ **BgcVector3FP64**:
|
Ôóíêöèÿ äëÿ **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector);
|
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
|
||||||
```
|
```
|
||||||
|
|
||||||
Каждая из данных функции эквивалентна следующим строкам кода:
|
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
vector->x1 = 0;
|
vector->x = 0;
|
||||||
vector->x2 = 0;
|
vector->y = 0;
|
||||||
vector->x3 = 0;
|
vector->z = 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
|
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0)
|
||||||
|
òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
|
||||||
|
|
||||||
|
Äàííàÿ ôóíêöèÿ õîðîøî ïîäõîäèò äëÿ èíèöèàëèçàöèè íà÷àëüíîãî ñîñòîÿíèÿ âåêòîðà.
|
||||||
|
|
||||||
Пример применения:
|
Пример применения:
|
||||||
|
|
||||||
|
|
@ -32,11 +35,11 @@ vector->x3 = 0;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector;
|
BGC_FP32_Vector3 my_vector;
|
||||||
|
|
||||||
bgc_vector3_reset_fp32(&my_vector);
|
bgc_fp32_vector3_reset(&my_vector);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,34 @@
|
||||||
# Setting the coordinates of a three-dimensional vector
|
# Setting the coordinates of a three-dimensional vector
|
||||||
|
|
||||||
You can set the coordinates of vectors either directly or using functions. The functions for setting coordinate values allow you to do this in one line.
|
You can set the coordinates of vectors either directly or using functions.
|
||||||
|
The functions for setting coordinate values allow you to do this in one line.
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to);
|
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
|
||||||
```
|
```
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to);
|
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
|
||||||
```
|
```
|
||||||
|
|
||||||
Each of these functions is equivalent to the following lines of code:
|
Each of these functions is equivalent to the following lines of code:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
to->x1 = x1;
|
destination->x = x;
|
||||||
to->x2 = x2;
|
destination->y = y;
|
||||||
to->x3 = x3;
|
destination->z = z;
|
||||||
```
|
```
|
||||||
|
|
||||||
Invalid pointers should not be passed in the **to** parameter. The NULL (0) value is also considered invalid.
|
Invalid pointers should not be passed in the **destination** parameter.
|
||||||
|
The NULL (0) value is also considered invalid.
|
||||||
|
|
||||||
|
This function is good for setting up the initial values of coordinates with
|
||||||
|
one-line especially when the values are fixed constants like in the example
|
||||||
|
below.
|
||||||
|
|
||||||
Example of use:
|
Example of use:
|
||||||
|
|
||||||
|
|
@ -32,11 +38,11 @@ Example of use:
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector;
|
BGC_FP32_Vector3 my_vector;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector);
|
bgc_fp32_vector3_set_values(&my_vector, -2.2f, 7.1f, 10.01f);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,35 @@
|
||||||
# Задание координат трёхмерного вектора
|
# Указание координат трёхмерного вектора
|
||||||
|
|
||||||
Задавать координаты векторов можно как напрямую, так и спомощью функций. Функции задания значений координат позволяют сделать это одной строкой.
|
Указать координаты векторов можно как напрямую, так и спомощью функций.
|
||||||
|
Принципиальной разницы нет, но функции указания координат позволяют сделать это
|
||||||
|
одной строкой.
|
||||||
|
|
||||||
Функция для **BgcVector3FP32**:
|
Функция для **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to);
|
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
|
||||||
```
|
```
|
||||||
|
|
||||||
Функция для **BgcVector3FP32**:
|
Функция для **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to);
|
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
|
||||||
```
|
```
|
||||||
|
|
||||||
Каждая из данных функции эквивалентна следующим строкам кода:
|
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
to->x1 = x1;
|
destination->x = x;
|
||||||
to->x2 = x2;
|
destination->y = y;
|
||||||
to->x3 = x3;
|
destination->z = z;
|
||||||
```
|
```
|
||||||
|
|
||||||
В параметре **to** не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
В параметре **destination** не следует передавать некорректные указатели.
|
||||||
|
Значение NULL (0) также считается некорректным.
|
||||||
|
|
||||||
|
Данная функция хорошо подходит для заданя значений координат вектора одной
|
||||||
|
строкой. Особенно если надо указать фиксированные значения координат как
|
||||||
|
в примере ниже.
|
||||||
|
|
||||||
Пример применения:
|
Пример применения:
|
||||||
|
|
||||||
|
|
@ -32,11 +39,11 @@ to->x3 = x3;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector;
|
BGC_FP32_Vector3 my_vector;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector);
|
bgc_fp32_vector3_set_values(&my_vector, -2.2f, 7.1f, 10.01f);
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
|
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,28 @@
|
||||||
# Swapping
|
# Swapping
|
||||||
|
|
||||||
The exchange functions allow two vectors of the same type to exchange coordinate values.
|
The exchange functions allow two vectors of the same type to exchange coordinate
|
||||||
|
values.
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP32_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2);
|
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2);
|
||||||
```
|
```
|
||||||
|
|
||||||
Function for **BgcVector3FP32**:
|
Function for **BGC_FP64_Vector3**:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2);
|
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2);
|
||||||
```
|
```
|
||||||
|
|
||||||
The **vector1** and **vector2** parameters must not be invalid pointers. The NULL (0) value is also considered invalid.
|
The **vector1** and **vector2** parameters must be valid pointers.
|
||||||
|
The NULL (0) value is considered invalid.
|
||||||
|
|
||||||
Vector **vector1** after calling this function will have the coordinate values that vector **vector3** had before calling the function.
|
Vector **vector1** after calling this function will have the coordinate values
|
||||||
|
that vector **vector3** had before calling the function.
|
||||||
|
|
||||||
And vector **vector3** after calling this function will have the same coordinate values that vector **vector1** had before calling the function.
|
And vector **vector3** after calling this function will have the same coordinate
|
||||||
|
values that vector **vector1** had before calling the function.
|
||||||
|
|
||||||
Example of use:
|
Example of use:
|
||||||
|
|
||||||
|
|
@ -28,15 +32,15 @@ Example of use:
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector1, my_vector2;
|
BGC_FP32_Vector3 my_vector1, my_vector2;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 5, &my_vector1);
|
bgc_fp32_vector3_set_values(&my_vector1, -2, 7, 5);
|
||||||
bgc_vector3_set_values_fp32(10, -1, -3, &my_vector2);
|
bgc_fp32_vector3_set_values(&my_vector2, 10, -1, -3);
|
||||||
|
|
||||||
bgc_vector3_swap_fp32(&my_vector1, &my_vector2);
|
bgc_fp32_vector3_swap(&my_vector1, &my_vector2);
|
||||||
|
|
||||||
printf("Vector #1: x1 = %f, x2 = %f, x3 = %f\n", my_vector1.x1, my_vector1.x2, my_vector1.x3);
|
printf("Vector #1: x = %f, y = %f, z = %f\n", my_vector1.x, my_vector1.y, my_vector1.z);
|
||||||
printf("Vector #2: x1 = %f, x2 = %f, x3 = %f\n", my_vector2.x1, my_vector2.x2, my_vector2.x3);
|
printf("Vector #2: x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -45,8 +49,8 @@ int main()
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```
|
```
|
||||||
Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000
|
Vector #1: x = 10.000000, y = -1.000000, z = -3.000000
|
||||||
Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000
|
Vector #2: x = -2.000000, y = 7.000000, z = 5.000000
|
||||||
```
|
```
|
||||||
|
|
||||||
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)
|
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# Обмен
|
# Обмен значениями
|
||||||
|
|
||||||
Функции обмена позволяют двум векторам одного типа обменяться значениями координат.
|
Функции обмена позволяют двум векторам одного типа обменяться значениями
|
||||||
|
координат.
|
||||||
|
|
||||||
Функция для **BgcVector3FP32**:
|
Функция для **BgcVector3FP32**:
|
||||||
|
|
||||||
|
|
@ -14,11 +15,14 @@ inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vecto
|
||||||
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2);
|
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2);
|
||||||
```
|
```
|
||||||
|
|
||||||
Параметры **vector1** и **vector2** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным.
|
Параметры **vector1** и **vector2** не должны быть некорректными указателями.
|
||||||
|
Значение NULL (0) также считается некорректным.
|
||||||
|
|
||||||
Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции.
|
Вектор **vector1** после вызова данной функции будет иметь значения координат,
|
||||||
|
какие имел вектор **vector2** до вызова функции.
|
||||||
|
|
||||||
А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции.
|
А вектор **vector2** после вызова данной функции будет иметь такие же значения
|
||||||
|
координат, какие имел вектор **vector1** до вызова функции.
|
||||||
|
|
||||||
Пример применения:
|
Пример применения:
|
||||||
|
|
||||||
|
|
@ -28,15 +32,15 @@ inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vecto
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BgcVector3FP32 my_vector1, my_vector2;
|
BGC_FP32_Vector3 my_vector1, my_vector2;
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 5, &my_vector1);
|
bgc_fp32_vector3_set_values(&my_vector1, -2, 7, 5);
|
||||||
bgc_vector3_set_values_fp32(10, -1, -3, &my_vector2);
|
bgc_fp32_vector3_set_values(&my_vector2, 10, -1, -3);
|
||||||
|
|
||||||
bgc_vector3_swap_fp32(&my_vector1, &my_vector2);
|
bgc_fp32_vector3_swap(&my_vector1, &my_vector2);
|
||||||
|
|
||||||
printf("Vector #1: x1 = %f, x2 = %f, x3 = %f\n", my_vector1.x1, my_vector1.x2, my_vector1.x3);
|
printf("Vector #1: x = %f, y = %f, z = %f\n", my_vector1.x, my_vector1.y, my_vector1.z);
|
||||||
printf("Vector #2: x1 = %f, x2 = %f, x3 = %f\n", my_vector2.x1, my_vector2.x2, my_vector2.x3);
|
printf("Vector #2: x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -45,8 +49,8 @@ int main()
|
||||||
Результат:
|
Результат:
|
||||||
|
|
||||||
```
|
```
|
||||||
Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000
|
Vector #1: x = 10.000000, y = -1.000000, z = -3.000000
|
||||||
Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000
|
Vector #2: x = -2.000000, y = 7.000000, z = 5.000000
|
||||||
```
|
```
|
||||||
|
|
||||||
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)
|
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue