2023-04-25 09:27:57 +00:00
|
|
|
using static System.Math;
|
2023-02-26 09:38:28 +00:00
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Units;
|
|
|
|
|
2023-06-13 11:03:49 +00:00
|
|
|
public sealed class Angle : Unit
|
2023-02-26 09:38:28 +00:00
|
|
|
{
|
2023-06-13 11:03:49 +00:00
|
|
|
public override String Symbol => "rad";
|
2023-02-26 09:38:28 +00:00
|
|
|
|
2023-06-13 11:03:49 +00:00
|
|
|
public Angle(Double value): base(Normalize(value))
|
2023-02-26 09:38:28 +00:00
|
|
|
{
|
|
|
|
}
|
2023-06-13 11:03:49 +00:00
|
|
|
|
|
|
|
private static Double Normalize(Double value)
|
|
|
|
{
|
|
|
|
var modulo = value % Tau; // tau is 2pi
|
|
|
|
|
|
|
|
return modulo > PI
|
|
|
|
? modulo - Tau
|
|
|
|
: modulo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static implicit operator Angle(Double d) => new Angle(d);
|
|
|
|
public static implicit operator Double(Angle d) => d.Value;
|
2023-02-26 09:38:28 +00:00
|
|
|
}
|