Переименование проектов и оптимизация вычислений / Renaming of projects and optimization of computations
This commit is contained in:
parent
37d86bc4c1
commit
75e5c02609
36 changed files with 177 additions and 379 deletions
68
BasicGeometry/FP64Degrees.cs
Normal file
68
BasicGeometry/FP64Degrees.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
|
||||
/*
|
||||
* Author: Andrey Pokidov
|
||||
* Date: 18 Nov 2024
|
||||
*/
|
||||
|
||||
namespace BasicGeometry
|
||||
{
|
||||
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