Browse Source

Merge pull request #7355 from WestLangley/dev-cleanup

Vector2:rotateAround() clean up
Mr.doob 9 years ago
parent
commit
48d9b2051e
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/math/Vector2.js

+ 7 - 4
src/math/Vector2.js

@@ -417,12 +417,15 @@ THREE.Vector2.prototype = {
 
 	},
 
-	rotateAround: function ( center, rotation ) {
+	rotateAround: function ( center, angle ) {
 
-		var x = this.x - center.x,	y = this.y - center.y;
+		var c = Math.cos( angle ), s = Math.sin( angle );
 
-		this.x = center.x + x * Math.cos(rotation) - y * Math.sin(rotation);
-		this.y = center.y + y * Math.cos(rotation) + x * Math.sin(rotation);
+		var x = this.x - center.x;
+		var y = this.y - center.y;
+
+		this.x = x * c - y * s + center.x;
+		this.y = x * s + y * c + center.y;
 
 		return this;