Большая реорганизация проекта
This commit is contained in:
parent
233c027d46
commit
f3b0232dd4
35 changed files with 705 additions and 593 deletions
63
BasicGeometry/TurnFP32.cs
Normal file
63
BasicGeometry/TurnFP32.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
/*
|
||||
* Author: Andrey Pokidov
|
||||
* Date: 18 Nov 2024
|
||||
*/
|
||||
|
||||
namespace BasicGeometry
|
||||
{
|
||||
public class TurnFP32
|
||||
{
|
||||
public static float ToRadians(float turns)
|
||||
{
|
||||
return turns * RadianFP32.TWO_PI;
|
||||
}
|
||||
|
||||
public static float ToDegrees(float turns)
|
||||
{
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
public static float ToUnits(float turns, AngleUnit toUnit)
|
||||
{
|
||||
if (toUnit == AngleUnit.RADIANS)
|
||||
{
|
||||
return turns * RadianFP32.TWO_PI;
|
||||
}
|
||||
|
||||
if (toUnit == AngleUnit.DEGREES)
|
||||
{
|
||||
return turns * 360.0f;
|
||||
}
|
||||
|
||||
return turns;
|
||||
}
|
||||
|
||||
public static float Normalize(float turns, AngleRange range)
|
||||
{
|
||||
if (range == AngleRange.UNSIGNED_RANGE)
|
||||
{
|
||||
if (0.0f <= turns && turns < 1.0f)
|
||||
{
|
||||
return turns;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (-0.5f < turns && turns <= 0.5f)
|
||||
{
|
||||
return turns;
|
||||
}
|
||||
}
|
||||
|
||||
float rest = turns - MathF.Floor(turns);
|
||||
|
||||
if (range == AngleRange.SIGNED_RANGE && rest > 0.5f)
|
||||
{
|
||||
rest -= 1.0f;
|
||||
}
|
||||
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue