Завершение большого переименования
This commit is contained in:
parent
120e651517
commit
3805354611
31 changed files with 1213 additions and 1255 deletions
|
|
@ -1,3 +1,3 @@
|
|||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,102 +1,102 @@
|
|||
#ifndef _BASIC_GEOMETRY_ANGLE_H_
|
||||
#define _BASIC_GEOMETRY_ANGLE_H_
|
||||
#ifndef _BGC_ANGLE_H_
|
||||
#define _BGC_ANGLE_H_
|
||||
|
||||
#include <math.h>
|
||||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#define FP32_PI 3.1415926536f
|
||||
#define FP32_TWO_PI 6.2831853072f
|
||||
#define FP32_HALF_OF_PI 1.5707963268f
|
||||
#define FP32_THIRD_OF_PI 1.0471975512f
|
||||
#define FP32_FOURTH_OF_PI 0.7853981634f
|
||||
#define FP32_SIXTH_OF_PI 0.5235987756f
|
||||
#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 FP32_DEGREES_IN_RADIAN 57.295779513f
|
||||
#define FP32_TURNS_IN_RADIAN 0.1591549431f
|
||||
#define FP32_RADIANS_IN_DEGREE 1.745329252E-2f
|
||||
#define FP32_TURNS_IN_DEGREE 2.7777777778E-3f
|
||||
#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 FP64_PI 3.14159265358979324
|
||||
#define FP64_TWO_PI 6.28318530717958648
|
||||
#define FP64_HALF_OF_PI 1.57079632679489662
|
||||
#define FP64_THIRD_OF_PI 1.04719755119659775
|
||||
#define FP64_FOURTH_OF_PI 0.78539816339744831
|
||||
#define FP64_SIXTH_OF_PI 0.523598775598298873
|
||||
#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 FP64_DEGREES_IN_RADIAN 57.2957795130823209
|
||||
#define FP64_TURNS_IN_RADIAN 0.159154943091895336
|
||||
#define FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
|
||||
#define FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
|
||||
#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
|
||||
|
||||
typedef enum {
|
||||
BG_ANGLE_UNIT_RADIANS = 1,
|
||||
BG_ANGLE_UNIT_DEGREES = 2,
|
||||
BG_ANGLE_UNIT_TURNS = 3
|
||||
} angle_unit_t;
|
||||
BGC_ANGLE_UNIT_RADIANS = 1,
|
||||
BGC_ANGLE_UNIT_DEGREES = 2,
|
||||
BGC_ANGLE_UNIT_TURNS = 3
|
||||
} bgc_angle_unit_t;
|
||||
|
||||
typedef enum {
|
||||
/**
|
||||
* The measure of an angle with a range of:
|
||||
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
|
||||
*/
|
||||
BG_ANGLE_RANGE_UNSIGNED = 1,
|
||||
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
|
||||
*/
|
||||
BG_ANGLE_RANGE_SIGNED = 2
|
||||
} angle_range_t;
|
||||
BGC_ANGLE_RANGE_SIGNED = 2
|
||||
} bgc_angle_range_t;
|
||||
|
||||
// !================= Radians ==================! //
|
||||
|
||||
// ========= Convert radians to degrees ========= //
|
||||
|
||||
inline float fp32_radians_to_degrees(const float radians)
|
||||
inline float bgc_radians_to_degrees_fp32(const float radians)
|
||||
{
|
||||
return radians * FP32_DEGREES_IN_RADIAN;
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_radians_to_degrees(const double radians)
|
||||
inline double bgc_radians_to_degrees_fp64(const double radians)
|
||||
{
|
||||
return radians * FP64_DEGREES_IN_RADIAN;
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
// ========== Convert radians to turns ========== //
|
||||
|
||||
inline float fp32_radians_to_turns(const float radians)
|
||||
inline float bgc_radians_to_turns_fp32(const float radians)
|
||||
{
|
||||
return radians * FP32_TURNS_IN_RADIAN;
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_radians_to_turns(const double radians)
|
||||
inline double bgc_radians_to_turns_fp64(const double radians)
|
||||
{
|
||||
return radians * FP64_TURNS_IN_RADIAN;
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
// ========= Convert radians to any unit ======== //
|
||||
|
||||
inline float fp32_radians_to_units(const float radians, const angle_unit_t to_unit)
|
||||
inline float bgc_radians_to_units_fp32(const float radians, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return radians * FP32_DEGREES_IN_RADIAN;
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return radians * FP32_TURNS_IN_RADIAN;
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
return radians;
|
||||
}
|
||||
|
||||
inline double fp64_radians_to_units(const double radians, const angle_unit_t to_unit)
|
||||
inline double bgc_radians_to_units_fp64(const double radians, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return radians * FP64_DEGREES_IN_RADIAN;
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return radians * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return radians * FP64_TURNS_IN_RADIAN;
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
return radians;
|
||||
|
|
@ -104,103 +104,103 @@ inline double fp64_radians_to_units(const double radians, const angle_unit_t to_
|
|||
|
||||
// ============ Normalize radians ============= //
|
||||
|
||||
inline float fp32_radians_normalize(const float radians, const angle_range_t range)
|
||||
inline float bgc_radians_normalize_fp32(const float radians, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= radians && radians < FP32_TWO_PI) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (-FP32_PI < radians && radians <= FP32_PI) {
|
||||
if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
|
||||
float turns = radians * FP32_TURNS_IN_RADIAN;
|
||||
float turns = radians * BGC_TURNS_IN_RADIAN_FP32;
|
||||
|
||||
turns -= floorf(turns);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
turns -= 1.0f;
|
||||
}
|
||||
|
||||
return turns * FP32_TWO_PI;
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_radians_normalize(const double radians, const angle_range_t range)
|
||||
inline double bgc_radians_normalize_fp64(const double radians, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= radians && radians < FP64_TWO_PI) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (-FP64_PI < radians && radians <= FP64_PI) {
|
||||
if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) {
|
||||
return radians;
|
||||
}
|
||||
}
|
||||
|
||||
double turns = radians * FP64_TURNS_IN_RADIAN;
|
||||
double turns = radians * BGC_TURNS_IN_RADIAN_FP64;
|
||||
|
||||
turns -= floor(turns);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
turns -= 1.0;
|
||||
}
|
||||
|
||||
return turns * FP64_TWO_PI;
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
// !================= Degrees ==================! //
|
||||
|
||||
// ========= Convert degrees to radians ========= //
|
||||
|
||||
inline float fp32_degrees_to_radians(const float degrees)
|
||||
inline float bgc_degrees_to_radians_fp32(const float degrees)
|
||||
{
|
||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_degrees_to_radians(const double degrees)
|
||||
inline double bgc_degrees_to_radians_fp64(const double degrees)
|
||||
{
|
||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
// ========== Convert degrees to turns ========== //
|
||||
|
||||
inline float fp32_degrees_to_turns(const float radians)
|
||||
inline float bgc_degrees_to_turns_fp32(const float radians)
|
||||
{
|
||||
return radians * FP32_TURNS_IN_DEGREE;
|
||||
return radians * BGC_TURNS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_degrees_to_turns(const double radians)
|
||||
{
|
||||
return radians * FP64_TURNS_IN_DEGREE;
|
||||
return radians * BGC_TURNS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
// ========= Convert degreess to any unit ======== //
|
||||
|
||||
inline float fp32_degrees_to_units(const float degrees, const angle_unit_t to_unit)
|
||||
inline float bgc_degrees_to_units_fp32(const float degrees, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * FP32_RADIANS_IN_DEGREE;
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return degrees * FP32_TURNS_IN_DEGREE;
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
return degrees;
|
||||
}
|
||||
|
||||
inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_unit)
|
||||
inline double bgc_degrees_to_units_fp64(const double degrees, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * FP64_RADIANS_IN_DEGREE;
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return degrees * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return degrees * FP64_TURNS_IN_DEGREE;
|
||||
if (to_unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
return degrees;
|
||||
|
|
@ -208,9 +208,9 @@ inline double fp64_degrees_to_units(const double degrees, const angle_unit_t to_
|
|||
|
||||
// ============ Normalize degrees ============= //
|
||||
|
||||
inline float fp32_degrees_normalize(const float degrees, const angle_range_t range)
|
||||
inline float bgc_degrees_normalize_fp32(const float degrees, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= degrees && degrees < 360.0f) {
|
||||
return degrees;
|
||||
}
|
||||
|
|
@ -221,20 +221,20 @@ inline float fp32_degrees_normalize(const float degrees, const angle_range_t ran
|
|||
}
|
||||
}
|
||||
|
||||
float turns = degrees * FP32_TURNS_IN_DEGREE;
|
||||
float turns = degrees * BGC_TURNS_IN_DEGREE_FP32;
|
||||
|
||||
turns -= floorf(turns);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
|
||||
turns -= 1.0f;
|
||||
}
|
||||
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
inline double fp64_degrees_normalize(const double degrees, const angle_range_t range)
|
||||
inline double bgc_degrees_normalize_fp64(const double degrees, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= degrees && degrees < 360.0) {
|
||||
return degrees;
|
||||
}
|
||||
|
|
@ -245,11 +245,11 @@ inline double fp64_degrees_normalize(const double degrees, const angle_range_t r
|
|||
}
|
||||
}
|
||||
|
||||
double turns = degrees * FP64_TURNS_IN_DEGREE;
|
||||
double turns = degrees * BGC_TURNS_IN_DEGREE_FP64;
|
||||
|
||||
turns -= floor(turns);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
|
||||
turns -= 1.0;
|
||||
}
|
||||
|
||||
|
|
@ -260,50 +260,50 @@ inline double fp64_degrees_normalize(const double degrees, const angle_range_t r
|
|||
|
||||
// ========== Convert turns to radians ========== //
|
||||
|
||||
inline float fp32_turns_to_radians(const float turns)
|
||||
inline float bgc_turns_to_radians_fp32(const float turns)
|
||||
{
|
||||
return turns * FP32_TWO_PI;
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_turns_to_radians(const double turns)
|
||||
inline double bgc_turns_to_radians_fp64(const double turns)
|
||||
{
|
||||
return turns * FP64_TWO_PI;
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
// ========== Convert turns to degrees ========== //
|
||||
|
||||
inline float fp32_turns_to_degrees(const float turns)
|
||||
inline float bgc_turns_to_degrees_fp32(const float turns)
|
||||
{
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
inline double fp64_turns_to_degrees(const double turns)
|
||||
inline double bgc_turns_to_degrees_fp64(const double turns)
|
||||
{
|
||||
return turns * 360.0;
|
||||
}
|
||||
|
||||
// ========= Convert turns to any unit ======== //
|
||||
|
||||
inline float fp32_turns_to_units(const float turns, const angle_unit_t to_unit)
|
||||
inline float bgc_turns_to_units_fp32(const float turns, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return turns * FP32_TWO_PI;
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_TWO_PI_FP32;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
return turns;
|
||||
}
|
||||
|
||||
inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit)
|
||||
inline double bgc_turns_to_units_fp64(const double turns, const bgc_angle_unit_t to_unit)
|
||||
{
|
||||
if (to_unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return turns * FP64_TWO_PI;
|
||||
if (to_unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return turns * BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
if (to_unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (to_unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return turns * 360.0;
|
||||
}
|
||||
|
||||
|
|
@ -312,9 +312,9 @@ inline double fp64_turns_to_units(const double turns, const angle_unit_t to_unit
|
|||
|
||||
// ============= Normalize turns ============== //
|
||||
|
||||
inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
||||
inline float bgc_turns_normalize_fp32(const float turns, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0f <= turns && turns < 1.0f) {
|
||||
return turns;
|
||||
}
|
||||
|
|
@ -327,16 +327,16 @@ inline float fp32_turns_normalize(const float turns, const angle_range_t range)
|
|||
|
||||
float rest = turns - floorf(turns);
|
||||
|
||||