소스 검색

Vector2f: save 2 trig calculations in rotateAroundOrigin() (#1731)

Stephen Gold 3 년 전
부모
커밋
33e690bd33
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      jme3-core/src/main/java/com/jme3/math/Vector2f.java

+ 4 - 2
jme3-core/src/main/java/com/jme3/math/Vector2f.java

@@ -823,8 +823,10 @@ public final class Vector2f implements Savable, Cloneable, java.io.Serializable
         if (cw) {
             angle = -angle;
         }
-        float newX = FastMath.cos(angle) * x - FastMath.sin(angle) * y;
-        float newY = FastMath.sin(angle) * x + FastMath.cos(angle) * y;
+        float cos = FastMath.cos(angle);
+        float sin = FastMath.sin(angle);
+        float newX = cos * x - sin * y;
+        float newY = sin * x + cos * y;
         x = newX;
         y = newY;
     }