Завершение большого переименования
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);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
|
||||
return rest - 1.0f;
|
||||
}
|
||||
|
||||
return rest;
|
||||
}
|
||||
|
||||
inline double fp64_turns_normalize(const double turns, const angle_range_t range)
|
||||
inline double bgc_turns_normalize_fp64(const double turns, const bgc_angle_range_t range)
|
||||
{
|
||||
if (range == BG_ANGLE_RANGE_UNSIGNED) {
|
||||
if (range == BGC_ANGLE_RANGE_UNSIGNED) {
|
||||
if (0.0 <= turns && turns < 1.0) {
|
||||
return turns;
|
||||
}
|
||||
|
|
@ -349,7 +349,7 @@ inline double fp64_turns_normalize(const double turns, const angle_range_t range
|
|||
|
||||
double rest = turns - floor(turns);
|
||||
|
||||
if (range == BG_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
||||
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
|
||||
return rest - 1.0;
|
||||
}
|
||||
|
||||
|
|
@ -360,27 +360,27 @@ inline double fp64_turns_normalize(const double turns, const angle_range_t range
|
|||
|
||||
// ========= Convert any unit to radians ======== //
|
||||
|
||||
inline float fp32_angle_to_radians(const float angle, const angle_unit_t unit)
|
||||
inline float bgc_angle_to_radians_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return angle * FP32_RADIANS_IN_DEGREE;
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_RADIANS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return angle * FP32_TWO_PI;
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_TWO_PI_FP32;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
||||
inline double bgc_angle_to_radians_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return angle * FP64_RADIANS_IN_DEGREE;
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_RADIANS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return angle * FP64_TWO_PI;
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -388,26 +388,26 @@ inline double fp64_angle_to_radians(const double angle, const angle_unit_t unit)
|
|||
|
||||
// ========= Convert any unit to degreess ======== //
|
||||
|
||||
inline float fp32_angle_to_degrees(const float angle, const angle_unit_t unit)
|
||||
inline float bgc_angle_to_degrees_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return angle * FP32_DEGREES_IN_RADIAN;
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_DEGREES_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * 360.0f;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
||||
inline double bgc_angle_to_degrees_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return angle * FP64_DEGREES_IN_RADIAN;
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_DEGREES_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return angle * 360.0;
|
||||
}
|
||||
|
||||
|
|
@ -416,27 +416,27 @@ inline double fp64_angle_to_degrees(const double angle, const angle_unit_t unit)
|
|||
|
||||
// ========= Convert any unit to turns ======== //
|
||||
|
||||
inline float fp32_angle_to_turns(const float angle, const angle_unit_t unit)
|
||||
inline float bgc_angle_to_turns_fp32(const float angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return angle * FP32_TURNS_IN_RADIAN;
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_TURNS_IN_RADIAN_FP32;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return angle * FP32_TURNS_IN_DEGREE;
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_TURNS_IN_DEGREE_FP32;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
||||
inline double bgc_angle_to_turns_fp64(const double angle, const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_RADIANS) {
|
||||
return angle * FP64_TURNS_IN_RADIAN;
|
||||
if (unit == BGC_ANGLE_UNIT_RADIANS) {
|
||||
return angle * BGC_TURNS_IN_RADIAN_FP64;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return angle * FP64_TURNS_IN_DEGREE;
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return angle * BGC_TURNS_IN_DEGREE_FP64;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -444,114 +444,114 @@ inline double fp64_angle_to_turns(const double angle, const angle_unit_t unit)
|
|||
|
||||
// ============= Get Full Circle ============== //
|
||||
|
||||
inline float fp32_angle_get_full_circle(const angle_unit_t unit)
|
||||
inline float bgc_angle_get_full_circle_fp32(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 360.0f;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
return FP32_TWO_PI;
|
||||
return BGC_TWO_PI_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_angle_get_full_circle(const angle_unit_t unit)
|
||||
inline double bgc_angle_get_full_circle_fp64(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 360.0;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return FP64_TWO_PI;
|
||||
return BGC_TWO_PI_FP64;
|
||||
}
|
||||
|
||||
// ============= Get Half Circle ============== //
|
||||
|
||||
inline float fp32_angle_get_half_circle(const angle_unit_t unit)
|
||||
inline float bgc_angle_get_half_circle_fp32(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 180.0f;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
return FP32_PI;
|
||||
return BGC_PI_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_angle_get_half_circle(const angle_unit_t unit)
|
||||
inline double bgc_angle_get_half_circle_fp64(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 180.0;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
return FP64_PI;
|
||||
return BGC_PI_FP64;
|
||||
}
|
||||
|
||||
// ============= Get Half Circle ============== //
|
||||
|
||||
inline float fp32_angle_get_quater_circle(const angle_unit_t unit)
|
||||
inline float bgc_angle_get_quater_circle_fp32(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 90.0f;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
return FP32_HALF_OF_PI;
|
||||
return BGC_HALF_OF_PI_FP32;
|
||||
}
|
||||
|
||||
inline double fp64_angle_get_quater_circle(const angle_unit_t unit)
|
||||
inline double bgc_angle_get_quater_circle_fp64(const bgc_angle_unit_t unit)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return 90.0;
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
return FP64_HALF_OF_PI;
|
||||
return BGC_HALF_OF_PI_FP64;
|
||||
}
|
||||
|
||||
// ================ Normalize ================= //
|
||||
|
||||
inline float fp32_angle_normalize(const float angle, const angle_unit_t unit, const angle_range_t range)
|
||||
inline float bgc_angle_normalize_fp32(const float angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return fp32_degrees_normalize(angle, range);
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_degrees_normalize_fp32(angle, range);
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return fp32_turns_normalize(angle, range);
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_turns_normalize_fp32(angle, range);
|
||||
}
|
||||
|
||||
return fp32_radians_normalize(angle, range);
|
||||
return bgc_radians_normalize_fp32(angle, range);
|
||||
}
|
||||
|
||||
inline double fp64_angle_normalize(const double angle, const angle_unit_t unit, const angle_range_t range)
|
||||
inline double bgc_angle_normalize_fp64(const double angle, const bgc_angle_unit_t unit, const bgc_angle_range_t range)
|
||||
{
|
||||
if (unit == BG_ANGLE_UNIT_DEGREES) {
|
||||
return fp64_degrees_normalize(angle, range);
|
||||
if (unit == BGC_ANGLE_UNIT_DEGREES) {
|
||||
return bgc_degrees_normalize_fp64(angle, range);
|
||||
}
|
||||
|
||||
if (unit == BG_ANGLE_UNIT_TURNS) {
|
||||
return fp64_turns_normalize(angle, range);
|
||||
if (unit == BGC_ANGLE_UNIT_TURNS) {
|
||||
return bgc_turns_normalize_fp64(angle, range);
|
||||
}
|
||||
|
||||
return fp64_radians_normalize(angle, range);
|
||||
return bgc_radians_normalize_fp64(angle, range);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
<Unit filename="basis.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="basis.h" />
|
||||
<Unit filename="matrix2x2.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
|
@ -78,6 +77,7 @@
|
|||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="tangent.h" />
|
||||
<Unit filename="utilities.h" />
|
||||
<Unit filename="vector2.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __GEOMETRY_H__
|
||||
#define __GEOMETRY_H__
|
||||
#ifndef _BGC_H_
|
||||
#define _BGC_H_
|
||||
|
||||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
|
||||
#include "angle.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="angle.h" />
|
||||
<ClInclude Include="basis.h" />
|
||||
<ClInclude Include="basic-geometry.h" />
|
||||
<ClInclude Include="matrix2x2.h" />
|
||||
<ClInclude Include="matrix2x3.h" />
|
||||
|
|
@ -30,6 +29,7 @@
|
|||
<ClInclude Include="quaternion.h" />
|
||||
<ClInclude Include="rotation3.h" />
|
||||
<ClInclude Include="tangent.h" />
|
||||
<ClInclude Include="utilities.h" />
|
||||
<ClInclude Include="versor.h" />
|
||||
<ClInclude Include="vector2.h" />
|
||||
<ClInclude Include="vector3.h" />
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<ClInclude Include="angle.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="basis.h">
|
||||
<ClInclude Include="utilities.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="basic-geometry.h">
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
#ifndef _GEOMETRY_BASIS_H_
|
||||
#define _GEOMETRY_BASIS_H_
|
||||
|
||||
#define FP32_EPSYLON_EFFECTIVENESS_LIMIT 10.0f
|
||||
|
||||
#define FP32_EPSYLON 5E-7f
|
||||
#define FP32_TWO_EPSYLON 1E-6f
|
||||
#define FP32_SQUARE_EPSYLON 2.5E-13f
|
||||
|
||||
#define FP32_ONE_THIRD 0.333333333f
|
||||
#define FP32_ONE_SIXTH 0.166666667f
|
||||
#define FP32_ONE_NINETH 0.111111111f
|
||||
|
||||
#define FP32_GOLDEN_RATIO_HIGH 1.618034f
|
||||
#define FP32_GOLDEN_RATIO_LOW 0.618034f
|
||||
|
||||
#define FP64_EPSYLON_EFFECTIVENESS_LIMIT 10.0
|
||||
|
||||
#define FP64_EPSYLON 5E-14
|
||||
#define FP64_TWO_EPSYLON 1E-13
|
||||
#define FP64_SQUARE_EPSYLON 2.5E-27
|
||||
|
||||
#define FP64_ONE_THIRD 0.333333333333333333
|
||||
#define FP64_ONE_SIXTH 0.166666666666666667
|
||||
#define FP64_ONE_NINETH 0.111111111111111111
|
||||
|
||||
#define FP64_GOLDEN_RATIO_HIGH 1.61803398874989485
|
||||
#define FP64_GOLDEN_RATIO_LOW 0.61803398874989485
|
||||
|
||||
inline int fp32_are_equal(const float value1, const float value2)
|
||||
{
|
||||
if (-FP32_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return -FP32_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP32_EPSYLON;
|
||||
}
|
||||
|
||||
if (value1 < 0.0f) {
|
||||
return (1.0f + FP32_EPSYLON) * value2 <= value1 && (1.0f + FP32_EPSYLON) * value1 <= value2;
|
||||
}
|
||||
|
||||
return value2 <= value1 * (1.0f + FP32_EPSYLON) && value1 <= value2 * (1.0f + FP32_EPSYLON);
|
||||
}
|
||||
|
||||
inline int fp64_are_equal(const double value1, const double value2)
|
||||
{
|
||||
if (-FP64_EPSYLON_EFFECTIVENESS_LIMIT < value1 && value1 < FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return -FP64_EPSYLON <= (value1 - value2) && (value1 - value2) <= FP64_EPSYLON;
|
||||
}
|
||||
|
||||
if (value1 < 0.0) {
|
||||
return (1.0 + FP64_EPSYLON) * value2 <= value1 && (1.0 + FP64_EPSYLON) * value1 <= value2;
|
||||
}
|
||||
|
||||
return value2 <= value1 * (1.0 + FP64_EPSYLON) && value1 <= value2 * (1.0 + FP64_EPSYLON);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _BASIC_GEOMETRY_MATRIX2X2_H_
|
||||
#define _BASIC_GEOMETRY_MATRIX2X2_H_
|
||||
#ifndef _BGC_MATRIX2X2_H_
|
||||
#define _BGC_MATRIX2X2_H_
|
||||
|
||||
#include "angle.h"
|
||||
#include "vector2.h"
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
inline void matrix2x2_reset_fp32(matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_reset_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 0.0f;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -15,7 +15,7 @@ inline void matrix2x2_reset_fp32(matrix2x2_fp32_t* matrix)
|
|||
matrix->r2c2 = 0.0f;
|
||||
}
|
||||
|
||||
inline void matrix2x2_reset_fp64(matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_reset_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 0.0;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -25,7 +25,7 @@ inline void matrix2x2_reset_fp64(matrix2x2_fp64_t* matrix)
|
|||
|
||||
// ================== Identity ================== //
|
||||
|
||||
inline void matrix2x2_set_to_identity_fp32(matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_set_to_identity_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 1.0f;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -33,7 +33,7 @@ inline void matrix2x2_set_to_identity_fp32(matrix2x2_fp32_t* matrix)
|
|||
matrix->r2c2 = 1.0f;
|
||||
}
|
||||
|
||||
inline void matrix2x2_set_to_identity_fp64(matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_set_to_identity_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = 1.0;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -43,7 +43,7 @@ inline void matrix2x2_set_to_identity_fp64(matrix2x2_fp64_t* matrix)
|
|||
|
||||
// ================ Make Diagonal =============== //
|
||||
|
||||
inline void matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = d1;
|
||||
matrix->r1c2 = 0.0f;
|
||||
|
|
@ -51,7 +51,7 @@ inline void matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, matri
|
|||
matrix->r2c2 = d2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = d1;
|
||||
matrix->r1c2 = 0.0;
|
||||
|
|
@ -61,9 +61,9 @@ inline void matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, mat
|
|||
|
||||
// ============== Rotation Matrix =============== //
|
||||
|
||||
inline void matrix2x2_make_rotation_fp32(const float angle, const angle_unit_t unit, matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
const float radians = fp32_angle_to_radians(angle, unit);
|
||||
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
||||
const float cosine = cosf(radians);
|
||||
const float sine = sinf(radians);
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ inline void matrix2x2_make_rotation_fp32(const float angle, const angle_unit_t u
|
|||
matrix->r2c2 = cosine;
|
||||
}
|
||||
|
||||
inline void matrix2x2_make_rotation_fp64(const double angle, const angle_unit_t unit, matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const bgc_angle_unit_t unit, bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
const double radians = fp64_angle_to_radians(angle, unit);
|
||||
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
||||
const double cosine = cos(radians);
|
||||
const double sine = sin(radians);
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ inline void matrix2x2_make_rotation_fp64(const double angle, const angle_unit_t
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void matrix2x2_copy_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
||||
inline void bgc_matrix2x2_copy_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -96,7 +96,7 @@ inline void matrix2x2_copy_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t*
|
|||
to->r2c2 = from->r2c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_copy_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
||||
inline void bgc_matrix2x2_copy_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -107,7 +107,7 @@ inline void matrix2x2_copy_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t*
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void matrix2x2_swap_fp32(matrix2x2_fp32_t* matrix1, matrix2x2_fp32_t* matrix2)
|
||||
inline void bgc_matrix2x2_swap_fp32(bgc_matrix2x2_fp32_t* matrix1, bgc_matrix2x2_fp32_t* matrix2)
|
||||
{
|
||||
const float r1c1 = matrix2->r1c1;
|
||||
const float r1c2 = matrix2->r1c2;
|
||||
|
|
@ -128,7 +128,7 @@ inline void matrix2x2_swap_fp32(matrix2x2_fp32_t* matrix1, matrix2x2_fp32_t* mat
|
|||
matrix1->r2c2 = r2c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_swap_fp64(matrix2x2_fp64_t* matrix1, matrix2x2_fp64_t* matrix2)
|
||||
inline void bgc_matrix2x2_swap_fp64(bgc_matrix2x2_fp64_t* matrix1, bgc_matrix2x2_fp64_t* matrix2)
|
||||
{
|
||||
const double r1c1 = matrix2->r1c1;
|
||||
const double r1c2 = matrix2->r1c2;
|
||||
|
|
@ -151,7 +151,7 @@ inline void matrix2x2_swap_fp64(matrix2x2_fp64_t* matrix1, matrix2x2_fp64_t* mat
|
|||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
inline void matrix2x2_convert_fp64_to_fp32(const matrix2x2_fp64_t* from, matrix2x2_fp32_t* to)
|
||||
inline void bgc_matrix2x2_convert_fp64_to_fp32(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp32_t* to)
|
||||
{
|
||||
to->r1c1 = (float)from->r1c1;
|
||||
to->r1c2 = (float)from->r1c2;
|
||||
|
|
@ -160,7 +160,7 @@ inline void matrix2x2_convert_fp64_to_fp32(const matrix2x2_fp64_t* from, matrix2
|
|||
to->r2c2 = (float)from->r2c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_convert_fp32_to_fp64(const matrix2x2_fp32_t* from, matrix2x2_fp64_t* to)
|
||||
inline void bgc_matrix2x2_convert_fp32_to_fp64(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp64_t* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
|
|
@ -171,42 +171,42 @@ inline void matrix2x2_convert_fp32_to_fp64(const matrix2x2_fp32_t* from, matrix2
|
|||
|
||||
// ================ Determinant ================= //
|
||||
|
||||
inline float matrix2x2_get_determinant_fp32(const matrix2x2_fp32_t* matrix)
|
||||
inline float bgc_matrix2x2_get_determinant_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||
}
|
||||
|
||||
inline double matrix2x2_get_determinant_fp64(const matrix2x2_fp64_t* matrix)
|
||||
inline double bgc_matrix2x2_get_determinant_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||
}
|
||||
|
||||
// ================== Singular ================== //
|
||||
|
||||
inline int matrix2x2_is_singular_fp32(const matrix2x2_fp32_t* matrix)
|
||||
inline int bgc_matrix2x2_is_singular_fp32(const bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
const float determinant = matrix2x2_get_determinant_fp32(matrix);
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
return -FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON;
|
||||
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||
}
|
||||
|
||||
inline int matrix2x2_is_singular_fp64(const matrix2x2_fp64_t* matrix)
|
||||
inline int bgc_matrix2x2_is_singular_fp64(const bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
const double determinant = matrix2x2_get_determinant_fp64(matrix);
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
return -FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON;
|
||||
return -BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64;
|
||||
}
|
||||
|
||||
// =============== Transposition ================ //
|
||||
|
||||
inline void matrix2x2_transpose_fp32(matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_transpose_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
const float tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
matrix->r2c1 = tmp;
|
||||
}
|
||||
|
||||
inline void matrix2x2_transpose_fp64(matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_transpose_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
const double tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
|
|
@ -215,11 +215,11 @@ inline void matrix2x2_transpose_fp64(matrix2x2_fp64_t* matrix)
|
|||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
inline int matrix2x2_invert_fp32(matrix2x2_fp32_t* matrix)
|
||||
inline int bgc_matrix2x2_invert_fp32(bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
const float determinant = matrix2x2_get_determinant_fp32(matrix);
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -240,11 +240,11 @@ inline int matrix2x2_invert_fp32(matrix2x2_fp32_t* matrix)
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int matrix2x2_invert_fp64(matrix2x2_fp64_t* matrix)
|
||||
inline int bgc_matrix2x2_invert_fp64(bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
const double determinant = matrix2x2_get_determinant_fp64(matrix);
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ inline int matrix2x2_invert_fp64(matrix2x2_fp64_t* matrix)
|
|||
|
||||
// =============== Set Transposed =============== //
|
||||
|
||||
inline void matrix2x2_set_transposed_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
||||
inline void bgc_matrix2x2_set_transposed_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||
{
|
||||
float tmp = from->r1c2;
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ inline void matrix2x2_set_transposed_fp32(const matrix2x2_fp32_t* from, matrix2x
|
|||
to->r2c2 = from->r2c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_set_transposed_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
||||
inline void bgc_matrix2x2_set_transposed_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||
{
|
||||
double tmp = from->r1c2;
|
||||
|
||||
|
|
@ -291,11 +291,11 @@ inline void matrix2x2_set_transposed_fp64(const matrix2x2_fp64_t* from, matrix2x
|
|||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
inline int matrix2x2_set_inverted_fp32(const matrix2x2_fp32_t* from, matrix2x2_fp32_t* to)
|
||||
inline int bgc_matrix2x2_set_inverted_fp32(const bgc_matrix2x2_fp32_t* from, bgc_matrix2x2_fp32_t* to)
|
||||
{
|
||||
const float determinant = matrix2x2_get_determinant_fp32(from);
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
||||
|
||||
if (-FP32_EPSYLON <= determinant && determinant <= FP32_EPSYLON) {
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -316,11 +316,11 @@ inline int matrix2x2_set_inverted_fp32(const matrix2x2_fp32_t* from, matrix2x2_f
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int matrix2x2_set_inverted_fp64(const matrix2x2_fp64_t* from, matrix2x2_fp64_t* to)
|
||||
inline int bgc_matrix2x2_set_inverted_fp64(const bgc_matrix2x2_fp64_t* from, bgc_matrix2x2_fp64_t* to)
|
||||
{
|
||||
const double determinant = matrix2x2_get_determinant_fp64(from);
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
||||
|
||||
if (-FP64_EPSYLON <= determinant && determinant <= FP64_EPSYLON) {
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -343,13 +343,13 @@ inline int matrix2x2_set_inverted_fp64(const matrix2x2_fp64_t* from, matrix2x2_f
|
|||
|
||||
// ================= Set Row 1 ================== //
|
||||
|
||||
inline void matrix2x2_set_row1_fp32(const float c1, const float c2, matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = c1;
|
||||
matrix->r1c2 = c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_set_row1_fp64(const double c1, const double c2, matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r1c1 = c1;
|
||||
matrix->r1c2 = c2;
|
||||
|
|
@ -357,13 +357,13 @@ inline void matrix2x2_set_row1_fp64(const double c1, const double c2, matrix2x2_
|
|||
|
||||
// ================= Set Row 2 ================== //
|
||||
|
||||
inline void matrix2x2_set_row2_fp32(const float c1, const float c2, matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||
matrix->r2c1 = c1;
|
||||
matrix->r2c2 = c2;
|
||||
}
|
||||
|
||||
inline void matrix2x2_set_row2_fp64(const double c1, const double c2, matrix2x2_fp64_t* matrix)
|
||||
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, bgc_matrix2x2_fp64_t* matrix)
|
||||
{
|
||||
matrix->r2c1 = c1;
|
||||
matrix->r2c2 = c2;
|
||||
|
|
@ -371,13 +371,13 @@ inline void matrix2x2_set_row2_fp64(const double c1, const double c2, matrix2x2_
|
|||
|
||||
// ================ Set Column 1 ================ //
|
||||
|
||||
inline void matrix2x2_set_column1_fp32(const float r1, const float r2, matrix2x2_fp32_t* matrix)
|
||||
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, bgc_matrix2x2_fp32_t* matrix)
|
||||
{
|
||||