Небольшие изменения в библиотеке геометрии и тестах
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 };
|
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) {
|
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;
|
twin->s0 = 1.0f;
|
||||||
|
|
@ -25,7 +25,7 @@ void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwi
|
||||||
twin->x3 /= module;
|
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) {
|
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;
|
twin->s0 = 1.0;
|
||||||
|
|
|
||||||
36
src/versor.h
36
src/versor.h
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <xmmintrin.h>
|
||||||
|
|
||||||
#include "basis.h"
|
#include "basis.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "rotation3.h"
|
#include "rotation3.h"
|
||||||
|
|
@ -22,11 +24,11 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float s0, x1, x2, x3;
|
float s0, x1, x2, x3;
|
||||||
} __BgFP32VersorDarkTwin;
|
} __BgFP32DarkTwinVersor;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double s0, x1, x2, x3;
|
double s0, x1, x2, x3;
|
||||||
} __BgFP64VersorDarkTwin;
|
} __BgFP64DarkTwinVersor;
|
||||||
|
|
||||||
// ================= Constants ================== //
|
// ================= Constants ================== //
|
||||||
|
|
||||||
|
|
@ -37,7 +39,7 @@ extern const BgFP64Versor BG_FP64_IDLE_VERSOR;
|
||||||
|
|
||||||
static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
||||||
{
|
{
|
||||||
__BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor;
|
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||||
|
|
||||||
twin->s0 = 1.0f;
|
twin->s0 = 1.0f;
|
||||||
twin->x1 = 0.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)
|
static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
||||||
{
|
{
|
||||||
__BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor;
|
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||||
|
|
||||||
twin->s0 = 1.0;
|
twin->s0 = 1.0;
|
||||||
twin->x1 = 0.0;
|
twin->x1 = 0.0;
|
||||||
|
|
@ -57,13 +59,13 @@ static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
||||||
|
|
||||||
// ==================== Set ===================== //
|
// ==================== Set ===================== //
|
||||||
|
|
||||||