arcade-physics
Version:
Use Arcade Physics without Phaser.
37 lines • 1.62 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Point_1 = __importDefault(require("../point/Point"));
/**
* Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle.
*
* @function Phaser.Geom.Ellipse.CircumferencePoint
* @since 3.0.0
*
* @generic {Phaser.Geom.Point} O - [out,$return]
*
* @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on.
* @param {number} angle - The angle from the center of the Ellipse 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.
*
* @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference.
*/
const CircumferencePoint = (ellipse, angle, out) => {
if (out === undefined) {
out = new Point_1.default();
}
const halfWidth = ellipse.width / 2;
const halfHeight = ellipse.height / 2;
out.x = ellipse.x + halfWidth * Math.cos(angle);
out.y = ellipse.y + halfHeight * Math.sin(angle);
return out;
};
exports.default = CircumferencePoint;
//# sourceMappingURL=CircumferencePoint.js.map