Innovenergy_trunk/csharp/Lib/Units/Angle.cs

24 lines
534 B
C#

using static System.Math;
namespace InnovEnergy.Lib.Units;
public sealed class Angle : Unit
{
public override String Symbol => "rad";
public Angle(Double value): base(Normalize(value))
{
}
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;
}