Изменение функций нормализации, переименование make функий в set values, добавление внутренних restrict функций, гарантирующих оптимизальное выполнение открытых функций, независимо от компилятора
This commit is contained in:
parent
e6ac9023ec
commit
6945c69ef2
20 changed files with 324 additions and 337 deletions
|
|
@ -7,11 +7,14 @@ const BGC_FP64_Turn2 BGC_FP64_IDLE_TURN2 = { 1.0, 0.0 };
|
|||
extern inline void bgc_fp32_turn2_reset(BGC_FP32_Turn2* const turn);
|
||||
extern inline void bgc_fp64_turn2_reset(BGC_FP64_Turn2* const turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_make(BGC_FP32_Turn2* const turn, const float x1, const float x2);
|
||||
extern inline void bgc_fp64_turn2_make(BGC_FP64_Turn2* const turn, const double x1, const double x2);
|
||||
extern void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* const turn);
|
||||
extern void _bgc_fp64_turn2_normalize(BGC_FP64_Turn2* const turn);
|
||||
|
||||
extern inline void bgc_fp32_turn2_make_for_angle(BGC_FP32_Turn2* const turn, const float angle, const int angle_unit);
|
||||
extern inline void bgc_fp64_turn2_make_for_angle(BGC_FP64_Turn2* const turn, const double angle, const int angle_unit);
|
||||
extern inline void bgc_fp32_turn2_set_values(BGC_FP32_Turn2* const turn, const float x1, const float x2);
|
||||
extern inline void bgc_fp64_turn2_set_values(BGC_FP64_Turn2* const turn, const double x1, const double x2);
|
||||
|
||||
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 int bgc_fp32_turn2_is_idle(const BGC_FP32_Turn2* const turn);
|
||||
extern inline int bgc_fp64_turn2_is_idle(const BGC_FP64_Turn2* const turn);
|
||||
|
|
@ -57,35 +60,3 @@ extern inline void bgc_fp64_turn2_vector_back(BGC_FP64_Vector2* const turned_vec
|
|||
|
||||
extern inline int bgc_fp32_turn2_are_close(const BGC_FP32_Turn2* const turn1, const BGC_FP32_Turn2* const turn2);
|
||||
extern inline int bgc_fp64_turn2_are_close(const BGC_FP64_Turn2* const turn1, const BGC_FP64_Turn2* const turn2);
|
||||
|
||||
void _bgc_fp32_turn2_normalize(BGC_FP32_Turn2* const 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* const 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