Отказ от терминов Versor и Cotes Number в пользу Turn3 и Turn2, использование кватернионов внутри Turn3
This commit is contained in:
parent
38cff7e27d
commit
b470a3194b
27 changed files with 1815 additions and 2045 deletions
91
basic-geometry/turn2.c
Normal file
91
basic-geometry/turn2.c
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
#include "./turn2.h"
|
||||
|
||||
const BGC_FP32_Turn2 BGC_FP32_IDLE_TURN2 = { 1.0f, 0.0f };
|
||||
|
||||
const BGC_FP64_Turn2 BGC_FP64_IDLE_TURN2 = { 1.0, 0.0 };
|
||||
|
||||
extern inline void bgc_fp32_turn2_reset(BGC_FP32_Turn2* turn);
|
||||
extern inline void bgc_fp64_turn2_reset(BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_make(BGC_FP32_Turn2* turn, const float x1, const float x2);
|
||||
extern inline void bgc_fp64_turn2_make(BGC_FP64_Turn2* turn, const double x1, const double x2);
|
||||
|
||||
extern inline void bgc_fp32_turn2_make_for_angle(BGC_FP32_Turn2* turn, const float angle, const int angle_unit);
|
||||
extern inline void bgc_fp64_turn2_make_for_angle(BGC_FP64_Turn2* turn, const double angle, const int angle_unit);
|
||||
|
||||
extern inline int bgc_fp32_turn2_is_idle(const BGC_FP32_Turn2* turn);
|
||||
extern inline int bgc_fp64_turn2_is_idle(const BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline float bgc_fp32_turn2_get_angle(const BGC_FP32_Turn2* turn, const int angle_unit);
|
||||
extern inline double bgc_fp64_turn2_get_angle(const BGC_FP64_Turn2* turn, const int angle_unit);
|
||||
|
||||
extern inline void bgc_fp32_turn2_copy(BGC_FP32_Turn2* destination, const BGC_FP32_Turn2* source);
|
||||
extern inline void bgc_fp64_turn2_copy(BGC_FP64_Turn2* destination, const BGC_FP64_Turn2* source);
|
||||
|
||||
extern inline void bgc_fp32_turn2_swap(BGC_FP32_Turn2* turn1, BGC_FP32_Turn2* turn2);
|
||||
extern inline void bgc_fp64_turn2_swap(BGC_FP64_Turn2* turn1, BGC_FP64_Turn2* turn2);
|
||||
|
||||
extern inline void bgc_fp64_turn2_convert_to_fp32(BGC_FP32_Turn2* destination, const BGC_FP64_Turn2* source);
|
||||
extern inline void bgc_fp32_turn2_convert_to_fp64(BGC_FP64_Turn2* destination, const BGC_FP32_Turn2* source);
|
||||
|
||||
extern inline void bgc_fp32_turn2_revert(BGC_FP32_Turn2* turn);
|
||||
extern inline void bgc_fp64_turn2_revert(BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_get_reverse(BGC_FP32_Turn2* reverse, const BGC_FP32_Turn2* turn);
|
||||
extern inline void bgc_fp64_turn2_get_reverse(BGC_FP64_Turn2* reverse, const BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_get_exponation(BGC_FP32_Turn2* power, const BGC_FP32_Turn2* base, const float exponent);
|
||||
extern inline void bgc_fp64_turn2_get_exponation(BGC_FP64_Turn2* power, const BGC_FP64_Turn2* base, const double exponent);
|
||||
|
||||
extern inline void bgc_fp32_turn2_combine(BGC_FP32_Turn2* combination, const BGC_FP32_Turn2* turn1, const BGC_FP32_Turn2* turn2);
|
||||
extern inline void bgc_fp64_turn2_combine(BGC_FP64_Turn2* combination, const BGC_FP64_Turn2* turn1, const BGC_FP64_Turn2* turn2);
|
||||
|
||||
extern inline void bgc_fp32_turn2_exclude(BGC_FP32_Turn2* difference, const BGC_FP32_Turn2* base, const BGC_FP32_Turn2* excludant);
|
||||
extern inline void bgc_fp64_turn2_exclude(BGC_FP64_Turn2* difference, const BGC_FP64_Turn2* base, const BGC_FP64_Turn2* excludant);
|
||||
|
||||
extern inline void bgc_fp32_turn2_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Turn2* turn);
|
||||
extern inline void bgc_fp64_turn2_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Turn2* turn);
|
||||
extern inline void bgc_fp64_turn2_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Turn2* turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_vector(BGC_FP32_Vector2* turned_vector, const BGC_FP32_Turn2* turn, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_turn2_vector(BGC_FP64_Vector2* turned_vector, const BGC_FP64_Turn2* turn, const BGC_FP64_Vector2* vector);
|
||||
|
||||
extern inline void bgc_fp32_turn2_vector_back(BGC_FP32_Vector2* turned_vector, const BGC_FP32_Turn2* turn, const BGC_FP32_Vector2* vector);
|
||||
extern inline void bgc_fp64_turn2_vector_back(BGC_FP64_Vector2* turned_vector, const BGC_FP64_Turn2* turn, const BGC_FP64_Vector2* vector);
|
||||
|
||||
extern inline int bgc_fp32_turn2_are_close(const BGC_FP32_Turn2* turn1, const BGC_FP32_Turn2* turn2);
|
||||
extern inline int bgc_fp64_turn2_are_close(const BGC_FP64_Turn2* turn1, const BGC_FP64_Turn2* turn2);
|
||||
|
||||
void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* turn)
|
||||
{
|
||||
const float square_modulus = turn->_cos * turn->_cos + turn->_sin * turn->_sin;
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
turn->_cos = 1.0f;
|
||||
turn->_sin = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sqrtf(1.0f / square_modulus);
|
||||
|
||||
turn->_cos *= multiplier;
|
||||
turn->_sin *= multiplier;
|
||||
}
|
||||
|
||||
void _bgc_fp64_turn2_normalize(BGC_FP64_Turn2* turn)
|
||||
{
|
||||
const double square_modulus = turn->_cos * turn->_cos + turn->_sin * turn->_sin;
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
turn->_cos = 1.0;
|
||||
turn->_sin = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
const double multiplier = sqrt(1.0 / square_modulus);
|
||||
|
||||
turn->_cos *= multiplier;
|
||||
turn->_sin *= multiplier;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue