Переименование типов в соответствии со стилем POSIX, отказ от префикса bg_

This commit is contained in:
Andrey Pokidov 2025-01-13 21:31:26 +07:00
parent d2a25823a5
commit 605afabd94
25 changed files with 1109 additions and 1035 deletions

View file

@ -3,68 +3,68 @@
#include "angle.h"
#include "versor.h"
const BgFP32Versor BG_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
const fp32_versor_t 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 fp64_versor_t FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
// =============== Set Crude Turn =============== //
void bg_fp32_versor_set_crude_turn(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, BgFP32Versor* result)
void fp32_versor_set_crude_turn(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, fp32_versor_t* result)
{
const float square_vector = x1 * x1 + x2 * x2 + x3 * x3;
if (square_vector <= BG_FP32_SQUARE_EPSYLON) {
bg_fp32_versor_reset(result);
if (square_vector <= FP32_SQUARE_EPSYLON) {
fp32_versor_reset(result);
return;
}
const float half_angle = bg_fp32_angle_to_radians(0.5f * angle, unit);
const float half_angle = fp32_angle_to_radians(0.5f * angle, unit);
const float sine = sinf(half_angle);
if (-BG_FP32_EPSYLON <= sine && sine <= BG_FP32_EPSYLON) {
bg_fp32_versor_reset(result);
if (-FP32_EPSYLON <= sine && sine <= FP32_EPSYLON) {
fp32_versor_reset(result);
return;
}
const float multiplier = sine / sqrtf(square_vector);
bg_fp32_versor_set_values(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
fp32_versor_set_values(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
}
void bg_fp64_versor_set_crude_turn(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, BgFP64Versor* result)
void fp64_versor_set_crude_turn(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, fp64_versor_t* result)
{
const double square_vector = x1 * x1 + x2 * x2 + x3 * x3;
if (square_vector <= BG_FP64_SQUARE_EPSYLON) {
bg_fp64_versor_reset(result);
if (square_vector <= FP64_SQUARE_EPSYLON) {
fp64_versor_reset(result);
return;
}
const double half_angle = bg_fp64_angle_to_radians(0.5 * angle, unit);
const double half_angle = fp64_angle_to_radians(0.5 * angle, unit);
const double sine = sin(half_angle);
if (-BG_FP64_EPSYLON <= sine && sine <= BG_FP64_EPSYLON) {
bg_fp64_versor_reset(result);
if (-FP64_EPSYLON <= sine && sine <= FP64_EPSYLON) {
fp64_versor_reset(result);
return;
}
const double multiplier = sine / sqrt(square_vector);
bg_fp64_versor_set_values(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
fp64_versor_set_values(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
}
// ================= Rotation3 ================== //
void bg_fp32_versor_get_rotation(const BgFP32Versor* versor, BgFP32Rotation3* result)
void fp32_versor_get_rotation(const fp32_versor_t* versor, fp32_rotation3_t* result)
{
if (versor == 0 || result == 0) {
return;
}
if (versor->s0 <= -(1.0f - BG_FP32_EPSYLON) || 1.0f - BG_FP32_EPSYLON <= versor->s0) {
bg_fp32_rotation_reset(result);
if (versor->s0 <= -(1.0f - FP32_EPSYLON) || 1.0f - FP32_EPSYLON <= versor->s0) {
fp32_rotation_reset(result);
return;
}
@ -79,14 +79,14 @@ void bg_fp32_versor_get_rotation(const BgFP32Versor* versor, BgFP32Rotation3* re
result->axis.x3 = versor->x3 * multiplier;
}
void bg_fp64_versor_get_rotation(const BgFP64Versor* versor, BgFP64Rotation3* result)
void fp64_versor_get_rotation(const fp64_versor_t* versor, fp64_rotation3_t* result)
{
if (versor == 0 || result == 0) {
return;
}
if (versor->s0 <= -(1.0 - BG_FP64_EPSYLON) || 1.0 - BG_FP64_EPSYLON <= versor->s0) {
bg_fp64_rotation_reset(result);
if (versor->s0 <= -(1.0 - FP64_EPSYLON) || 1.0 - FP64_EPSYLON <= versor->s0) {
fp64_rotation_reset(result);
return;
}