UNPKG

arcade-physics

Version:
43 lines 1.91 kB
"use strict"; /** * @author Florian Vazelle * @author Geoffrey Glaive * @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 GetLineToCircle_1 = __importDefault(require("./GetLineToCircle")); const TriangleToCircle_1 = __importDefault(require("./TriangleToCircle")); /** * Checks if a Triangle and a Circle intersect, and returns the intersection points as a Point object array. * * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. * * @function Phaser.Geom.Intersects.GetTriangleToCircle * @since 3.0.0 * * @param {Phaser.Geom.Triangle} triangle - The Triangle to check for intersection. * @param {Phaser.Geom.Circle} circle - The Circle to check for intersection. * @param {array} [out] - An optional array in which to store the points of intersection. * * @return {array} An array with the points of intersection if objects intersect, otherwise an empty array. */ const GetTriangleToCircle = (triangle, circle, out) => { if (out === undefined) { out = []; } if ((0, TriangleToCircle_1.default)(triangle, circle)) { const lineA = triangle.getLineA(); const lineB = triangle.getLineB(); const lineC = triangle.getLineC(); (0, GetLineToCircle_1.default)(lineA, circle, out); (0, GetLineToCircle_1.default)(lineB, circle, out); (0, GetLineToCircle_1.default)(lineC, circle, out); } return out; }; exports.default = GetTriangleToCircle; //# sourceMappingURL=GetTriangleToCircle.js.map