OSDN Git Service

[unfucked] Restored sin/cos LUT with special cased cardinal angles.
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 9 Feb 2011 10:55:10 +0000 (10:55 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 9 Feb 2011 10:55:10 +0000 (10:55 +0000)
gdx/src/com/badlogic/gdx/utils/MathUtils.java

index 25d85aa..8ec2917 100644 (file)
@@ -37,33 +37,33 @@ public class MathUtils {
 \r
        static public final float[] sin = new float[SIN_COUNT];\r
        static public final float[] cos = new float[SIN_COUNT];\r
-       \r
+\r
        static {\r
                for (int i = 0; i < SIN_COUNT; i++) {\r
                        float a = (i + 0.5f) / SIN_COUNT * radFull;\r
                        sin[i] = (float)Math.sin(a);\r
                        cos[i] = (float)Math.cos(a);\r
                }\r
+               for (int i = 0; i < 360; i += 90) {\r
+                       sin[(int)(i * degToIndex) & SIN_MASK] = (float)Math.sin(i * degreesToRadians);\r
+                       cos[(int)(i * degToIndex) & SIN_MASK] = (float)Math.cos(i * degreesToRadians);\r
+               }\r
        }\r
 \r
        static public final float sin (float rad) {\r
-               return (float)Math.sin(rad);\r
-//             return sin[(int)(rad * radToIndex) & SIN_MASK];\r
+               return sin[(int)(rad * radToIndex) & SIN_MASK];\r
        }\r
 \r
        static public final float cos (float rad) {\r
-               return (float)Math.cos(rad);\r
-//             return cos[(int)(rad * radToIndex) & SIN_MASK];\r
+               return cos[(int)(rad * radToIndex) & SIN_MASK];\r
        }\r
 \r
        static public final float sinDeg (float deg) {\r
-               return (float)Math.sin(degreesToRadians * deg);\r
-//             return sin[(int)(deg * degToIndex) & SIN_MASK];\r
+               return sin[(int)(deg * degToIndex) & SIN_MASK];\r
        }\r
 \r
        static public final float cosDeg (float deg) {\r
-               return (float)Math.cos(degreesToRadians * deg);\r
-//             return cos[(int)(deg * degToIndex) & SIN_MASK];\r
+               return cos[(int)(deg * degToIndex) & SIN_MASK];\r
        }\r
 \r
        // ---\r