Innovenergy_trunk/csharp/Lib/Units/Angle.cs

24 lines
534 B
C#
Raw Normal View History

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