|
|
@ -19,8 +19,24 @@ namespace SemiColinGames { |
|
|
|
public static class FMath { |
|
|
|
public const float PI = (float) Math.PI; |
|
|
|
|
|
|
|
public static float DegToRad(float degrees) { |
|
|
|
return PI / 180 * degrees; |
|
|
|
private static float[] degToRad = new float[360]; |
|
|
|
|
|
|
|
static FMath() { |
|
|
|
for (int i = 0; i < degToRad.Length; i++) { |
|
|
|
degToRad[i] = PI / 180 * i; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Converts degrees to radians using a look-up table. Expects the input to be near [0, 360)
|
|
|
|
// and will loop for potentially a long while if that's not the case.
|
|
|
|
public static float DegToRad(int degrees) { |
|
|
|
while (degrees < 0) { |
|
|
|
degrees += 360; |
|
|
|
} |
|
|
|
while (degrees >= 360) { |
|
|
|
degrees -= 360; |
|
|
|
} |
|
|
|
return degToRad[degrees]; |
|
|
|
} |
|
|
|
|
|
|
|
public static float Sin(double degrees) { |
|
|
|