Большое переименование: замена префикса F на более корректный FP (Floating Point)
This commit is contained in:
parent
c66edd3432
commit
ebb0a73555
31 changed files with 483 additions and 483 deletions
68
BGC/FP64Degrees.cs
Normal file
68
BGC/FP64Degrees.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
|
||||
/*
|
||||
* Author: Andrey Pokidov
|
||||
* Date: 18 Nov 2024
|
||||
*/
|
||||
|
||||
namespace BGC
|
||||
{
|
||||
public class FP64Degrees
|
||||
{
|
||||
public const double RADIANS_IN_DEGREE = 1.74532925199432958E-2;
|
||||
public const double TURNS_IN_DEGREE = 2.77777777777777778E-3;
|
||||
|
||||
public static double ToRadians(double degrees)
|
||||
{
|
||||
return degrees * RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
public static double ToTurns(double degrees)
|
||||
{
|
||||
return degrees * TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
public static double ToUnits(double degrees, AngleUnit toUnit)
|
||||
{
|
||||
if (toUnit == AngleUnit.RADIANS)
|
||||
{
|
||||
return degrees * RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (toUnit == AngleUnit.TURNS)
|
||||
{
|
||||
return degrees * TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return degrees;
|
||||
}
|
||||
|
||||
public static double Normalize(double degrees, AngleRange range)
|
||||
{
|
||||
if (range == AngleRange.UNSIGNED_RANGE)
|
||||
{
|
||||
if (0.0 <= degrees && degrees < 360.0)
|
||||
{
|
||||
return degrees;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (-180.0 < degrees && degrees <= 180.0)
|
||||
{
|
||||
return degrees;
|
||||
}
|
||||
}
|
||||
|
||||
double turns = degrees * TURNS_IN_DEGREE;
|
||||
|
||||
turns -= Math.Floor(turns);
|
||||
|
||||
if (range == AngleRange.SIGNED_RANGE && turns > 0.5)
|
||||
{
|
||||
turns -= 1.0;
|
||||
}
|
||||
|
||||
return turns * 360.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue