Большое переименование и рефакторинг углов / Big renaming and refactoring of angles
This commit is contained in:
parent
1afbf8c1d6
commit
72d06a23b2
38 changed files with 3819 additions and 3757 deletions
63
BGC/F32Turns.cs
Normal file
63
BGC/F32Turns.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
/*
|
||||
* Author: Andrey Pokidov
|
||||
* Date: 18 Nov 2024
|
||||
*/
|
||||
|
||||
namespace BGC
|
||||
{
|
||||
public class F32Turns
|
||||
{
|
||||
public static float ToRadians(float turns)
|
||||
{
|
||||
return turns * F32Radians.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 * F32Radians.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