Files
2023-06-20 13:17:31 -05:00

39 lines
943 B
C#

namespace SmartPoint.Mathematics
{
public static class FloatExt
{
public static float NormalizeRadians(this ref float self)
{
var f = 0.5f;
if (self < 0f)
{
f = -0.5f;
}
self += ((self * 0.15915f + f) * -6.2832f);
return self;
}
public static float NormalizeDegrees(this ref float self)
{
var f = 0.5f;
if (self < 0f)
{
f = -0.5f;
}
self += ((self * 0.0027778f + f) * -360.0f);
return self;
}
public static float LerpDegrees(float a1, float a2, float s)
{
float diff = a2 - a1;
var f = 0.5f;
if (diff < 0f)
{
f = -0.5f;
}
return (diff + ((diff * 0.0027778f + f) * -360.0f)) * s + a1;
}
}
}