mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 04:23:30 +00:00
16 lines
441 B
JavaScript
16 lines
441 B
JavaScript
// p = Point or any object with public x/y properties, the item to be rotated
|
|
// x/y = the coordinate to rotate around
|
|
// angle = radians
|
|
// distance = in px
|
|
|
|
var RotateAroundDistance = function (point, x, y, angle, distance)
|
|
{
|
|
var t = angle + Math.atan2(point.y - y, point.x - x);
|
|
|
|
point.x = x + (distance * Math.cos(t));
|
|
point.y = y + (distance * Math.sin(t));
|
|
|
|
return point;
|
|
};
|
|
|
|
module.exports = RotateAroundDistance;
|