Skip to content

Commit 48d9b20

Browse files
committed
Merge pull request mrdoob#7355 from WestLangley/dev-cleanup
Vector2:rotateAround() clean up
2 parents d36df79 + 56723ec commit 48d9b20

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/math/Vector2.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,15 @@ THREE.Vector2.prototype = {
417417

418418
},
419419

420-
rotateAround: function ( center, rotation ) {
420+
rotateAround: function ( center, angle ) {
421421

422-
var x = this.x - center.x, y = this.y - center.y;
422+
var c = Math.cos( angle ), s = Math.sin( angle );
423423

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);
424+
var x = this.x - center.x;
425+
var y = this.y - center.y;
426+
427+
this.x = x * c - y * s + center.x;
428+
this.y = x * s + y * c + center.y;
426429

427430
return this;
428431

0 commit comments

Comments
 (0)