Небольшие изменения в библиотеке геометрии и тестах
This commit is contained in:
parent
23fcdc2c28
commit
da61a9bf7c
5 changed files with 44 additions and 42 deletions
|
|
@ -7,7 +7,7 @@ const BgFP32Versor BG_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|||
|
||||
const BgFP64Versor BG_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
|
||||
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwin* twin)
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVersor* twin)
|
||||
{
|
||||
if (square_module <= BG_FP32_SQUARE_EPSYLON || (twin->x1 * twin->x1 + twin->x2 * twin->x2 + twin->x3 * twin->x3) <= BG_FP32_SQUARE_EPSYLON * square_module) {
|
||||
twin->s0 = 1.0f;
|
||||
|
|
@ -25,7 +25,7 @@ void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwi
|
|||
twin->x3 /= module;
|
||||
}
|
||||
|
||||
void __bg_fp64_versor_normalize(const double square_module, __BgFP64VersorDarkTwin* twin)
|
||||
void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVersor* twin)
|
||||
{
|
||||
if (square_module <= BG_FP64_SQUARE_EPSYLON || (twin->x1 * twin->x1 + twin->x2 * twin->x2 + twin->x3 * twin->x3) <= BG_FP64_SQUARE_EPSYLON * square_module) {
|
||||
twin->s0 = 1.0;
|
||||
|
|
|
|||
36
src/versor.h
36
src/versor.h
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#include "basis.h"
|
||||
#include "vector3.h"
|
||||
#include "rotation3.h"
|
||||
|
|
@ -22,11 +24,11 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
float s0, x1, x2, x3;
|
||||
} __BgFP32VersorDarkTwin;
|
||||
} __BgFP32DarkTwinVersor;
|
||||
|
||||
typedef struct {
|
||||
double s0, x1, x2, x3;
|
||||
} __BgFP64VersorDarkTwin;
|
||||
} __BgFP64DarkTwinVersor;
|
||||
|
||||
// ================= Constants ================== //
|
||||
|
||||
|
|
@ -37,7 +39,7 @@ extern const BgFP64Versor BG_FP64_IDLE_VERSOR;
|
|||
|
||||
static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
||||
{
|
||||
__BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor;
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
|
||||
twin->s0 = 1.0f;
|
||||
twin->x1 = 0.0f;
|
||||
|
|
@ -47,7 +49,7 @@ static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
|||
|
||||
static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
||||
{
|
||||
__BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor;
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
|
||||
twin->s0 = 1.0;
|
||||
twin->x1 = 0.0;
|
||||
|
|
@ -57,13 +59,13 @@ static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwin* twin);
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVersor* twin);
|
||||
|
||||
void __bg_fp64_versor_normalize(const double square_module, __BgFP64VersorDarkTwin* twin);
|
||||
void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVersor* twin);
|
||||
|
||||
static inline void bg_fp32_versor_set_values(const float s0, const float x1, const float x2, const float x3, BgFP32Versor* versor)
|
||||
{
|
||||
__BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor;
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
|
|
@ -73,13 +75,13 @@ static inline void bg_fp32_versor_set_values(const float s0, const float x1, con
|
|||
const float square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (square_module < 1.0f - BG_FP32_TWO_EPSYLON || 1.0f + BG_FP32_TWO_EPSYLON < square_module) {
|
||||
__bg_fp32_versor_normalize(square_module, (__BgFP32VersorDarkTwin*)versor);
|
||||
__bg_fp32_versor_normalize(square_module, (__BgFP32DarkTwinVersor*)versor);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_values(const double s0, const double x1, const double x2, const double x3, BgFP64Versor* versor)
|
||||
{
|
||||
__BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor;
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
|
|
@ -97,7 +99,7 @@ static inline void bg_fp64_versor_set_values(const double s0, const double x1, c
|
|||
|
||||
static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* to)
|
||||
{
|
||||
__BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)to;
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to;
|
||||
|
||||
twin->s0 = from->s0;
|
||||
twin->x1 = from->x1;
|
||||
|
|
@ -107,7 +109,7 @@ static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* t
|
|||
|
||||
static inline void bg_fp64_versor_copy(const BgFP64Versor* from, BgFP64Versor* to)
|
||||
{
|
||||
__BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)to;
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to;
|
||||
|
||||
twin->s0 = from->s0;
|
||||
twin->x1 = from->x1;
|
||||
|
|
@ -185,7 +187,7 @@ static inline void bg_fp64_versor_set_from_fp32(const BgFP32Versor* versor, BgFP
|
|||
|
||||
static inline void bg_fp32_versor_invert(BgFP32Versor* versor)
|
||||
{
|
||||