phaser/src/geom/circle/CircumferencePoint.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Point = require('../point/Point');
2016-12-29 00:17:20 +00:00
/**
2018-01-26 04:18:22 +00:00
* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
*
* @function Phaser.Geom.Circle.CircumferencePoint
* @since 3.0.0
*
* @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on.
2018-01-26 04:18:22 +00:00
* @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians.
* @param {Phaser.Geom.Point|object} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created.
2017-10-13 13:11:54 +00:00
*
2018-01-26 04:18:22 +00:00
* @return {Phaser.Geom.Point|object} A Point object where the `x` and `y` properties are the point on the circumference.
*/
2016-12-29 00:17:20 +00:00
var CircumferencePoint = function (circle, angle, out)
{
if (out === undefined) { out = new Point(); }
2016-12-29 00:17:20 +00:00
out.x = circle.x + (circle.radius * Math.cos(angle));
out.y = circle.y + (circle.radius * Math.sin(angle));
return out;
};
module.exports = CircumferencePoint;