Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -4,99 +4,95 @@
|
|||
#include <math.h>
|
||||
#include "utilities.h"
|
||||
|
||||
#define BGC_PI_FP32 3.1415926536f
|
||||
#define BGC_TWO_PI_FP32 6.2831853072f
|
||||
#define BGC_HALF_OF_PI_FP32 1.5707963268f
|
||||
#define BGC_THIRD_OF_PI_FP32 1.0471975512f
|
||||
#define BGC_FOURTH_OF_PI_FP32 0.7853981634f
|
||||
#define BGC_SIXTH_OF_PI_FP32 0.5235987756f
|
||||
#define BGC_FP32_PI 3.1415926536f
|
||||
#define BGC_FP32_TWO_PI 6.2831853072f
|
||||
#define BGC_FP32_HALF_OF_PI 1.5707963268f
|
||||
#define BGC_FP32_ONE_THIRD_OF_PI 1.0471975512f
|
||||
#define BGC_FP32_ONE_FOURTH_OF_PI 0.7853981634f
|
||||
#define BGC_FP32_ONE_SIXTH_OF_PI 0.5235987756f
|
||||
|
||||
#define BGC_DEGREES_IN_RADIAN_FP32 57.295779513f
|
||||
#define BGC_TURNS_IN_RADIAN_FP32 0.1591549431f
|
||||
#define BGC_RADIANS_IN_DEGREE_FP32 1.745329252E-2f
|
||||
#define BGC_TURNS_IN_DEGREE_FP32 2.7777777778E-3f
|
||||
#define BGC_FP32_DEGREES_IN_RADIAN 57.295779513f
|
||||
#define BGC_FP32_TURNS_IN_RADIAN 0.1591549431f
|
||||
#define BGC_FP32_RADIANS_IN_DEGREE 1.745329252E-2f
|
||||
#define BGC_FP32_TURNS_IN_DEGREE 2.7777777778E-3f
|
||||
|
||||
#define BGC_PI_FP64 3.14159265358979324
|
||||
#define BGC_TWO_PI_FP64 6.28318530717958648
|
||||
#define BGC_HALF_OF_PI_FP64 1.57079632679489662
|
||||
#define BGC_THIRD_OF_PI_FP64 1.04719755119659775
|
||||
#define BGC_FOURTH_OF_PI_FP64 0.78539816339744831
|
||||
#define BGC_SIXTH_OF_PI_FP64 0.523598775598298873
|
||||
#define BGC_FP64_PI 3.14159265358979324
|
||||
#define BGC_FP64_TWO_PI 6.28318530717958648
|
||||
#define BGC_FP64_HALF_OF_PI 1.57079632679489662
|
||||
#define BGC_FP64_ONE_THIRD_OF_PI 1.04719755119659775
|
||||
#define BGC_FP64_ONE_FOURTH_OF_PI 0.78539816339744831
|
||||
#define BGC_FP64_ONE_SIXTH_OF_PI 0.523598775598298873
|
||||
|
||||
#define BGC_DEGREES_IN_RADIAN_FP64 57.2957795130823209
|
||||
#define BGC_TURNS_IN_RADIAN_FP64 0.159154943091895336
|
||||
#define BGC_RADIANS_IN_DEGREE_FP64 1.74532925199432958E-2
|
||||
#define BGC_TURNS_IN_DEGREE_FP64 2.77777777777777778E-3
|
||||
#define BGC_FP64_DEGREES_IN_RADIAN 57.2957795130823209
|
||||
#define BGC_FP64_TURNS_IN_RADIAN 0.159154943091895336
|
||||
#define BGC_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
|
||||
#define BGC_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
|
||||
|
||||
typedef enum {
|
||||
BGC_ANGLE_UNIT_RADIANS = 1,
|
||||
BGC_ANGLE_UNIT_DEGREES = 2,
|
||||
BGC_ANGLE_UNIT_TURNS = 3
|
||||
} BgcAngleUnitEnum;
|
||||
#define BGC_ANGLE_UNIT_RADIANS 1
|
||||
#define BGC_ANGLE_UNIT_DEGREES 2
|
||||
#define BGC_ANGLE_UNIT_TURNS 3
|
||||
|
||||
typedef enum {
|
||||
/**
|
||||
* The measure of an angle with a range of:
|
||||
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
||||
*/
|
||||
BGC_ANGLE_RANGE_UNSIGNED = 1,
|
||||
/**
|
||||
* The measure of an angle with a range of:
|
||||
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
||||
*/
|
||||
#define BGC_ANGLE_RANGE_UNSIGNED 1
|
||||
|
||||
/**
|
||||
* The measure of an angle with a range of:
|
||||
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
|
||||
*/
|
||||
BGC_ANGLE_RANGE_SIGNED = 2
|
||||
} BgcAngleRangeEnum;
|
||||
/**
|
||||
* The measure of an angle with a range of:
|
||||
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
|
||||
*/
|
||||
#define BGC_ANGLE_RANGE_SIGNED 2
|
||||
|
||||
// !================= Radians ==================! //
|
||||
|
||||
// ========= Convert radians to degrees ========= //
|
||||
|
||||
inline float bgc_radians_to_degrees_fp32(const float radians)
|
||||
inline float bgc_fp32_radians_to_degrees(const float radians)
|
||||
{
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
return radians * BGC_FP32_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
inline double bgc_radians_to_degrees_fp64(const double radians)
|
||||
inline double bgc_fp64_radians_to_degrees(const double radians)
|
||||
{
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
return radians * BGC_FP64_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
// ========== Convert radians to turns ========== //
|
||||
|
||||
inline float bgc_radians_to_turns_fp32(const float radians)
|
||||
inline float bgc_fp32_radians_to_turns(const float radians)
|
||||
{
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
return radians * BGC_FP32_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
inline double bgc_radians_to_turns_fp64(const double radians)
|
||||
inline double bgc_fp64_radians_to_turns(const double radians)
|
||||
{
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
return radians * BGC_FP64_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
// ========= Convert radians to any unit ======== //
|
||||
|
||||
inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit)
|
||||
inline float bgc_fp32_radians_to_units(const float radians, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_FP32_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_FP32_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
return radians;
|
||||
}
|
||||
|
||||
inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit)
|
||||
inline double bgc_fp64_radians_to_units(const double radians, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_FP64_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_FP64_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
return radians;
|
||||
|
|
@ -104,103 +100,103 @@ inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnit
|
|||
|
||||
// ============ Normalize radians ============= //
|
||||
|
||||
inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range)
|
||||
inline float bgc_fp32_normalize_radians(const float radians, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= radians && radians < BGC_FP32_TWO_PI) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) {
|
||||
if (-BGC_FP32_PI < radians && radians <= BGC_FP32_PI) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
|
||||
float turns = radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
float turns = radians * BGC_FP32_TURNS_IN_RADIAN;
|
||||
|
||||
turns -= floorf(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
turns -= 1.0f;
|
||||
}
|
||||
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
return turns * BGC_FP32_TWO_PI;
|
||||
}
|
||||
|
||||
inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range)
|
||||
inline double bgc_fp64_normalize_radians(const double radians, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= radians && radians < BGC_FP64_TWO_PI) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) {
|
||||
if (-BGC_FP64_PI < radians && radians <= BGC_FP64_PI) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
|
||||
double turns = radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
double turns = radians * BGC_FP64_TURNS_IN_RADIAN;
|
||||
|
||||
turns -= floor(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
turns -= 1.0;
|
||||
}
|
||||
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
return turns * BGC_FP64_TWO_PI;
|
||||
}
|
||||
|
||||
// !================= Degrees ==================! //
|
||||
|
||||
// ========= Convert degrees to radians ========= //
|
||||
|
||||
inline float bgc_degrees_to_radians_fp32(const float degrees)
|
||||
inline float bgc_fp32_degrees_to_radians(const float degrees)
|
||||
{
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
return degrees * BGC_FP32_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
inline double bgc_degrees_to_radians_fp64(const double degrees)
|
||||
inline double bgc_fp64_degrees_to_radians(const double degrees)
|
||||
{
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
return degrees * BGC_FP64_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
// ========== Convert degrees to turns ========== //
|
||||
|
||||
inline float bgc_degrees_to_turns_fp32(const float radians)
|
||||
inline float bgc_fp32_degrees_to_turns(const float radians)
|
||||
{
|
||||
return radians * BGC_TURNS_IN_DEGREE_FP32;
|
||||
return radians * BGC_FP32_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
inline double bgc_degrees_to_turns_fp64(const double radians)
|
||||
inline double bgc_fp64_degrees_to_turns(const double radians)
|
||||
{
|
||||
return radians * BGC_TURNS_IN_DEGREE_FP64;
|
||||
return radians * BGC_FP64_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
// ========= Convert degreess to any unit ======== //
|
||||
|
||||
inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit)
|
||||
inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_FP32_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_FP32_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return degrees;
|
||||
}
|
||||
|
||||
inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit)
|
||||
inline double bgc_fp64_degrees_to_units(const double degrees, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_FP64_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_FP64_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return degrees;
|
||||
|
|
@ -208,9 +204,9 @@ inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnit
|
|||
|
||||
// ============ Normalize degrees ============= //
|
||||
|
||||
inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range)
|
||||
inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= degrees && degrees < 360.0f) {
|
||||
return degrees;
|
||||
}
|
||||
|
|
@ -221,20 +217,20 @@ inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRange
|
|||
}
|
||||
}
|
||||
|
||||
float turns = degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||
float turns = degrees * BGC_FP32_TURNS_IN_DEGREE;
|
||||
|
||||
turns -= floorf(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
turns -= 1.0f;
|
||||
}
|
||||
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range)
|
||||
inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= degrees && degrees < 360.0) {
|
||||
return degrees;
|
||||
}
|
||||
|
|
@ -245,11 +241,11 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
|
|||
}
|
||||
}
|
||||
|
||||
double turns = degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||
double turns = degrees * BGC_FP64_TURNS_IN_DEGREE;
|
||||
|
||||
turns -= floor(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
turns -= 1.0;
|
||||
}
|
||||
|
||||
|
|
@ -260,50 +256,50 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
|
|||
|
||||
// ========== Convert turns to radians ========== //
|
||||
|
||||
inline float bgc_turns_to_radians_fp32(const float turns)
|
||||
inline float bgc_fp32_turns_to_radians(const float turns)
|
||||
{
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
return turns * BGC_FP32_TWO_PI;
|
||||
}
|
||||
|
||||
inline double bgc_turns_to_radians_fp64(const double turns)
|
||||
inline double bgc_fp64_turns_to_radians(const double turns)
|
||||
{
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
return turns * BGC_FP64_TWO_PI;
|
||||
}
|
||||
|
||||
// ========== Convert turns to degrees ========== //
|
||||
|
||||
inline float bgc_turns_to_degrees_fp32(const float turns)
|
||||
inline float bgc_fp32_turns_to_degrees(const float turns)
|
||||
{
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
inline double bgc_turns_to_degrees_fp64(const double turns)
|
||||
inline double bgc_fp64_turns_to_degrees(const double turns)
|
||||
{
|
||||
return turns * 360.0;
|
||||
}
|
||||
|
||||
// ========= Convert turns to any unit ======== //
|
||||
|
||||
inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit)
|
||||
inline float bgc_fp32_turns_to_units(const float turns, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_FP32_TWO_PI;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
return turns;
|
||||
}
|
||||
|
||||
inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit)
|
||||
inline double bgc_fp64_turns_to_units(const double turns, const int angle_unit)
|
||||
{
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_FP64_TWO_PI;
|
||||
}
|
||||
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return turns * 360.0;
|
||||
}
|
||||
|
||||
|
|
@ -312,9 +308,9 @@ inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum
|
|||
|
||||
// ============= Normalize turns ============== //
|
||||
|
||||
inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range)
|
||||
inline float bgc_fp32_normalize_turns(const float turns, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= turns && turns < 1.0f) {
|
||||
return turns;
|
||||
}
|
||||
|
|
@ -327,16 +323,16 @@ inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum
|
|||
|
||||
float rest = turns - floorf(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
||||
return rest - 1.0f;
|
||||
}
|
||||
|
||||
return rest;
|
||||
}
|
||||
|
||||
inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range)
|
||||
inline double bgc_fp64_normalize_turns(const double turns, const int angle_range)
|
||||
{
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= turns && turns < 1.0) {
|
||||
return turns;
|
||||
}
|
||||
|
|
@ -349,7 +345,7 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
|
|||
|
||||
double rest = turns - floor(turns);
|
||||
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
||||
if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
||||
return rest - 1.0;
|
||||
}
|
||||
|
||||
|
|
@ -360,27 +356,27 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
|
|||
|
||||
// ========= Convert any unit to radians ======== //
|
||||
|
||||
inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit)
|
||||
inline float bgc_fp32_angle_to_radians(const float angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_FP32_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_TWO_PI_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_FP32_TWO_PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit)
|
||||
inline double bgc_fp64_angle_to_radians(const double angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_FP64_RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_TWO_PI_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_FP64_TWO_PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -388,26 +384,26 @@ inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEn
|
|||
|
||||
// ========= Convert any unit to degreess ======== //
|
||||
|
||||
inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit)
|
||||
inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_FP32_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * 360.0f;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit)
|
||||
inline double bgc_fp64_angle_to_degrees(const double angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_FP64_DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * 360.0;
|
||||
}
|
||||
|
||||
|
|
@ -416,27 +412,27 @@ inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEn
|
|||
|
||||
// ========= Convert any unit to turns ======== //
|
||||
|
||||
inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit)
|
||||
inline float bgc_fp32_angle_to_turns(const float angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_TURNS_IN_RADIAN_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_FP32_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_TURNS_IN_DEGREE_FP32;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_FP32_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit)
|
||||
inline double bgc_fp64_angle_to_turns(const double angle, const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_TURNS_IN_RADIAN_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_FP64_TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_TURNS_IN_DEGREE_FP64;
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_FP64_TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -444,114 +440,58 @@ inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum
|
|||
|
||||
// ============= Get Full Circle ============== //
|
||||
|
||||
inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit)
|
||||
inline float bgc_fp32_full_circle(const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 360.0f;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
return BGC_TWO_PI_FP32;
|
||||
return BGC_FP32_TWO_PI;
|
||||
}
|
||||
|
||||
inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit)
|
||||
inline double bgc_fp64_full_circle(const int angle_unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 360.0;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
// ============= Get Half Circle ============== //
|
||||
|
||||
inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 180.0f;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
return BGC_PI_FP32;
|
||||
}
|
||||
|
||||
inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 180.0;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
return BGC_PI_FP64;
|
||||
}
|
||||
|
||||
// ============= Get Half Circle ============== //
|
||||
|
||||
inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 90.0f;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
return BGC_HALF_OF_PI_FP32;
|
||||
}
|
||||
|
||||
inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 90.0;
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
return BGC_HALF_OF_PI_FP64;
|
||||
return BGC_FP64_TWO_PI;
|
||||
}
|
||||
|
||||
// ================ Normalize ================= //
|
||||
|
||||
inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
|
||||
inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_degrees_normalize_fp32(angle, range);
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_fp32_normalize_degrees(angle, angle_range);
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_turns_normalize_fp32(angle, range);
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_fp32_normalize_turns(angle, angle_range);
|
||||
}
|
||||
|
||||
return bgc_radians_normalize_fp32(angle, range);
|
||||
return bgc_fp32_normalize_radians(angle, angle_range);
|
||||
}
|
||||
|
||||
inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range)
|
||||
inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range)
|
||||
{
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_degrees_normalize_fp64(angle, range);
|
||||
if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_fp64_degrees_normalize(angle, angle_range);
|
||||
}
|
||||
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_turns_normalize_fp64(angle, range);
|
||||
if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_fp64_normalize_turns(angle, angle_range);
|
||||
}
|
||||
|
||||
return bgc_radians_normalize_fp64(angle, range);
|
||||
return bgc_fp64_normalize_radians(angle, angle_range);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue