arcade-physics
Version:
Use Arcade Physics without Phaser.
29 lines • 1 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Calculate the distance between two sets of coordinates (points) to the power of `pow`.
*
* @function Phaser.Math.Distance.Power
* @since 3.0.0
*
* @param {number} x1 - The x coordinate of the first point.
* @param {number} y1 - The y coordinate of the first point.
* @param {number} x2 - The x coordinate of the second point.
* @param {number} y2 - The y coordinate of the second point.
* @param {number} pow - The exponent.
*
* @return {number} The distance between each point.
*/
const DistancePower = (x1, y1, x2, y2, pow) => {
if (pow === undefined) {
pow = 2;
}
return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow));
};
exports.default = DistancePower;
//# sourceMappingURL=DistancePower.js.map