Browse Source

Merge pull request #7307 from please-wait/dev

Added rotateAround method to Vector2
Mr.doob 9 years ago
parent
commit
6febf71066
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/math/Vector2.js

+ 11 - 0
src/math/Vector2.js

@@ -415,6 +415,17 @@ THREE.Vector2.prototype = {
 
 
 		return this;
 		return this;
 
 
+	},
+
+	rotateAround: function ( center, rotation ) {
+
+		var x = this.x - center.x,	y = this.y - center.y;
+
+		this.x = center.x + x * Math.cos(rotation) - y * Math.sin(rotation);
+		this.y = center.y + y * Math.cos(rotation) + x * Math.sin(rotation);
+
+		return this;
+
 	}
 	}
 
 
 };
 };