Завершение большого переименования
This commit is contained in:
parent
120e651517
commit
3805354611
31 changed files with 1213 additions and 1255 deletions
|
|
@ -1,23 +1,23 @@
|
|||
#ifndef _BASIC_GEOMETRY_QUATERNION_H_
|
||||
#define _BASIC_GEOMETRY_QUATERNION_H_
|
||||
#ifndef _BGC_QUATERNION_H_
|
||||
#define _BGC_QUATERNION_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "matrix3x3.h"
|
||||
|
||||
typedef struct {
|
||||
float s0, x1, x2, x3;
|
||||
} quaternion_fp32_t;
|
||||
} bgc_quaternion_fp32_t;
|
||||
|
||||
typedef struct {
|
||||
double s0, x1, x2, x3;
|
||||
} quaternion_fp64_t;
|
||||
} bgc_quaternion_fp64_t;
|
||||
|
||||
// ==================== Reset =================== //
|
||||
|
||||
inline void quaternion_reset_fp32(quaternion_fp32_t * quaternion)
|
||||
inline void bgc_quaternion_reset_fp32(bgc_quaternion_fp32_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = 0.0f;
|
||||
quaternion->x1 = 0.0f;
|
||||
|
|
@ -25,7 +25,7 @@ inline void quaternion_reset_fp32(quaternion_fp32_t * quaternion)
|
|||
quaternion->x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void quaternion_reset_fp64(quaternion_fp64_t * quaternion)
|
||||
inline void bgc_quaternion_reset_fp64(bgc_quaternion_fp64_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = 0.0;
|
||||
quaternion->x1 = 0.0;
|
||||
|
|
@ -35,7 +35,7 @@ inline void quaternion_reset_fp64(quaternion_fp64_t * quaternion)
|
|||
|
||||
// ================== Set Unit ================== //
|
||||
|
||||
inline void quaternion_set_to_identity_fp32(quaternion_fp32_t * quaternion)
|
||||
inline void bgc_quaternion_set_to_identity_fp32(bgc_quaternion_fp32_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = 1.0f;
|
||||
quaternion->x1 = 0.0f;
|
||||
|
|
@ -43,7 +43,7 @@ inline void quaternion_set_to_identity_fp32(quaternion_fp32_t * quaternion)
|
|||
quaternion->x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void quaternion_set_to_identity_fp64(quaternion_fp64_t * quaternion)
|
||||
inline void bgc_quaternion_set_to_identity_fp64(bgc_quaternion_fp64_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = 1.0;
|
||||
quaternion->x1 = 0.0;
|
||||
|
|
@ -53,7 +53,7 @@ inline void quaternion_set_to_identity_fp64(quaternion_fp64_t * quaternion)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
inline void quaternion_set_values_fp32(const float s0, const float x1, const float x2, const float x3, quaternion_fp32_t * quaternion)
|
||||
inline void bgc_quaternion_set_values_fp32(const float s0, const float x1, const float x2, const float x3, bgc_quaternion_fp32_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = s0;
|
||||
quaternion->x1 = x1;
|
||||
|
|
@ -61,7 +61,7 @@ inline void quaternion_set_values_fp32(const float s0, const float x1, const flo
|
|||
quaternion->x3 = x3;
|
||||
}
|
||||
|
||||
inline void quaternion_set_values_fp64(const double s0, const double x1, const double x2, const double x3, quaternion_fp64_t * quaternion)
|
||||
inline void bgc_quaternion_set_values_fp64(const double s0, const double x1, const double x2, const double x3, bgc_quaternion_fp64_t * quaternion)
|
||||
{
|
||||
quaternion->s0 = s0;
|
||||
quaternion->x1 = x1;
|
||||
|
|
@ -71,7 +71,7 @@ inline void quaternion_set_values_fp64(const double s0, const double x1, const d
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void quaternion_copy_fp32(const quaternion_fp32_t* from, quaternion_fp32_t* to)
|
||||
inline void bgc_quaternion_copy_fp32(const bgc_quaternion_fp32_t* from, bgc_quaternion_fp32_t* to)
|
||||
{
|
||||
to->s0 = from->s0;
|
||||
to->x1 = from->x1;
|
||||
|
|
@ -79,7 +79,7 @@ inline void quaternion_copy_fp32(const quaternion_fp32_t* from, quaternion_fp32_
|
|||
to->x3 = from->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_copy_fp64(const quaternion_fp64_t* from, quaternion_fp64_t* to)
|
||||
inline void bgc_quaternion_copy_fp64(const bgc_quaternion_fp64_t* from, bgc_quaternion_fp64_t* to)
|
||||
{
|
||||
to->s0 = from->s0;
|
||||
to->x1 = from->x1;
|
||||
|
|
@ -89,7 +89,7 @@ inline void quaternion_copy_fp64(const quaternion_fp64_t* from, quaternion_fp64_
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void quaternion_swap_fp32(quaternion_fp32_t* quarternion1, quaternion_fp32_t* quarternion2)
|
||||
inline void bgc_quaternion_swap_fp32(bgc_quaternion_fp32_t* quarternion1, bgc_quaternion_fp32_t* quarternion2)
|
||||
{
|
||||
const float s0 = quarternion2->s0;
|
||||
const float x1 = quarternion2->x1;
|
||||
|
|
@ -107,7 +107,7 @@ inline void quaternion_swap_fp32(quaternion_fp32_t* quarternion1, quaternion_fp3
|
|||
quarternion1->x3 = x3;
|
||||
}
|
||||
|
||||
inline void quaternion_swap_fp64(quaternion_fp64_t* quarternion1, quaternion_fp64_t* quarternion2)
|
||||
inline void bgc_quaternion_swap_fp64(bgc_quaternion_fp64_t* quarternion1, bgc_quaternion_fp64_t* quarternion2)
|
||||
{
|
||||
const double s0 = quarternion2->s0;
|
||||
const double x1 = quarternion2->x1;
|
||||
|
|
@ -127,7 +127,7 @@ inline void quaternion_swap_fp64(quaternion_fp64_t* quarternion1, quaternion_fp6
|
|||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
inline void quaternion_convert_fp64_to_fp32(const quaternion_fp64_t* quaternion, quaternion_fp32_t* result)
|
||||
inline void bgc_quaternion_convert_fp64_to_fp32(const bgc_quaternion_fp64_t* quaternion, bgc_quaternion_fp32_t* result)
|
||||
{
|
||||
result->s0 = (float) quaternion->s0;
|
||||
result->x1 = (float) quaternion->x1;
|
||||
|
|
@ -135,7 +135,7 @@ inline void quaternion_convert_fp64_to_fp32(const quaternion_fp64_t* quaternion,
|
|||
result->x3 = (float) quaternion->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_convert_fp32_to_fp64(const quaternion_fp32_t* quaternion, quaternion_fp64_t* result)
|
||||
inline void bgc_quaternion_convert_fp32_to_fp64(const bgc_quaternion_fp32_t* quaternion, bgc_quaternion_fp64_t* result)
|
||||
{
|
||||
result->s0 = quaternion->s0;
|
||||
result->x1 = quaternion->x1;
|
||||
|
|
@ -145,14 +145,14 @@ inline void quaternion_convert_fp32_to_fp64(const quaternion_fp32_t* quaternion,
|
|||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
inline void quaternion_conjugate_fp32(quaternion_fp32_t* quaternion)
|
||||
inline void bgc_quaternion_conjugate_fp32(bgc_quaternion_fp32_t* quaternion)
|
||||
{
|
||||
quaternion->x1 = -quaternion->x1;
|
||||
quaternion->x2 = -quaternion->x2;
|
||||
quaternion->x3 = -quaternion->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_conjugate_fp64(quaternion_fp64_t* quaternion)
|
||||
inline void bgc_quaternion_conjugate_fp64(bgc_quaternion_fp64_t* quaternion)
|
||||
{
|
||||
quaternion->x1 = -quaternion->x1;
|
||||
quaternion->x2 = -quaternion->x2;
|
||||
|
|
@ -161,7 +161,7 @@ inline void quaternion_conjugate_fp64(quaternion_fp64_t* quaternion)
|
|||
|
||||
// ================ Set Conjugate =============== //
|
||||
|
||||
inline void quaternion_set_conjugate_fp32(const quaternion_fp32_t* quaternion, quaternion_fp32_t* result)
|
||||
inline void bgc_quaternion_set_conjugate_fp32(const bgc_quaternion_fp32_t* quaternion, bgc_quaternion_fp32_t* result)
|
||||
{
|
||||
result->s0 = quaternion->s0;
|
||||
result->x1 = -quaternion->x1;
|
||||
|
|
@ -169,7 +169,7 @@ inline void quaternion_set_conjugate_fp32(const quaternion_fp32_t* quaternion, q
|
|||
result->x3 = -quaternion->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_set_conjugate_fp64(const quaternion_fp64_t* quaternion, quaternion_fp64_t* result)
|
||||
inline void bgc_quaternion_set_conjugate_fp64(const bgc_quaternion_fp64_t* quaternion, bgc_quaternion_fp64_t* result)
|
||||
{
|
||||
result->s0 = quaternion->s0;
|
||||
result->x1 = -quaternion->x1;
|
||||
|
|
@ -179,7 +179,7 @@ inline void quaternion_set_conjugate_fp64(const quaternion_fp64_t* quaternion, q
|
|||
|
||||
// ================ Set Conjugate =============== //
|
||||
|
||||
inline void quaternion_set_conjugate_fp64_to_fp32(const quaternion_fp64_t* quaternion, quaternion_fp32_t* result)
|
||||
inline void bgc_quaternion_set_conjugate_fp64_to_fp32(const bgc_quaternion_fp64_t* quaternion, bgc_quaternion_fp32_t* result)
|
||||
{
|
||||
result->s0 = (float) quaternion->s0;
|
||||
result->x1 = (float) -quaternion->x1;
|
||||
|
|
@ -187,7 +187,7 @@ inline void quaternion_set_conjugate_fp64_to_fp32(const quaternion_fp64_t* quate
|
|||
result->x3 = (float) -quaternion->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_set_conjugate_fp32_to_fp64(const quaternion_fp32_t* quaternion, quaternion_fp64_t* result)
|
||||
inline void bgc_quaternion_set_conjugate_fp32_to_fp64(const bgc_quaternion_fp32_t* quaternion, bgc_quaternion_fp64_t* result)
|
||||
{
|
||||
result->s0 = quaternion->s0;
|
||||
result->x1 = -quaternion->x1;
|
||||
|
|
@ -197,40 +197,40 @@ inline void quaternion_set_conjugate_fp32_to_fp64(const quaternion_fp32_t* quate
|
|||
|
||||
// ============= Get Square Modulus ============= //
|
||||
|
||||
inline float quaternion_get_square_modulus_fp32(const quaternion_fp32_t* quaternion)
|
||||
inline float bgc_quaternion_get_square_modulus_fp32(const bgc_quaternion_fp32_t* quaternion)
|
||||
{
|
||||
return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3);
|
||||
}
|
||||
|
||||
inline double quaternion_get_square_modulus_fp64(const quaternion_fp64_t* quaternion)
|
||||
inline double bgc_quaternion_get_square_modulus_fp64(const bgc_quaternion_fp64_t* quaternion)
|
||||
{
|
||||
return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3);
|
||||
}
|
||||
|
||||
// ================ Get Modulus ================= //
|
||||
|
||||
inline float quaternion_get_modulus_fp32(const quaternion_fp32_t* quaternion)
|
||||
inline float bgc_quaternion_get_modulus_fp32(const bgc_quaternion_fp32_t* quaternion)
|
||||
{
|
||||
return sqrtf(quaternion_get_square_modulus_fp32(quaternion));
|
||||
return sqrtf(bgc_quaternion_get_square_modulus_fp32(quaternion));
|
||||
}
|
||||
|
||||
inline double quaternion_get_modulus_fp64(const quaternion_fp64_t* quaternion)
|
||||
inline double bgc_quaternion_get_modulus_fp64(const bgc_quaternion_fp64_t* quaternion)
|
||||
{
|
||||
return sqrt(quaternion_get_square_modulus_fp64(quaternion));
|
||||
return sqrt(bgc_quaternion_get_square_modulus_fp64(quaternion));
|
||||
}
|
||||
|
||||
// =============== Normalization ================ //
|
||||
|
||||
inline int quaternion_normalize_fp32(quaternion_fp32_t* quaternion)
|
||||
inline int bgc_quaternion_normalize_fp32(bgc_quaternion_fp32_t* quaternion)
|
||||
{
|
||||
const float square_modulus = quaternion_get_square_modulus_fp32(quaternion);
|
||||
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(quaternion);
|
||||
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= FP32_SQUARE_EPSYLON) {
|
||||
quaternion_reset_fp32(quaternion);
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
bgc_quaternion_reset_fp32(quaternion);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -244,16 +244,16 @@ inline int quaternion_normalize_fp32(quaternion_fp32_t* quaternion)
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int quaternion_normalize_fp64(quaternion_fp64_t* quaternion)
|
||||
inline int bgc_quaternion_normalize_fp64(bgc_quaternion_fp64_t* quaternion)
|
||||
{
|
||||
const double square_modulus = quaternion_get_square_modulus_fp64(quaternion);
|
||||
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(quaternion);
|
||||
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= FP32_SQUARE_EPSYLON) {
|
||||
quaternion_reset_fp64(quaternion);
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
bgc_quaternion_reset_fp64(quaternion);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ inline int quaternion_normalize_fp64(quaternion_fp64_t* quaternion)
|
|||
|
||||
// ============ Make Rotation Matrix ============ //
|
||||
|
||||
inline void quaternion_get_rotation_matrix_fp32(const quaternion_fp32_t* quaternion, matrix3x3_fp32_t* matrix)
|
||||
inline void bgc_quaternion_get_rotation_matrix_fp32(const bgc_quaternion_fp32_t* quaternion, bgc_matrix3x3_fp32_t* matrix)
|
||||
{
|
||||
const float s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const float x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -278,9 +278,9 @@ inline void quaternion_get_rotation_matrix_fp32(const quaternion_fp32_t* quatern
|
|||
|
||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-FP32_EPSYLON <= square_modulus && square_modulus <= FP32_EPSYLON)
|
||||
if (-BGC_EPSYLON_FP32 <= square_modulus && square_modulus <= BGC_EPSYLON_FP32)
|
||||
{
|
||||
matrix3x3_set_to_identity_fp32(matrix);
|
||||
bgc_matrix3x3_set_to_identity_fp32(matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ inline void quaternion_get_rotation_matrix_fp32(const quaternion_fp32_t* quatern
|
|||
matrix->r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
inline void quaternion_get_rotation_matrix_fp64(const quaternion_fp64_t* quaternion, matrix3x3_fp64_t* matrix)
|
||||
inline void bgc_quaternion_get_rotation_matrix_fp64(const bgc_quaternion_fp64_t* quaternion, bgc_matrix3x3_fp64_t* matrix)
|
||||
{
|
||||
const double s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const double x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -316,9 +316,9 @@ inline void quaternion_get_rotation_matrix_fp64(const quaternion_fp64_t* quatern
|
|||
|
||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-FP64_EPSYLON <= square_modulus && square_modulus <= FP64_EPSYLON)
|
||||
if (-BGC_EPSYLON_FP64 <= square_modulus && square_modulus <= BGC_EPSYLON_FP64)
|
||||
{
|
||||
matrix3x3_set_to_identity_fp64(matrix);
|
||||
bgc_matrix3x3_set_to_identity_fp64(matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ inline void quaternion_get_rotation_matrix_fp64(const quaternion_fp64_t* quatern
|
|||
|
||||
// ============ Make Reverse Matrix ============= //
|
||||
|
||||
inline void quaternion_get_reverse_matrix_fp32(const quaternion_fp32_t* quaternion, matrix3x3_fp32_t* matrix)
|
||||
inline void bgc_quaternion_get_reverse_matrix_fp32(const bgc_quaternion_fp32_t* quaternion, bgc_matrix3x3_fp32_t* matrix)
|
||||
{
|
||||
const float s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const float x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -356,9 +356,9 @@ inline void quaternion_get_reverse_matrix_fp32(const quaternion_fp32_t* quaterni
|
|||
|
||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-FP32_EPSYLON <= square_modulus && square_modulus <= FP32_EPSYLON)
|
||||
if (-BGC_EPSYLON_FP32 <= square_modulus && square_modulus <= BGC_EPSYLON_FP32)
|
||||
{
|
||||
matrix3x3_set_to_identity_fp32(matrix);
|
||||
bgc_matrix3x3_set_to_identity_fp32(matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ inline void quaternion_get_reverse_matrix_fp32(const quaternion_fp32_t* quaterni
|
|||
matrix->r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
}
|
||||
|
||||
inline void quaternion_get_reverse_matrix_fp64(const quaternion_fp64_t* quaternion, matrix3x3_fp64_t* matrix)
|
||||
inline void bgc_quaternion_get_reverse_matrix_fp64(const bgc_quaternion_fp64_t* quaternion, bgc_matrix3x3_fp64_t* matrix)
|
||||
{
|
||||
const double s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const double x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -394,9 +394,9 @@ inline void quaternion_get_reverse_matrix_fp64(const quaternion_fp64_t* quaterni
|
|||
|
||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-FP64_EPSYLON <= square_modulus && square_modulus <= FP64_EPSYLON)
|
||||
if (-BGC_EPSYLON_FP64 <= square_modulus && square_modulus <= BGC_EPSYLON_FP64)
|
||||
{
|
||||
matrix3x3_set_to_identity_fp64(matrix);
|
||||
bgc_matrix3x3_set_to_identity_fp64(matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -425,25 +425,43 @@ inline void quaternion_get_reverse_matrix_fp64(const quaternion_fp64_t* quaterni
|
|||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
inline void quaternion_add_fp32(const quaternion_fp32_t * quaternion1, const quaternion_fp32_t * quaternion2, quaternion_fp32_t * result)
|
||||
inline void bgc_quaternion_add_fp32(const bgc_quaternion_fp32_t * quaternion1, const bgc_quaternion_fp32_t * quaternion2, bgc_quaternion_fp32_t * sum)
|
||||
{
|
||||
result->s0 = quaternion1->s0 + quaternion2->s0;
|
||||
result->x1 = quaternion1->x1 + quaternion2->x1;
|
||||
result->x2 = quaternion1->x2 + quaternion2->x2;
|
||||
result->x3 = quaternion1->x3 + quaternion2->x3;
|
||||
sum->s0 = quaternion1->s0 + quaternion2->s0;
|
||||
sum->x1 = quaternion1->x1 + quaternion2->x1;
|
||||
sum->x2 = quaternion1->x2 + quaternion2->x2;
|
||||
sum->x3 = quaternion1->x3 + quaternion2->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_add_fp64(const quaternion_fp64_t * quaternion1, const quaternion_fp64_t * quaternion2, quaternion_fp64_t * result)
|
||||
inline void bgc_quaternion_add_fp64(const bgc_quaternion_fp64_t * quaternion1, const bgc_quaternion_fp64_t * quaternion2, bgc_quaternion_fp64_t * sum)
|
||||
{
|
||||
result->s0 = quaternion1->s0 + quaternion2->s0;
|
||||
result->x1 = quaternion1->x1 + quaternion2->x1;
|
||||
result->x2 = quaternion1->x2 + quaternion2->x2;
|
||||
result->x3 = quaternion1->x3 + quaternion2->x3;
|
||||
sum->s0 = quaternion1->s0 + quaternion2->s0;
|
||||
sum->x1 = quaternion1->x1 + quaternion2->x1;
|
||||
sum->x2 = quaternion1->x2 + quaternion2->x2;
|
||||
sum->x3 = quaternion1->x3 + quaternion2->x3;
|
||||
}
|
||||
|
||||
// ================= Add Scaled ================= //
|
||||
|
||||
inline void bgc_quaternion_add_scaled_fp32(const bgc_quaternion_fp32_t * basic_quaternion, const bgc_quaternion_fp32_t * scalable_quaternion, const float scale, bgc_quaternion_fp32_t * sum)
|
||||
{
|
||||
sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale;
|
||||
sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale;
|
||||
sum->x2 = basic_quaternion->x2 + scalable_quaternion->x2 * scale;
|
||||
sum->x3 = basic_quaternion->x3 + scalable_quaternion->x3 * scale;
|
||||
}
|
||||
|
||||
inline void bgc_quaternion_add_scaled_fp64(const bgc_quaternion_fp64_t * basic_quaternion, const bgc_quaternion_fp64_t * scalable_quaternion, const double scale, bgc_quaternion_fp64_t * sum)
|
||||
{
|
||||
sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale;
|
||||
sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale;
|
||||
sum->x2 = basic_quaternion->x2 + scalable_quaternion->x2 * scale;
|
||||
sum->x3 = basic_quaternion->x3 + scalable_quaternion->x3 * scale;
|
||||
}
|
||||
|
||||
// ================== Subtract ================== //
|
||||
|
||||
inline void quaternion_subtract_fp32(const quaternion_fp32_t * minuend, const quaternion_fp32_t * subtrahend, quaternion_fp32_t * difference)
|
||||
inline void bgc_quaternion_subtract_fp32(const bgc_quaternion_fp32_t * minuend, const bgc_quaternion_fp32_t * subtrahend, bgc_quaternion_fp32_t * difference)
|
||||
{
|
||||
difference->s0 = minuend->s0 - subtrahend->s0;
|
||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
||||
|
|
@ -451,7 +469,7 @@ inline void quaternion_subtract_fp32(const quaternion_fp32_t * minuend, const qu
|
|||
difference->x3 = minuend->x3 - subtrahend->x3;
|
||||
}
|
||||
|
||||
inline void quaternion_subtract_fp64(const quaternion_fp64_t * minuend, const quaternion_fp64_t * subtrahend, quaternion_fp64_t * difference)
|
||||
inline void bgc_quaternion_subtract_fp64(const bgc_quaternion_fp64_t * minuend, const bgc_quaternion_fp64_t * subtrahend, bgc_quaternion_fp64_t * difference)
|
||||
{
|
||||
difference->s0 = minuend->s0 - subtrahend->s0;
|
||||
difference->x1 = minuend->x1 - subtrahend->x1;
|
||||
|
|
@ -461,7 +479,7 @@ inline void quaternion_subtract_fp64(const quaternion_fp64_t * minuend, const qu
|
|||
|
||||
// =============== Multiplication =============== //
|
||||
|
||||
inline void quaternion_multiply_fp32(const quaternion_fp32_t* multiplicand, const float multipier, quaternion_fp32_t* product)
|
||||
inline void bgc_quaternion_multiply_fp32(const bgc_quaternion_fp32_t* multiplicand, const float multipier, bgc_quaternion_fp32_t* product)
|
||||
{
|
||||
product->s0 = multiplicand->s0 * multipier;
|
||||
product->x1 = multiplicand->x1 * multipier;
|
||||
|
|
@ -469,7 +487,7 @@ inline void quaternion_multiply_fp32(const quaternion_fp32_t* multiplicand, cons
|
|||
product->x3 = multiplicand->x3 * multipier;
|
||||
}
|
||||
|
||||
inline void quaternion_multiply_fp64(const quaternion_fp64_t* multiplicand, const double multipier, quaternion_fp64_t* product)
|
||||
inline void bgc_quaternion_multiply_fp64(const bgc_quaternion_fp64_t* multiplicand, const double multipier, bgc_quaternion_fp64_t* product)
|
||||
{
|
||||
product->s0 = multiplicand->s0 * multipier;
|
||||
product->x1 = multiplicand->x1 * multipier;
|
||||
|
|
@ -479,19 +497,19 @@ inline void quaternion_multiply_fp64(const quaternion_fp64_t* multiplicand, cons
|
|||
|
||||
// ================== Division ================== //
|
||||
|
||||
inline void quaternion_divide_fp32(const quaternion_fp32_t* dividend, const float divisor, quaternion_fp32_t* quotient)
|
||||
inline void bgc_quaternion_divide_fp32(const bgc_quaternion_fp32_t* dividend, const float divisor, bgc_quaternion_fp32_t* quotient)
|
||||
{
|
||||
quaternion_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||
bgc_quaternion_multiply_fp32(dividend, 1.0f / divisor, quotient);
|
||||
}
|
||||
|
||||
inline void quaternion_fp64_divide(const quaternion_fp64_t* dividend, const double divisor, quaternion_fp64_t* quotient)
|
||||
inline void bgc_quaternion_divide_fp64(const bgc_quaternion_fp64_t* dividend, const double divisor, bgc_quaternion_fp64_t* quotient)
|
||||
{
|
||||
quaternion_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||
bgc_quaternion_multiply_fp64(dividend, 1.0 / divisor, quotient);
|
||||
}
|
||||
|
||||
// ================== Product =================== //
|
||||
|
||||
inline void quaternion_get_product_fp32(const quaternion_fp32_t* left, const quaternion_fp32_t* right, quaternion_fp32_t* product)
|
||||
inline void bgc_quaternion_get_product_fp32(const bgc_quaternion_fp32_t* left, const bgc_quaternion_fp32_t* right, bgc_quaternion_fp32_t* product)
|
||||
{
|
||||
const float s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3);
|
||||
const float x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3);
|
||||
|
|
@ -504,7 +522,7 @@ inline void quaternion_get_product_fp32(const quaternion_fp32_t* left, const qua
|
|||
product->x3 = x3;
|
||||
}
|
||||
|
||||
inline void quaternion_get_product_fp64(const quaternion_fp64_t* left, const quaternion_fp64_t* right, quaternion_fp64_t* product)
|
||||
inline void bgc_quaternion_get_product_fp64(const bgc_quaternion_fp64_t* left, const bgc_quaternion_fp64_t* right, bgc_quaternion_fp64_t* product)
|
||||
{
|
||||
const double s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3);
|
||||
const double x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3);
|
||||
|
|
@ -517,4 +535,4 @@ inline void quaternion_get_product_fp64(const quaternion_fp64_t* left, const qua
|
|||
product->x3 = x3;
|
||||
}
|
||||
|
||||
#endif // _GEOMETRY_QUATERNION_H_
|
||||
#endif // _BGC_QUATERNION_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue