Added coterminal angles.
This commit is contained in:
parent
3ee5f9b811
commit
631ee0ea92
@ -119,6 +119,31 @@ public struct Angle : IAbsolute<Angle>, IAverage<Angle>, IClamp<Angle>, ICloneab
|
|||||||
|
|
||||||
public object Clone() => new Angle(p_deg);
|
public object Clone() => new Angle(p_deg);
|
||||||
|
|
||||||
|
public Angle[] GetCoterminalAngles() => GetCoterminalAngles(Zero, Full);
|
||||||
|
public Angle[] GetCoterminalAngles(Angle lowerBound, Angle upperBound)
|
||||||
|
{
|
||||||
|
List<Angle> values = new();
|
||||||
|
|
||||||
|
Angle active = this;
|
||||||
|
|
||||||
|
// A little bit redundant but it's a fairly easy way to guarentee
|
||||||
|
// all coterminal angles are between the lower and upper bounds.
|
||||||
|
// Definitely not the most efficient approach.
|
||||||
|
while (active < upperBound) active += Full;
|
||||||
|
active -= Full;
|
||||||
|
|
||||||
|
while (active > lowerBound) active -= Full;
|
||||||
|
active += Full;
|
||||||
|
|
||||||
|
while (active < upperBound)
|
||||||
|
{
|
||||||
|
values.Add(active);
|
||||||
|
active += Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public float ValueFromType(Type type) => type switch
|
public float ValueFromType(Type type) => type switch
|
||||||
{
|
{
|
||||||
Type.Degrees => Degrees,
|
Type.Degrees => Degrees,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user