Skip to content

Commit 6febf71

Browse files
committed
Merge pull request mrdoob#7307 from please-wait/dev
Added rotateAround method to Vector2
2 parents 773e043 + 1ab154b commit 6febf71

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/math/Vector2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,17 @@ THREE.Vector2.prototype = {
415415

416416
return this;
417417

418+
},
419+
420+
rotateAround: function ( center, rotation ) {
421+
422+
var x = this.x - center.x, y = this.y - center.y;
423+
424+
this.x = center.x + x * Math.cos(rotation) - y * Math.sin(rotation);
425+
this.y = center.y + y * Math.cos(rotation) + x * Math.sin(rotation);
426+
427+
return this;
428+
418429
}
419430

420431
};

0 commit comments

Comments
 (0)