From b6bd40e291b345e537af15e13f91068475ee242f Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 5 May 2019 10:30:49 +0800 Subject: [PATCH] - Docs: Use jsdoc modules --- dist/index-esm.js | 510 ++++++++++++++++++++------------------ dist/index-esm.min.js.map | 2 +- dist/index-umd.js | 510 ++++++++++++++++++++------------------ dist/index-umd.min.js.map | 2 +- index.js | 61 ++++- lib/AffineShapes.js | 55 ++-- lib/Intersection.js | 389 ++++++++++++++--------------- lib/IntersectionArgs.js | 8 +- lib/IntersectionQuery.js | 26 +- lib/Shapes.js | 24 +- 10 files changed, 842 insertions(+), 745 deletions(-) diff --git a/dist/index-esm.js b/dist/index-esm.js index 74ba50f..99df64b 100644 --- a/dist/index-esm.js +++ b/dist/index-esm.js @@ -2021,7 +2021,7 @@ SqrtPolynomial.prototype.toString = function () { var Polynomial = Polynomial_1; /** - * + * @memberof module:kld-intersections.Intersection~ * @param {*} o * @returns {boolean} */ @@ -2031,9 +2031,9 @@ function isNullish(o) { } /** * closePolygon - * - * @param {Array} points - * @returns {Array} + * @memberof module:kld-intersections.Intersection~ + * @param {Array} points + * @returns {Array} */ @@ -2043,7 +2043,8 @@ function closePolygon(points) { return copy; } /** - * Intersection + * Intersection + * @memberof module:kld-intersections */ @@ -2052,6 +2053,7 @@ var Intersection = function () { /** * @param {string} status + * @returns {module:kld-intersections.Intersection} */ function Intersection(status) { _classCallCheck(this, Intersection); @@ -2062,7 +2064,7 @@ function () { * init * * @param {string} status - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2075,7 +2077,7 @@ function () { /** * appendPoint * - * @param {Point2D} point + * @param {module:kld-intersections.Point2D} point */ }, { @@ -2086,7 +2088,7 @@ function () { /** * appendPoints * - * @param {Array} points + * @param {Array} points */ }, { @@ -2102,9 +2104,9 @@ function () { /** * intersect * - * @param {IntersectionArgs} shape1 - * @param {IntersectionArgs} shape2 - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} shape1 + * @param {module:kld-intersections.IntersectionArgs} shape2 + * @returns {module:kld-intersections.Intersection} */ @@ -2143,9 +2145,9 @@ Intersection.intersect = function (shape1, shape2) { /** * intersectPathShape * - * @param {IntersectionArgs} path - * @param {IntersectionArgs} shape - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} path + * @param {module:kld-intersections.IntersectionArgs} shape + * @returns {module:kld-intersections.Intersection} */ @@ -2185,13 +2187,13 @@ Intersection.intersectPathShape = function (path, shape) { /** * intersectBezier2Bezier2 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @returns {module:kld-intersections.Intersection} */ @@ -2297,14 +2299,14 @@ Intersection.intersectBezier2Bezier2 = function (a1, a2, a3, b1, b2, b3) { /** * intersectBezier2Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ @@ -2417,12 +2419,12 @@ Intersection.intersectBezier2Bezier3 = function (a1, a2, a3, b1, b2, b3, b4) { /** * intersectBezier2Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2432,13 +2434,13 @@ Intersection.intersectBezier2Circle = function (p1, p2, p3, c, r) { /** * intersectBezier2Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2492,12 +2494,12 @@ Intersection.intersectBezier2Ellipse = function (p1, p2, p3, ec, rx, ry) { /** * intersectBezier2Line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -2582,11 +2584,11 @@ Intersection.intersectBezier2Line = function (p1, p2, p3, a1, a2) { /** * intersectBezier2Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -2596,11 +2598,11 @@ Intersection.intersectBezier2Polygon = function (p1, p2, p3, points) { /** * intersectBezier2Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -2624,12 +2626,12 @@ Intersection.intersectBezier2Polyline = function (p1, p2, p3, points) { /** * intersectBezier2Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -2657,15 +2659,15 @@ Intersection.intersectBezier2Rectangle = function (p1, p2, p3, r1, r2) { /** * intersectBezier3Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} a4 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} a4 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ @@ -2811,13 +2813,13 @@ Intersection.intersectBezier3Bezier3 = function (a1, a2, a3, a4, b1, b2, b3, b4) /** * intersectBezier3Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2827,14 +2829,14 @@ Intersection.intersectBezier3Circle = function (p1, p2, p3, p4, c, r) { /** * intersectBezier3Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2900,13 +2902,13 @@ Intersection.intersectBezier3Ellipse = function (p1, p2, p3, p4, ec, rx, ry) { * sketch of the algorithm used here. Without his help, I'm not sure when I * would have figured out this intersection problem. * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3013,12 +3015,12 @@ Intersection.intersectBezier3Line = function (p1, p2, p3, p4, a1, a2) { /** * intersectBezier3Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3028,12 +3030,12 @@ Intersection.intersectBezier3Polygon = function (p1, p2, p3, p4, points) { /** * intersectBezier3Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3057,13 +3059,13 @@ Intersection.intersectBezier3Polyline = function (p1, p2, p3, p4, points) { /** * intersectBezier3Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3091,11 +3093,11 @@ Intersection.intersectBezier3Rectangle = function (p1, p2, p3, p4, r1, r2) { /** * intersectCircleCircle * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} r1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} r2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3126,12 +3128,12 @@ Intersection.intersectCircleCircle = function (c1, r1, c2, r2) { /** * intersectCircleEllipse * - * @param {Point2D} cc + * @param {module:kld-intersections.Point2D} cc * @param {number} r - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3141,11 +3143,11 @@ Intersection.intersectCircleEllipse = function (cc, r, ec, rx, ry) { /** * intersectCircleLine * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3189,10 +3191,10 @@ Intersection.intersectCircleLine = function (c, r, a1, a2) { /** * intersectCirclePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3202,10 +3204,10 @@ Intersection.intersectCirclePolygon = function (c, r, points) { /** * intersectCirclePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3232,11 +3234,11 @@ Intersection.intersectCirclePolyline = function (c, r, points) { /** * intersectCircleRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3272,13 +3274,13 @@ Intersection.intersectCircleRectangle = function (c, r, r1, r2) { * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} rx1 * @param {number} ry1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} rx2 * @param {number} ry2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3320,12 +3322,12 @@ Intersection.intersectEllipseEllipse = function (c1, rx1, ry1, c2, rx2, ry2) { * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3383,11 +3385,11 @@ Intersection.intersectEllipseLine = function (c, rx, ry, a1, a2) { /** * intersectEllipsePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3397,11 +3399,11 @@ Intersection.intersectEllipsePolygon = function (c, rx, ry, points) { /** * intersectEllipsePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3425,12 +3427,12 @@ Intersection.intersectEllipsePolyline = function (c, rx, ry, points) { /** * intersectEllipseRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3458,11 +3460,11 @@ Intersection.intersectEllipseRectangle = function (c, rx, ry, r1, r2) { /** * intersectLineLine * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3493,10 +3495,10 @@ Intersection.intersectLineLine = function (a1, a2, b1, b2) { /** * intersectLinePolygon * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3506,10 +3508,10 @@ Intersection.intersectLinePolygon = function (a1, a2, points) { /** * intersectLinePolyline * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3533,11 +3535,11 @@ Intersection.intersectLinePolyline = function (a1, a2, points) { /** * intersectLineRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3565,9 +3567,9 @@ Intersection.intersectLineRectangle = function (a1, a2, r1, r2) { /** * intersectPolygonPolygon * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3577,9 +3579,9 @@ Intersection.intersectPolygonPolygon = function (points1, points2) { /** * intersectPolygonPolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3589,10 +3591,10 @@ Intersection.intersectPolygonPolyline = function (points1, points2) { /** * intersectPolygonRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3602,9 +3604,9 @@ Intersection.intersectPolygonRectangle = function (points, r1, r2) { /** * intersectPolylinePolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3628,10 +3630,10 @@ Intersection.intersectPolylinePolyline = function (points1, points2) { /** * intersectPolylineRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3659,11 +3661,11 @@ Intersection.intersectPolylineRectangle = function (points, r1, r2) { /** * intersectRectangleRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3691,11 +3693,11 @@ Intersection.intersectRectangleRectangle = function (a1, a2, b1, b2) { /** * intersectRayRay * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3724,9 +3726,9 @@ Intersection.intersectRayRay = function (a1, a2, b1, b2) { * code along with many other excellent examples are avaiable at his site: * http://www.magic-software.com * - * @param {Array} e1 - * @param {Array} e2 - * @returns {Polynomial} + * @param {Array} e1 + * @param {Array} e2 + * @returns {external:Polynomial} */ @@ -3757,15 +3759,15 @@ Intersection.bezout = function (e1, e2) { /** * IntersectionArgs - * + * @memberof module:kld-intersections */ var IntersectionArgs = /*#__PURE__*/ function () { /** * @param {string} name - * @param {Array} args - * @returns {IntersectionArgs} + * @param {Array} args + * @returns {module:kld-intersections.IntersectionArgs} */ function IntersectionArgs(name, args) { _classCallCheck(this, IntersectionArgs); @@ -3776,7 +3778,7 @@ function () { * init * * @param {string} name - * @param {Array} args + * @param {Array} args */ @@ -3795,7 +3797,12 @@ function () { * Shapes * * @copyright 2017, Kevin Lindsey + * @module Shapes + */ +/** + * @namespace */ + var Shapes = {}; /** * quadraticBezier @@ -3806,7 +3813,7 @@ var Shapes = {}; * @param {number} p2y * @param {number} p3x * @param {number} p3y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.quadraticBezier = function (p1x, p1y, p2x, p2y, p3x, p3y) { @@ -3823,7 +3830,7 @@ Shapes.quadraticBezier = function (p1x, p1y, p2x, p2y, p3x, p3y) { * @param {number} p3y * @param {number} p4x * @param {number} p4y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3836,7 +3843,7 @@ Shapes.cubicBezier = function (p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) { * @param {number} centerX * @param {number} centerY * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3850,7 +3857,7 @@ Shapes.circle = function (centerX, centerY, radius) { * @param {number} centerY * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3864,7 +3871,7 @@ Shapes.ellipse = function (centerX, centerY, radiusX, radiusY) { * @param {number} p1y * @param {number} p2x * @param {number} p2y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3874,8 +3881,8 @@ Shapes.line = function (p1x, p1y, p2x, p2y) { /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3886,7 +3893,7 @@ Shapes.path = function (segments) { * polygon * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3903,7 +3910,7 @@ Shapes.polygon = function (coords) { * polyline * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3923,7 +3930,7 @@ Shapes.polyline = function (coords) { * @param {number} y * @param {number} width * @param {number} height - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3935,15 +3942,19 @@ Shapes.rectangle = function (x, y, width, height) { * AffineShapes * * @copyright 2017, Kevin Lindsey + * @module AffineShapes + */ +/** + * @namespace */ + var AffineShapes = {}; /** * quadraticBezier - * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.quadraticBezier = function (p1, p2, p3) { @@ -3952,11 +3963,11 @@ AffineShapes.quadraticBezier = function (p1, p2, p3) { /** * cubicBezier * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3966,9 +3977,9 @@ AffineShapes.cubicBezier = function (p1, p2, p3, p4) { /** * circle * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3978,10 +3989,10 @@ AffineShapes.circle = function (center, radius) { /** * ellipse * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3991,9 +4002,9 @@ AffineShapes.ellipse = function (center, radiusX, radiusY) { /** * line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4003,8 +4014,8 @@ AffineShapes.line = function (p1, p2) { /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4014,8 +4025,8 @@ AffineShapes.path = function (segments) { /** * polygon * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4025,8 +4036,8 @@ AffineShapes.polygon = function (points) { /** * polyline * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4036,9 +4047,9 @@ AffineShapes.polyline = function (points) { /** * rectangle * - * @param {Point2D} topLeft - * @param {Vector2D} size - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Vector2D} size + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4051,18 +4062,18 @@ AffineShapes.rectangle = function (topLeft, size) { * IntersectionQuery.js * * @copyright 2017 Kevin Lindsey - * + * @module IntersectionQuery */ /** - * + * @namespace */ var IntersectionQuery = {}; /** * pointInCircle * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radius * @returns {boolean} */ @@ -4074,8 +4085,8 @@ IntersectionQuery.pointInCircle = function (point, center, radius) { /** * pointInEllipse * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY * @returns {boolean} @@ -4089,8 +4100,8 @@ IntersectionQuery.pointInEllipse = function (point, center, radiusX, radiusY) { /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ @@ -4122,8 +4133,8 @@ IntersectionQuery.pointInPolyline = function (point, points) { /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ @@ -4131,9 +4142,9 @@ IntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline; /** * pointInRectangle * - * @param {Point2D} point - * @param {Point2D} topLeft - * @param {Point2D} bottomRight + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Point2D} bottomRight * @returns {boolean} */ @@ -4141,6 +4152,11 @@ IntersectionQuery.pointInRectangle = function (point, topLeft, bottomRight) { return topLeft.x <= point.x && point.x < bottomRight.x && topLeft.y <= point.y && point.y < bottomRight.y; }; -// expose module classes +/** + * @module kld-intersections + */ +/** +* @external Polynomial +*/ export { AffineShapes, Intersection, IntersectionArgs, IntersectionQuery, Matrix2D, Point2D, Shapes, Vector2D }; diff --git a/dist/index-esm.min.js.map b/dist/index-esm.min.js.map index bb578e3..7458805 100644 --- a/dist/index-esm.min.js.map +++ b/dist/index-esm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"index-esm.min.js","sources":["../node_modules/kld-affine/lib/Point2D.js","../node_modules/kld-affine/lib/Vector2D.js","../node_modules/kld-affine/lib/Matrix2D.js","../node_modules/kld-affine/index.js","../node_modules/kld-polynomial/lib/Polynomial.js","../node_modules/kld-polynomial/lib/SqrtPolynomial.js","../node_modules/kld-polynomial/index.js","../lib/Intersection.js","../lib/IntersectionArgs.js","../lib/Shapes.js","../lib/AffineShapes.js","../lib/IntersectionQuery.js"],"sourcesContent":["/**\n *\n * Point2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Point2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Point2D}\n */\nfunction Point2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * clone\n *\n * @returns {Point2D}\n */\nPoint2D.prototype.clone = function() {\n return new this.constructor(this.x, this.y);\n};\n\n/**\n * add\n *\n * @param {Point2D|Vector2D} that\n * @returns {Point2D}\n */\nPoint2D.prototype.add = function(that) {\n return new this.constructor(this.x+that.x, this.y+that.y);\n};\n\n/**\n * subtract\n *\n * @param { Vector2D | Point2D } that\n * @returns {Point2D}\n */\nPoint2D.prototype.subtract = function(that) {\n return new this.constructor(this.x-that.x, this.y-that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x*scalar, this.y*scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x/scalar, this.y/scalar);\n};\n\n/**\n * equals\n *\n * @param {Point2D} that\n * @returns {Boolean}\n */\nPoint2D.prototype.equals = function(that) {\n return ( this.x === that.x && this.y === that.y );\n};\n\n/**\n * precisionEquals\n *\n * @param {Point2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nPoint2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n// utility methods\n\n/**\n * lerp\n *\n * @param { Vector2D | Point2D } that\n * @param {Number} t\n @ @returns {Point2D}\n */\nPoint2D.prototype.lerp = function(that, t) {\n var omt = 1.0 - t;\n\n return new this.constructor(\n this.x * omt + that.x * t,\n this.y * omt + that.y * t\n );\n};\n\n/**\n * distanceFrom\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.distanceFrom = function(that) {\n var dx = this.x - that.x;\n var dy = this.y - that.y;\n\n return Math.sqrt(dx*dx + dy*dy);\n};\n\n/**\n * min\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.min = function(that) {\n return new this.constructor(\n Math.min( this.x, that.x ),\n Math.min( this.y, that.y )\n );\n};\n\n/**\n * max\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.max = function(that) {\n return new this.constructor(\n Math.max( this.x, that.x ),\n Math.max( this.y, that.y )\n );\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @result {Point2D}\n */\nPoint2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y + matrix.e,\n matrix.b * this.x + matrix.d * this.y + matrix.f\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nPoint2D.prototype.toString = function() {\n return \"point(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Point2D;\n}\n","/**\n *\n * Vector2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Vector2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Vector2D}\n */\nfunction Vector2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * fromPoints\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {Vector2D}\n */\nVector2D.fromPoints = function(p1, p2) {\n return new Vector2D(\n p2.x - p1.x,\n p2.y - p1.y\n );\n};\n\n/**\n * length\n *\n * @returns {Number}\n */\nVector2D.prototype.length = function() {\n return Math.sqrt(this.x*this.x + this.y*this.y);\n};\n\n/**\n * magnitude\n *\n * @returns {Number}\n */\nVector2D.prototype.magnitude = function() {\n return this.x*this.x + this.y*this.y;\n};\n\n/**\n * dot\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.dot = function(that) {\n return this.x*that.x + this.y*that.y;\n};\n\n/**\n * cross\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.cross = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * determinant\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.determinant = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * unit\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.unit = function() {\n return this.divide( this.length() );\n};\n\n/**\n * add\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.add = function(that) {\n return new this.constructor(this.x + that.x, this.y + that.y);\n};\n\n/**\n * subtract\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.subtract = function(that) {\n return new this.constructor(this.x - that.x, this.y - that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x * scalar, this.y * scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x / scalar, this.y / scalar);\n};\n\n/**\n * angleBetween\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.angleBetween = function(that) {\n var cos = this.dot(that) / (this.length() * that.length());\n cos = Math.max(-1, Math.min(cos, 1));\n var radians = Math.acos(cos);\n\n return (this.cross(that) < 0.0) ? -radians : radians;\n};\n\n/**\n * Find a vector is that is perpendicular to this vector\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.perp = function() {\n return new this.constructor(-this.y, this.x);\n};\n\n/**\n * Find the component of the specified vector that is perpendicular to\n * this vector\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.perpendicular = function(that) {\n return this.subtract(this.project(that));\n};\n\n/**\n * project\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.project = function(that) {\n var percent = this.dot(that) / that.dot(that);\n\n return that.multiply(percent);\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @returns {Vector2D}\n */\nVector2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y,\n matrix.b * this.x + matrix.d * this.y\n );\n};\n\n/**\n * equals\n *\n * @param {Vector2D} that\n * @returns {Boolean}\n */\nVector2D.prototype.equals = function(that) {\n return (\n this.x === that.x &&\n this.y === that.y\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Vector2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nVector2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nVector2D.prototype.toString = function() {\n return \"vector(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Vector2D;\n}\n","/**\n * Matrix2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n */\n\nfunction setReadonlyProperty(object, property, value) {\n Object.defineProperty(object, property, {\n value: value,\n writable: false,\n enumerable: true,\n configurable: false\n });\n}\n\n/**\n * Identity matrix\n *\n * @returns {Matrix2D}\n */\nsetReadonlyProperty(Matrix2D, \"IDENTITY\", new Matrix2D(1, 0, 0, 1, 0, 0));\nsetReadonlyProperty(Matrix2D.IDENTITY, \"isIdentity\", function () { return true; });\n\n\n/**\n * Matrix2D\n *\n * [a c e]\n * [b d f]\n * [0 0 1]\n *\n * @param {Number} a\n * @param {Number} b\n * @param {Number} c\n * @param {Number} d\n * @param {Number} e\n * @param {Number} f\n * @returns {Matrix2D}\n */\nfunction Matrix2D(a, b, c, d, e, f) {\n setReadonlyProperty(this, \"a\", (a !== undefined) ? a : 1);\n setReadonlyProperty(this, \"b\", (b !== undefined) ? b : 0);\n setReadonlyProperty(this, \"c\", (c !== undefined) ? c : 0);\n setReadonlyProperty(this, \"d\", (d !== undefined) ? d : 1);\n setReadonlyProperty(this, \"e\", (e !== undefined) ? e : 0);\n setReadonlyProperty(this, \"f\", (f !== undefined) ? f : 0);\n}\n\n\n// *** STATIC METHODS\n\n/**\n * translation\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.translation = function(tx, ty) {\n return new Matrix2D(1, 0, 0, 1, tx, ty);\n};\n\n/**\n * scaling\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.scaling = function(scale) {\n return new Matrix2D(scale, 0, 0, scale, 0, 0);\n};\n\n/**\n * scalingAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.scalingAt = function(scale, center) {\n return new Matrix2D(\n scale,\n 0,\n 0,\n scale,\n center.x - center.x * scale,\n center.y - center.y * scale\n );\n}\n\n\n/**\n * nonUniformScaling\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScaling = function(scaleX, scaleY) {\n return new Matrix2D(scaleX, 0, 0, scaleY, 0, 0);\n};\n\n/**\n * nonUniformScalingAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScalingAt = function(scaleX, scaleY, center) {\n return new Matrix2D(\n scaleX,\n 0,\n 0,\n scaleY,\n center.x - center.x * scaleX,\n center.y - center.y * scaleY\n );\n};\n\n/**\n * rotation\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.rotation = function(radians) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * rotationAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.rotationAt = function(radians, center) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(\n c,\n s,\n -s,\n c,\n center.x - center.x * c + center.y * s,\n center.y - center.y * c - center.x * s\n );\n};\n\n/**\n * rotationFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.rotationFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * xFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.xFlip = function() {\n return new Matrix2D(-1, 0, 0, 1, 0, 0);\n};\n\n/**\n * yFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.yFlip = function() {\n return new Matrix2D(1, 0, 0, -1, 0, 0);\n};\n\n/**\n * xSkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.xSkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, 0, t, 1, 0, 0);\n};\n\n/**\n * ySkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.ySkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, t, 0, 1, 0, 0);\n};\n\n\n// *** METHODS\n\n/**\n * multiply\n *\n * @pararm {Matrix2D} that\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.multiply = function (that) {\n if (this.isIdentity()) {\n return that;\n }\n\n if (that.isIdentity()) {\n return this;\n }\n\n return new this.constructor(\n this.a * that.a + this.c * that.b,\n this.b * that.a + this.d * that.b,\n this.a * that.c + this.c * that.d,\n this.b * that.c + this.d * that.d,\n this.a * that.e + this.c * that.f + this.e,\n this.b * that.e + this.d * that.f + this.f\n );\n};\n\n/**\n * inverse\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.inverse = function () {\n if (this.isIdentity()) {\n return this;\n }\n\n var det1 = this.a * this.d - this.b * this.c;\n\n if ( det1 === 0.0 ) {\n throw(\"Matrix is not invertible\");\n }\n\n var idet = 1.0 / det1;\n var det2 = this.f * this.c - this.e * this.d;\n var det3 = this.e * this.b - this.f * this.a;\n\n return new this.constructor(\n this.d * idet,\n -this.b * idet,\n -this.c * idet,\n this.a * idet,\n det2 * idet,\n det3 * idet\n );\n};\n\n/**\n * translate\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.translate = function(tx, ty) {\n return new this.constructor(\n this.a,\n this.b,\n this.c,\n this.d,\n this.a * tx + this.c * ty + this.e,\n this.b * tx + this.d * ty + this.f\n );\n};\n\n/**\n * scale\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scale = function(scale) {\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleAt = function(scale, center) {\n var dx = center.x - scale * center.x;\n var dy = center.y - scale * center.y;\n\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * scaleNonUniform\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniform = function(scaleX, scaleY) {\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleNonUniformAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniformAt = function(scaleX, scaleY, center) {\n var dx = center.x - scaleX * center.x;\n var dy = center.y - scaleY * center.y;\n\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * rotate\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotate = function(radians) {\n var c = Math.cos(radians);\n var s = Math.sin(radians);\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * rotateAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @result {Matrix2D}\n */\nMatrix2D.prototype.rotateAt = function(radians, center) {\n var cos = Math.cos(radians);\n var sin = Math.sin(radians);\n var cx = center.x;\n var cy = center.y;\n\n var a = this.a * cos + this.c * sin;\n var b = this.b * cos + this.d * sin;\n var c = this.c * cos - this.a * sin;\n var d = this.d * cos - this.b * sin;\n\n return new this.constructor(\n a,\n b,\n c,\n d,\n (this.a - a) * cx + (this.c - c) * cy + this.e,\n (this.b - b) * cx + (this.d - d) * cy + this.f\n );\n};\n\n/**\n * rotateFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotateFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * flipX\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipX = function() {\n return new this.constructor(\n -this.a,\n -this.b,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * flipY\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipY = function() {\n return new this.constructor(\n this.a,\n this.b,\n -this.c,\n -this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * skewX\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewX = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a,\n this.b,\n this.c + this.a * t,\n this.d + this.b * t,\n this.e,\n this.f\n );\n};\n\n// TODO: skewXAt\n\n/**\n * skewY\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewY = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a + this.c * t,\n this.b + this.d * t,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n// TODO: skewYAt\n\n/**\n * isIdentity\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isIdentity = function() {\n return (\n this.a === 1.0 &&\n this.b === 0.0 &&\n this.c === 0.0 &&\n this.d === 1.0 &&\n this.e === 0.0 &&\n this.f === 0.0\n );\n};\n\n/**\n * isInvertible\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isInvertible = function() {\n return this.a * this.d - this.b * this.c !== 0.0;\n};\n\n/**\n * getScale\n *\n * @returns {{ scaleX: Number, scaleY: Number }}\n */\nMatrix2D.prototype.getScale = function() {\n return {\n scaleX: Math.sqrt(this.a * this.a + this.c * this.c),\n scaleY: Math.sqrt(this.b * this.b + this.d * this.d)\n };\n};\n\n/**\n * getDecomposition\n *\n * Calculates matrix Singular Value Decomposition\n *\n * The resulting matrices, translation, rotation, scale, and rotation0, return\n * this matrix when they are muliplied together in the listed order\n *\n * @see Jim Blinn's article {@link http://dx.doi.org/10.1109/38.486688}\n * @see {@link http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation}\n *\n * @returns {{ translation: Matrix2D, rotation: Matrix2D, scale: Matrix2D, rotation0: Matrix2D }}\n */\nMatrix2D.prototype.getDecomposition = function () {\n var E = (this.a + this.d) * 0.5;\n var F = (this.a - this.d) * 0.5;\n var G = (this.b + this.c) * 0.5;\n var H = (this.b - this.c) * 0.5;\n\n var Q = Math.sqrt(E * E + H * H);\n var R = Math.sqrt(F * F + G * G);\n var scaleX = Q + R;\n var scaleY = Q - R;\n\n var a1 = Math.atan2(G, F);\n var a2 = Math.atan2(H, E);\n var theta = (a2 - a1) * 0.5;\n var phi = (a2 + a1) * 0.5;\n\n // TODO: Add static methods to generate translation, rotation, etc.\n // matrices directly\n\n return {\n translation: new this.constructor(1, 0, 0, 1, this.e, this.f),\n rotation: this.constructor.IDENTITY.rotate(phi),\n scale: new this.constructor(scaleX, 0, 0, scaleY, 0, 0),\n rotation0: this.constructor.IDENTITY.rotate(theta)\n };\n};\n\n/**\n * equals\n *\n * @param {Matrix2D} that\n * @returns {Boolean}\n */\nMatrix2D.prototype.equals = function(that) {\n return (\n this.a === that.a &&\n this.b === that.b &&\n this.c === that.c &&\n this.d === that.d &&\n this.e === that.e &&\n this.f === that.f\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Matrix2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nMatrix2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.a - that.a) < precision &&\n Math.abs(this.b - that.b) < precision &&\n Math.abs(this.c - that.c) < precision &&\n Math.abs(this.d - that.d) < precision &&\n Math.abs(this.e - that.e) < precision &&\n Math.abs(this.f - that.f) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nMatrix2D.prototype.toString = function() {\n return \"matrix(\" + [this.a, this.b, this.c, this.d, this.e, this.f].join(\",\") + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Matrix2D;\n}\n","// expose classes\n\nexports.Point2D = require('./lib/Point2D');\nexports.Vector2D = require('./lib/Vector2D');\nexports.Matrix2D = require('./lib/Matrix2D');\n","/**\n *\n * Polynomial.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n * \n * contribution {@link http://github.com/Quazistax/kld-polynomial}\n * @copyright 2015 Robert Benko (Quazistax) \n * @license MIT\n */\n\nPolynomial.TOLERANCE = 1e-6;\nPolynomial.ACCURACY = 15;\n\n\n/**\n * interpolate\n *\n * Based on poloint in \"Numerical Recipes in C, 2nd Edition\", pages 109-110\n *\n * @param {Array} xs\n * @param {Array} ys\n * @param {Number} n\n * @param {Number} offset\n * @param {Number} x\n *\n * @returns {{y: Number, dy: Number}}\n */\nPolynomial.interpolate = function(xs, ys, n, offset, x) {\n if ( xs.constructor !== Array || ys.constructor !== Array ) {\n throw new Error(\"Polynomial.interpolate: xs and ys must be arrays\");\n }\n if ( isNaN(n) || isNaN(offset) || isNaN(x) ) {\n throw new Error(\"Polynomial.interpolate: n, offset, and x must be numbers\");\n }\n\n var y = 0;\n var dy = 0;\n var c = new Array(n);\n var d = new Array(n);\n var ns = 0;\n\n var diff = Math.abs(x - xs[offset]);\n\n for ( var i = 0; i < n; i++ ) {\n var dift = Math.abs(x - xs[offset+i]);\n\n if ( dift < diff ) {\n ns = i;\n diff = dift;\n }\n c[i] = d[i] = ys[offset+i];\n }\n\n y = ys[offset+ns];\n ns--;\n\n for ( var m = 1; m < n; m++ ) {\n for ( var i = 0; i < n-m; i++ ) {\n var ho = xs[offset+i] - x;\n var hp = xs[offset+i+m] - x;\n var w = c[i+1]-d[i];\n var den = ho - hp;\n\n if ( den == 0.0 ) {\n throw new Error(\"Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)\");\n }\n\n den = w / den;\n d[i] = hp*den;\n c[i] = ho*den;\n }\n\n dy = (2*(ns+1) < (n-m)) ? c[ns+1] : d[ns--];\n y += dy;\n }\n\n return { y: y, dy: dy };\n};\n\n\n/**\n * Polynomial\n *\n * @returns {Polynomial}\n */\nfunction Polynomial() {\n this.init( arguments );\n}\n\n\n/**\n * init\n */\nPolynomial.prototype.init = function(coefs) {\n this.coefs = new Array();\n\n for ( var i = coefs.length - 1; i >= 0; i-- )\n this.coefs.push( coefs[i] );\n\n this._variable = \"t\";\n this._s = 0;\n};\n\n\n/**\n * eval\n */\nPolynomial.prototype.eval = function(x) {\n if ( isNaN(x) ) {\n throw new Error(\"Polynomial.eval: parameter must be a number\");\n }\n\n var result = 0;\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n result = result * x + this.coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * add\n */\nPolynomial.prototype.add = function(that) {\n var result = new Polynomial();\n var d1 = this.getDegree();\n var d2 = that.getDegree();\n var dmax = Math.max(d1,d2);\n\n for ( var i = 0; i <= dmax; i++ ) {\n var v1 = (i <= d1) ? this.coefs[i] : 0;\n var v2 = (i <= d2) ? that.coefs[i] : 0;\n\n result.coefs[i] = v1 + v2;\n }\n\n return result;\n};\n\n\n/**\n * multiply\n */\nPolynomial.prototype.multiply = function(that) {\n var result = new Polynomial();\n\n for ( var i = 0; i <= this.getDegree() + that.getDegree(); i++ ) {\n result.coefs.push(0);\n }\n\n for ( var i = 0; i <= this.getDegree(); i++ ) {\n for ( var j = 0; j <= that.getDegree(); j++ ) {\n result.coefs[i+j] += this.coefs[i] * that.coefs[j];\n }\n }\n\n return result;\n};\n\n\n/**\n * divide_scalar\n */\nPolynomial.prototype.divide_scalar = function(scalar) {\n for ( var i = 0; i < this.coefs.length; i++ ) {\n this.coefs[i] /= scalar;\n }\n};\n\n\n/**\n * simplify\n */\nPolynomial.prototype.simplify = function(TOLERANCE) {\n if (TOLERANCE === undefined) TOLERANCE = 1e-12;\n\n for ( var i = this.getDegree(); i >= 0; i-- ) {\n if ( Math.abs( this.coefs[i] ) <= TOLERANCE ) {\n this.coefs.pop();\n }\n else {\n break;\n }\n }\n};\n\n\n/**\n * bisection\n */\nPolynomial.prototype.bisection = function(min, max) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n var result;\n\n if ( Math.abs(minValue) <= Polynomial.TOLERANCE ) {\n result = min;\n }\n else if ( Math.abs(maxValue) <= Polynomial.TOLERANCE ) {\n result = max;\n }\n else if ( minValue * maxValue <= 0 ) {\n var tmp1 = Math.log(max - min);\n var tmp2 = Math.LN10 * Polynomial.ACCURACY;\n var iters = Math.ceil( (tmp1+tmp2) / Math.LN2 );\n\n for ( var i = 0; i < iters; i++ ) {\n result = 0.5 * (min + max);\n var value = this.eval(result);\n\n if ( Math.abs(value) <= Polynomial.TOLERANCE ) {\n break;\n }\n\n if ( value * minValue < 0 ) {\n max = result;\n maxValue = value;\n }\n else {\n min = result;\n minValue = value;\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * toString\n */\nPolynomial.prototype.toString = function() {\n var coefs = new Array();\n var signs = new Array();\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n var value = Math.round(this.coefs[i]*1000)/1000;\n //var value = this.coefs[i];\n\n if ( value != 0 ) {\n var sign = ( value < 0 ) ? \" - \" : \" + \";\n\n value = Math.abs(value);\n\n if ( i > 0 ) {\n if ( value == 1 ) {\n value = this._variable;\n }\n else {\n value += this._variable;\n }\n }\n\n if ( i > 1 ) {\n value += \"^\" + i;\n }\n\n signs.push( sign );\n coefs.push( value );\n }\n }\n\n signs[0] = ( signs[0] == \" + \" ) ? \"\" : \"-\";\n\n var result = \"\";\n\n for ( var i = 0; i < coefs.length; i++ ) {\n result += signs[i] + coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * trapezoid\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 137\n */\nPolynomial.prototype.trapezoid = function(min, max, n) {\n if ( isNaN(min) || isNaN(max) || isNaN(n) ) {\n throw new Error(\"Polynomial.trapezoid: parameters must be numbers\");\n }\n\n var range = max - min;\n var TOLERANCE = 1e-7;\n\n if ( n == 1 ) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n\n this._s = 0.5*range*( minValue + maxValue );\n }\n else {\n var it = 1 << (n-2);\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 0; i < it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n this._s = 0.5*(this._s + range*sum/it);\n }\n\n if ( isNaN(this._s) ) {\n throw new Error(\"Polynomial.trapezoid: this._s is NaN\");\n }\n\n return this._s;\n};\n\n\n/**\n * simpson\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 139\n */\nPolynomial.prototype.simpson = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.simpson: parameters must be numbers\");\n }\n\n var range = max - min;\n var st = 0.5 * range * ( this.eval(min) + this.eval(max) );\n var t = st;\n var s = 4.0*st/3.0;\n var os = s;\n var ost = st;\n var TOLERANCE = 1e-7;\n\n var it = 1;\n\n for ( var n = 2; n <= 20; n++ ) {\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 1; i <= it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n t = 0.5 * (t + range * sum / it);\n st = t;\n s = (4.0*st - ost)/3.0;\n\n if ( Math.abs(s-os) < TOLERANCE*Math.abs(os) ) {\n break;\n }\n\n os = s;\n ost = st;\n it <<= 1;\n }\n\n return s;\n};\n\n\n/**\n * romberg\n */\nPolynomial.prototype.romberg = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.romberg: parameters must be numbers\");\n }\n\n var MAX = 20;\n var K = 3;\n var TOLERANCE = 1e-6;\n var s = new Array(MAX+1);\n var h = new Array(MAX+1);\n var result = { y: 0, dy: 0 };\n\n h[0] = 1.0;\n\n for ( var j = 1; j <= MAX; j++ ) {\n s[j-1] = this.trapezoid(min, max, j);\n\n if ( j >= K ) {\n result = Polynomial.interpolate(h, s, K, j-K, 0.0);\n if ( Math.abs(result.dy) <= TOLERANCE*result.y) break;\n }\n\n s[j] = s[j-1];\n h[j] = 0.25 * h[j-1];\n }\n\n return result.y;\n};\n\n// getters and setters\n\n/**\n * get degree\n */\nPolynomial.prototype.getDegree = function() {\n return this.coefs.length - 1;\n};\n\n\n/**\n * getDerivative\n */\nPolynomial.prototype.getDerivative = function() {\n var derivative = new Polynomial();\n\n for ( var i = 1; i < this.coefs.length; i++ ) {\n derivative.coefs.push(i*this.coefs[i]);\n }\n\n return derivative;\n};\n\n\n/**\n * getRoots\n */\nPolynomial.prototype.getRoots = function() {\n var result;\n\n this.simplify();\n\n switch ( this.getDegree() ) {\n case 0: result = []; break;\n case 1: result = this.getLinearRoot(); break;\n case 2: result = this.getQuadraticRoots(); break;\n case 3: result = this.getCubicRoots(); break;\n case 4: result = this.getQuarticRoots(); break;\n default:\n result = [];\n }\n\n return result;\n};\n\n\n/**\n * getRootsInInterval\n */\nPolynomial.prototype.getRootsInInterval = function(min, max) {\n var roots = new Array();\n var root;\n\n if ( this.getDegree() == 1 ) {\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // get roots of derivative\n var deriv = this.getDerivative();\n var droots = deriv.getRootsInInterval(min, max);\n\n if ( droots.length > 0 ) {\n // find root on [min, droots[0]]\n root = this.bisection(min, droots[0]);\n\n if ( root != null ) {\n roots.push(root);\n }\n\n // find root on [droots[i],droots[i+1]] for 0 <= i <= count-2\n for ( i = 0; i <= droots.length-2; i++ ) {\n root = this.bisection(droots[i], droots[i+1]);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n\n // find root on [droots[count-1],xmax]\n root = this.bisection(droots[droots.length-1], max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // polynomial is monotone on [min,max], has at most one root\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n }\n\n return roots;\n};\n\n\n/**\n * getLinearRoot\n */\nPolynomial.prototype.getLinearRoot = function() {\n var result = [];\n var a = this.coefs[1];\n\n if ( a != 0 ) {\n result.push( -this.coefs[0] / a );\n }\n\n return result;\n};\n\n\n/**\n * getQuadraticRoots\n */\nPolynomial.prototype.getQuadraticRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 2 ) {\n var a = this.coefs[2];\n var b = this.coefs[1] / a;\n var c = this.coefs[0] / a;\n var d = b*b - 4*c;\n\n if ( d > 0 ) {\n var e = Math.sqrt(d);\n\n results.push( 0.5 * (-b + e) );\n results.push( 0.5 * (-b - e) );\n }\n else if ( d == 0 ) {\n // really two roots with same value, but we only return one\n results.push( 0.5 * -b );\n }\n }\n\n return results;\n};\n\n\n/**\n * getCubicRoots\n *\n * This code is based on MgcPolynomial.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.geometrictools.com\n */\nPolynomial.prototype.getCubicRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 3 ) {\n var c3 = this.coefs[3];\n var c2 = this.coefs[2] / c3;\n var c1 = this.coefs[1] / c3;\n var c0 = this.coefs[0] / c3;\n\n var a = (3*c1 - c2*c2) / 3;\n var b = (2*c2*c2*c2 - 9*c1*c2 + 27*c0) / 27;\n var offset = c2 / 3;\n var discrim = b*b/4 + a*a*a/27;\n var halfB = b / 2;\n\n var ZEROepsilon = this.zeroErrorEstimate();\n if (Math.abs(discrim) <= ZEROepsilon) {\n discrim = 0;\n }\n\n if ( discrim > 0 ) {\n var e = Math.sqrt(discrim);\n var tmp;\n var root;\n\n tmp = -halfB + e;\n\n if ( tmp >= 0 ) {\n root = Math.pow(tmp, 1/3);\n }\n else {\n root = -Math.pow(-tmp, 1/3);\n }\n\n tmp = -halfB - e;\n\n if ( tmp >= 0 ) {\n root += Math.pow(tmp, 1/3);\n }\n else {\n root -= Math.pow(-tmp, 1/3);\n }\n\n results.push( root - offset );\n }\n else if ( discrim < 0 ) {\n var distance = Math.sqrt(-a/3);\n var angle = Math.atan2( Math.sqrt(-discrim), -halfB) / 3;\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n var sqrt3 = Math.sqrt(3);\n\n results.push( 2*distance*cos - offset );\n results.push( -distance * (cos + sqrt3 * sin) - offset);\n results.push( -distance * (cos - sqrt3 * sin) - offset);\n }\n else {\n var tmp;\n\n if ( halfB >= 0 ) {\n tmp = -Math.pow(halfB, 1/3);\n }\n else {\n tmp = Math.pow(-halfB, 1/3);\n }\n\n results.push( 2*tmp - offset );\n // really should return next root twice, but we return only one\n results.push( -tmp - offset );\n }\n }\n\n return results;\n};\n\n\n/**\n * Sign of a number (+1, -1, +0, -0).\n */\nvar sign = function (x) {\n return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? x : NaN : NaN;\n};\n\n\n/**\n * Calculates roots of quartic polynomial.
\n * First, derivative roots are found, then used to split quartic polynomial \n * into segments, each containing one root of quartic polynomial.\n * Segments are then passed to newton's method to find roots.\n *\n * @returns {Array} roots\n */\nPolynomial.prototype.getQuarticRoots = function () {\n var results = [];\n\n var n = this.getDegree();\n\n if (n == 4) {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice();\n poly.divide_scalar(poly.coefs[n]);\n\n var ERRF = 1e-15;\n\n if (Math.abs(poly.coefs[0]) < 10 * ERRF * Math.abs(poly.coefs[3])) {\n poly.coefs[0] = 0;\n }\n\n var poly_d = poly.getDerivative();\n var derrt = poly_d.getRoots().sort(function (a, b) { return a - b; });\n var dery = [];\n var nr = derrt.length - 1;\n var i;\n var rb = this.bounds();\n\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n\n var ZEROepsilon = this.zeroErrorEstimate(maxabsX);\n \n for (i = 0; i <= nr; i++) {\n dery.push(poly.eval(derrt[i]));\n }\n\n for (i = 0; i <= nr; i++) {\n if (Math.abs(dery[i]) < ZEROepsilon) {\n dery[i] = 0;\n }\n }\n\n i = 0;\n var dx = Math.max(0.1 * (rb.maxX - rb.minX) / n, ERRF);\n var guesses = [];\n var minmax = [];\n\n if (nr > -1) {\n if (dery[0] != 0) {\n if (sign(dery[0]) != sign(poly.eval(derrt[0] - dx) - dery[0])) {\n guesses.push(derrt[0] - dx);\n minmax.push([rb.minX, derrt[0]]);\n }\n }\n else {\n results.push(derrt[0], derrt[0]);\n i++;\n }\n\n for (; i < nr; i++) {\n if (dery[i + 1] == 0) {\n results.push(derrt[i + 1], derrt[i + 1]);\n i++;\n }\n else if (sign(dery[i]) != sign(dery[i + 1])) {\n guesses.push((derrt[i] + derrt[i + 1]) / 2);\n minmax.push([derrt[i], derrt[i + 1]]);\n }\n }\n if (dery[nr] != 0 && sign(dery[nr]) != sign(poly.eval(derrt[nr] + dx) - dery[nr])) {\n guesses.push(derrt[nr] + dx);\n minmax.push([derrt[nr], rb.maxX]);\n }\n }\n\n var f = function (x) { return poly.eval(x); };\n var df = function (x) { return poly_d.eval(x); };\n\n if (guesses.length > 0) {\n for (i = 0; i < guesses.length; i++) {\n guesses[i] = Polynomial.newton_secant_bisection(guesses[i], f, df, 32, minmax[i][0], minmax[i][1]);\n }\n }\n\n results = results.concat(guesses);\n }\n\n return results;\n};\n\n\n/**\n * Estimate what is the maximum polynomial evaluation error value under which polynomial evaluation could be in fact 0.\n * \n * @returns {Number} \n */\nPolynomial.prototype.zeroErrorEstimate = function (maxabsX) {\n var poly = this;\n var ERRF = 1e-15;\n\n if (typeof maxabsX === 'undefined') {\n var rb = poly.bounds();\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n }\n\n if (maxabsX < 0.001) {\n return 2*Math.abs(poly.eval(ERRF));\n }\n\n var n = poly.coefs.length - 1;\n var an = poly.coefs[n];\n\n return 10 * ERRF * poly.coefs.reduce(function (m, v, i) {\n var nm = v / an * Math.pow(maxabsX, i);\n return nm > m ? nm : m;\n }, 0);\n}\n\n\n/**\n * Calculates upper Real roots bounds.
\n * Real roots are in interval [negX, posX]. Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_UpperReal_Fujiwara = function () {\n var a = this.coefs;\n var n = a.length - 1;\n var an = a[n];\n\n if (an != 1) {\n a = this.coefs.map(function (v) {\n return v / an;\n });\n }\n\n var b = a.map(function (v, i) {\n return (i < n)\n ? Math.pow(Math.abs((i == 0) ? v / 2 : v), 1 / (n - i))\n : v;\n });\n\n var coefSelectionFunc;\n var find2Max = function (acc, bi, i) {\n if (coefSelectionFunc(i)) {\n if (acc.max < bi) {\n acc.nearmax = acc.max;\n acc.max = bi;\n }\n else if (acc.nearmax < bi) {\n acc.nearmax = bi;\n }\n }\n return acc;\n };\n\n coefSelectionFunc = function (i) { return i < n && a[i] < 0; };\n var max_nearmax_pos = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n coefSelectionFunc = function (i) { return i < n && ((n % 2 == i % 2) ? a[i] < 0 : a[i] > 0); };\n var max_nearmax_neg = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n return {\n negX: -2 * max_nearmax_neg.max,\n posX: 2 * max_nearmax_pos.max\n };\n};\n\n\n/** \n * Calculates lower Real roots bounds.
\n * There are no Real roots in interval . Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_LowerReal_Fujiwara = function () {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice().reverse();\n\n var res = poly.bounds_UpperReal_Fujiwara();\n\n res.negX = 1 / res.negX;\n res.posX = 1 / res.posX;\n\n return res;\n};\n\n\n/** \n * Calculates left and right Real roots bounds.
\n * Real roots are in interval [minX, maxX]. Combines Fujiwara lower and upper bounds to get minimal interval.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ minX: Number, maxX: Number }}\n*/\nPolynomial.prototype.bounds = function () {\n var urb = this.bounds_UpperReal_Fujiwara();\n var rb = { minX: urb.negX, maxX: urb.posX };\n\n if (urb.negX === 0 && urb.posX === 0) {\n return rb;\n }\n\n if (urb.negX === 0) {\n rb.minX = this.bounds_LowerReal_Fujiwara().posX;\n }\n else if (urb.posX === 0) {\n rb.maxX = this.bounds_LowerReal_Fujiwara().negX;\n }\n\n if (rb.minX > rb.maxX) {\n //console.log('Polynomial.prototype.bounds: poly has no real roots? or floating point error?');\n rb.minX = rb.maxX = 0;\n }\n\n return rb;\n // TODO: if sure that there are no complex roots \n // (maybe by using Sturm's theorem) use:\n // return this.bounds_Real_Laguerre();\n};\n\n\n/**\n * Newton's (Newton-Raphson) method for finding Real roots on univariate function.
\n * When using bounds, algorithm falls back to secant if newton goes out of range.\n * Bisection is fallback for secant when determined secant is not efficient enough.\n * @see {@link http://en.wikipedia.org/wiki/Newton%27s_method}\n * @see {@link http://en.wikipedia.org/wiki/Secant_method}\n * @see {@link http://en.wikipedia.org/wiki/Bisection_method}\n *\n * @param {Number} x0 - Inital root guess\n * @param {function(x)} f - Function which root we are trying to find\n * @param {function(x)} df - Derivative of function f\n * @param {Number} max_iterations - Maximum number of algorithm iterations\n * @param {Number} [min_x] - Left bound value\n * @param {Number} [max_x] - Right bound value\n * @returns {Number} - root\n */\nPolynomial.newton_secant_bisection = function (x0, f, df, max_iterations, min, max) {\n var x, prev_dfx = 0, dfx, prev_x_ef_correction = 0, x_correction, x_new;\n var v, y_atmin, y_atmax;\n\n x = x0;\n\n var ACCURACY = 14;\n var min_correction_factor = Math.pow(10, -ACCURACY);\n var isBounded = (typeof min === 'number' && typeof max === 'number');\n\n if (isBounded) {\n if (min > max) {\n throw new Error(\"newton root finding: min must be greater than max\");\n }\n\n y_atmin = f(min);\n y_atmax = f(max);\n\n if (sign(y_atmin) == sign(y_atmax)) {\n throw new Error(\"newton root finding: y values of bounds must be of opposite sign\");\n }\n }\n\n var isEnoughCorrection = function () {\n // stop if correction is too small or if correction is in simple loop\n return (Math.abs(x_correction) <= min_correction_factor * Math.abs(x))\n || (prev_x_ef_correction == (x - x_correction) - x);\n };\n\n var i;\n\n for (i = 0; i < max_iterations; i++) {\n dfx = df(x);\n\n if (dfx == 0) {\n if (prev_dfx == 0) {\n // error\n throw new Error(\"newton root finding: df(x) is zero\");\n }\n else {\n // use previous derivation value\n dfx = prev_dfx;\n }\n // or move x a little?\n //dfx = df(x != 0 ? x + x * 1e-15 : 1e-15);\n }\n\n prev_dfx = dfx;\n y = f(x);\n x_correction = y / dfx;\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n\n if (isBounded) {\n if (sign(y) == sign(y_atmax)) {\n max = x;\n y_atmax = y;\n }\n else if (sign(y) == sign(y_atmin)) {\n min = x;\n y_atmin = y;\n }\n else {\n x = x_new;\n break;\n }\n\n if ((x_new < min) || (x_new > max)) {\n if (sign(y_atmin) == sign(y_atmax)) {\n break;\n }\n\n var RATIO_LIMIT = 50;\n var AIMED_BISECT_OFFSET = 0.25; // [0, 0.5)\n var dy = y_atmax - y_atmin;\n var dx = max - min;\n\n if (dy == 0) {\n x_correction = x - (min + dx * 0.5);\n }\n else if (Math.abs(dy / Math.min(y_atmin, y_atmax)) > RATIO_LIMIT) {\n x_correction = x - (min + dx * (0.5 + (Math.abs(y_atmin) < Math.abs(y_atmax) ? -AIMED_BISECT_OFFSET : AIMED_BISECT_OFFSET)));\n }\n else {\n x_correction = x - (min - y_atmin / dy * dx);\n }\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n }\n }\n\n prev_x_ef_correction = x - x_new;\n x = x_new;\n }\n\n return x;\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Polynomial;\n}\n","/**\n *\n * SqrtPolynomial.js\n *\n * copyright 2003, 2013 Kevin Lindsey\n *\n */\n\nif (typeof module !== \"undefined\") {\n var Polynomial = require(\"./Polynomial\");\n}\n\n/**\n * class variables\n */\nSqrtPolynomial.VERSION = 1.0;\n\n// setup inheritance\nSqrtPolynomial.prototype = new Polynomial();\nSqrtPolynomial.prototype.constructor = SqrtPolynomial;\nSqrtPolynomial.superclass = Polynomial.prototype;\n\n\n/**\n * SqrtPolynomial\n */\nfunction SqrtPolynomial() {\n this.init( arguments );\n}\n\n\n/**\n * eval\n *\n * @param {Number} x\n * @returns {Number}\n */\nSqrtPolynomial.prototype.eval = function(x) {\n var TOLERANCE = 1e-7;\n var result = SqrtPolynomial.superclass.eval.call(this, x);\n\n // NOTE: May need to change the following. I added these to capture\n // some really small negative values that were being generated by one\n // of my Bezier arcLength functions\n if ( Math.abs(result) < TOLERANCE ) result = 0;\n if ( result < 0 )\n throw new Error(\"SqrtPolynomial.eval: cannot take square root of negative number\");\n\n return Math.sqrt(result);\n};\n\nSqrtPolynomial.prototype.toString = function() {\n var result = SqrtPolynomial.superclass.toString.call(this);\n\n return \"sqrt(\" + result + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = SqrtPolynomial;\n}\n","// expose classes\n\nexports.Polynomial = require('./lib/Polynomial');\nexports.SqrtPolynomial = require('./lib/SqrtPolynomial');\n","/* eslint-disable camelcase, eqeqeq, no-labels, space-infix-ops */\n/**\n *\n * Intersection.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n *\n */\n\nimport {Point2D, Vector2D} from \"kld-affine\";\nimport {Polynomial} from \"kld-polynomial\";\n\n/**\n *\n * @param {*} o\n * @returns {boolean}\n */\nfunction isNullish(o) {\n return o === null || o === undefined;\n}\n\n/**\n * closePolygon\n *\n * @param {Array} points\n * @returns {Array}\n */\nfunction closePolygon(points) {\n const copy = points.slice();\n\n copy.push(points[0]);\n\n return copy;\n}\n\n\n/**\n * Intersection\n */\nclass Intersection {\n /**\n * @param {string} status\n */\n constructor(status) {\n this.init(status);\n }\n\n\n /**\n * init\n *\n * @param {string} status\n * @returns {Intersection}\n */\n init(status) {\n this.status = status;\n this.points = [];\n }\n\n\n /**\n * appendPoint\n *\n * @param {Point2D} point\n */\n appendPoint(point) {\n this.points.push(point);\n }\n\n\n /**\n * appendPoints\n *\n * @param {Array} points\n */\n appendPoints(points) {\n this.points = this.points.concat(points);\n }\n}\n\n// static methods\n\n/**\n * intersect\n *\n * @param {IntersectionArgs} shape1\n * @param {IntersectionArgs} shape2\n * @returns {Intersection}\n */\nIntersection.intersect = function(shape1, shape2) {\n let result;\n\n if (!isNullish(shape1) && !isNullish(shape2)) {\n if (shape1.name === \"Path\") {\n result = Intersection.intersectPathShape(shape1, shape2);\n }\n else if (shape2.name === \"Path\") {\n result = Intersection.intersectPathShape(shape2, shape1);\n }\n else {\n let method;\n let args;\n\n if (shape1.name < shape2.name) {\n method = \"intersect\" + shape1.name + shape2.name;\n args = shape1.args.concat(shape2.args);\n }\n else {\n method = \"intersect\" + shape2.name + shape1.name;\n args = shape2.args.concat(shape1.args);\n }\n\n if (!(method in Intersection)) {\n throw new Error(\"Intersection not available: \" + method);\n }\n\n result = Intersection[method].apply(null, args);\n }\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n\n return result;\n};\n\n\n/**\n * intersectPathShape\n *\n * @param {IntersectionArgs} path\n * @param {IntersectionArgs} shape\n * @returns {Intersection}\n */\nIntersection.intersectPathShape = function(path, shape) {\n const result = new Intersection(\"No Intersection\");\n\n for (const segment of path.args) {\n const inter = Intersection.intersect(segment, shape);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier2\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) {\n let a, b;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b2.multiply(-2);\n const c22 = b1.add(a.add(b3));\n\n a = b1.multiply(-2);\n b = b2.multiply(2);\n const c21 = a.add(b);\n\n const c20 = new Point2D(b1.x, b1.y);\n\n // bezout\n a = c12.x*c11.y - c11.x*c12.y;\n b = c22.x*c11.y - c11.x*c22.y;\n const c = c21.x*c11.y - c11.x*c21.y;\n const d = c11.x*(c10.y - c20.y) + c11.y*(-c10.x + c20.x);\n const e = c22.x*c12.y - c12.x*c22.y;\n const f = c21.x*c12.y - c12.x*c21.y;\n const g = c12.x*(c10.y - c20.y) + c12.y*(-c10.x + c20.x);\n\n // determinant\n const poly = new Polynomial(\n -e*e,\n -2*e*f,\n a*b - f*f - 2*e*g,\n a*c - 2*f*g,\n a*d - g*g\n );\n\n const roots = poly.getRoots();\n\n for (const s of roots) {\n if (0 <= s && s <= 1) {\n const xp = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(c22.multiply(s*s).add(c21.multiply(s).add(c20)));\n break checkRoots;\n }\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier3\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @param {Point2D} b4\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) {\n let a, b, c, d;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n const c10x2 = c10.x*c10.x;\n const c10y2 = c10.y*c10.y;\n const c11x2 = c11.x*c11.x;\n const c11y2 = c11.y*c11.y;\n const c12x2 = c12.x*c12.x;\n const c12y2 = c12.y*c12.y;\n const c20x2 = c20.x*c20.x;\n const c20y2 = c20.y*c20.y;\n const c21x2 = c21.x*c21.x;\n const c21y2 = c21.y*c21.y;\n const c22x2 = c22.x*c22.x;\n const c22y2 = c22.y*c22.y;\n const c23x2 = c23.x*c23.x;\n const c23y2 = c23.y*c23.y;\n\n const poly = new Polynomial(\n -2*c12.x*c12.y*c23.x*c23.y + c12x2*c23y2 + c12y2*c23x2,\n -2*c12.x*c12.y*c22.x*c23.y - 2*c12.x*c12.y*c22.y*c23.x + 2*c12y2*c22.x*c23.x +\n 2*c12x2*c22.y*c23.y,\n -2*c12.x*c21.x*c12.y*c23.y - 2*c12.x*c12.y*c21.y*c23.x - 2*c12.x*c12.y*c22.x*c22.y +\n 2*c21.x*c12y2*c23.x + c12y2*c22x2 + c12x2*(2*c21.y*c23.y + c22y2),\n 2*c10.x*c12.x*c12.y*c23.y + 2*c10.y*c12.x*c12.y*c23.x + c11.x*c11.y*c12.x*c23.y +\n c11.x*c11.y*c12.y*c23.x - 2*c20.x*c12.x*c12.y*c23.y - 2*c12.x*c20.y*c12.y*c23.x -\n 2*c12.x*c21.x*c12.y*c22.y - 2*c12.x*c12.y*c21.y*c22.x - 2*c10.x*c12y2*c23.x -\n 2*c10.y*c12x2*c23.y + 2*c20.x*c12y2*c23.x + 2*c21.x*c12y2*c22.x -\n c11y2*c12.x*c23.x - c11x2*c12.y*c23.y + c12x2*(2*c20.y*c23.y + 2*c21.y*c22.y),\n 2*c10.x*c12.x*c12.y*c22.y + 2*c10.y*c12.x*c12.y*c22.x + c11.x*c11.y*c12.x*c22.y +\n c11.x*c11.y*c12.y*c22.x - 2*c20.x*c12.x*c12.y*c22.y - 2*c12.x*c20.y*c12.y*c22.x -\n 2*c12.x*c21.x*c12.y*c21.y - 2*c10.x*c12y2*c22.x - 2*c10.y*c12x2*c22.y +\n 2*c20.x*c12y2*c22.x - c11y2*c12.x*c22.x - c11x2*c12.y*c22.y + c21x2*c12y2 +\n c12x2*(2*c20.y*c22.y + c21y2),\n 2*c10.x*c12.x*c12.y*c21.y + 2*c10.y*c12.x*c21.x*c12.y + c11.x*c11.y*c12.x*c21.y +\n c11.x*c11.y*c21.x*c12.y - 2*c20.x*c12.x*c12.y*c21.y - 2*c12.x*c20.y*c21.x*c12.y -\n 2*c10.x*c21.x*c12y2 - 2*c10.y*c12x2*c21.y + 2*c20.x*c21.x*c12y2 -\n c11y2*c12.x*c21.x - c11x2*c12.y*c21.y + 2*c12x2*c20.y*c21.y,\n -2*c10.x*c10.y*c12.x*c12.y - c10.x*c11.x*c11.y*c12.y - c10.y*c11.x*c11.y*c12.x +\n 2*c10.x*c12.x*c20.y*c12.y + 2*c10.y*c20.x*c12.x*c12.y + c11.x*c20.x*c11.y*c12.y +\n c11.x*c11.y*c12.x*c20.y - 2*c20.x*c12.x*c20.y*c12.y - 2*c10.x*c20.x*c12y2 +\n c10.x*c11y2*c12.x + c10.y*c11x2*c12.y - 2*c10.y*c12x2*c20.y -\n c20.x*c11y2*c12.x - c11x2*c20.y*c12.y + c10x2*c12y2 + c10y2*c12x2 +\n c20x2*c12y2 + c12x2*c20y2\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xRoots = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n ).getRoots();\n const yRoots = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n ).getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Circle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} c\n * @param {number} r\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Circle = function(p1, p2, p3, c, r) {\n return Intersection.intersectBezier2Ellipse(p1, p2, p3, c, r, r);\n};\n\n\n/**\n * intersectBezier2Ellipse\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) {\n let a; // temporary variables\n // c2, c1, c0; // coefficients of quadratic\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const roots = new Polynomial(\n ryry*c2.x*c2.x + rxrx*c2.y*c2.y,\n 2*(ryry*c2.x*c1.x + rxrx*c2.y*c1.y),\n ryry*(2*c2.x*c0.x + c1.x*c1.x) + rxrx*(2*c2.y*c0.y+c1.y*c1.y) -\n 2*(ryry*ec.x*c2.x + rxrx*ec.y*c2.y),\n 2*(ryry*c1.x*(c0.x-ec.x) + rxrx*c1.y*(c0.y-ec.y)),\n ryry*(c0.x*c0.x+ec.x*ec.x) + rxrx*(c0.y*c0.y + ec.y*ec.y) -\n 2*(ryry*ec.x*c0.x + rxrx*ec.y*c0.y) - rxrx*ryry\n ).getRoots();\n\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n result.points.push(c2.multiply(t*t).add(c1.multiply(t).add(c0)));\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Line\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) {\n let a; // temporary variables\n // let c2, c1, c0; // coefficients of quadratic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // Transform cubic coefficients to line's coordinate system and find roots\n // of cubic\n const roots = new Polynomial(\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p4 = p1.lerp(p2, t);\n const p5 = p2.lerp(p3, t);\n\n const p6 = p4.lerp(p5, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p6\n if (a1.x == a2.x) {\n if (min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p6.x && p6.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (min.x <= p6.x && p6.x <= max.x && min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Polygon\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Polygon = function(p1, p2, p3, points) {\n return Intersection.intersectBezier2Polyline(p1, p2, p3, closePolygon(points));\n};\n\n\n/**\n * intersectBezier2Polyline\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Polyline = function(p1, p2, p3, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier2Line(p1, p2, p3, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Rectangle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier2Line(p1, p2, p3, min, topRight);\n const inter2 = Intersection.intersectBezier2Line(p1, p2, p3, topRight, max);\n const inter3 = Intersection.intersectBezier2Line(p1, p2, p3, max, bottomLeft);\n const inter4 = Intersection.intersectBezier2Line(p1, p2, p3, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Bezier3\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} a4\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @param {Point2D} b4\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) {\n let a, b, c, d; // temporary variables\n // c13, c12, c11, c10; // coefficients of cubic\n // c23, c22, c21, c20; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = a1.multiply(-1);\n b = a2.multiply(3);\n c = a3.multiply(-3);\n d = a.add(b.add(c.add(a4)));\n const c13 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(3);\n b = a2.multiply(-6);\n c = a3.multiply(3);\n d = a.add(b.add(c));\n const c12 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(-3);\n b = a2.multiply(3);\n c = a.add(b);\n const c11 = new Vector2D(c.x, c.y);\n\n const c10 = new Vector2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n // bezout\n a = c13.x * c12.y - c12.x * c13.y;\n b = c13.x * c11.y - c11.x * c13.y;\n const c0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const c1 = c21.x * c13.y - c13.x * c21.y;\n const c2 = c22.x * c13.y - c13.x * c22.y;\n const c3 = c23.x * c13.y - c13.x * c23.y;\n d = c13.x * c11.y - c11.x * c13.y;\n const e0 = c13.x * c10.y + c12.x * c11.y - c11.x * c12.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const e1 = c21.x * c13.y - c13.x * c21.y;\n const e2 = c22.x * c13.y - c13.x * c22.y;\n const e3 = c23.x * c13.y - c13.x * c23.y;\n const f0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const f1 = c21.x * c12.y - c12.x * c21.y;\n const f2 = c22.x * c12.y - c12.x * c22.y;\n const f3 = c23.x * c12.y - c12.x * c23.y;\n const g0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const g1 = c21.x * c13.y - c13.x * c21.y;\n const g2 = c22.x * c13.y - c13.x * c22.y;\n const g3 = c23.x * c13.y - c13.x * c23.y;\n const h0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const h1 = c21.x * c12.y - c12.x * c21.y;\n const h2 = c22.x * c12.y - c12.x * c22.y;\n const h3 = c23.x * c12.y - c12.x * c23.y;\n const i0 = c11.x * c10.y - c10.x * c11.y + c20.x * c11.y - c11.x * c20.y;\n const i1 = c21.x * c11.y - c11.x * c21.y;\n const i2 = c22.x * c11.y - c11.x * c22.y;\n const i3 = c23.x * c11.y - c11.x * c23.y;\n\n // determinant\n const poly = new Polynomial(\n -c3 * e3 * g3,\n -c3 * e3 * g2 - c3 * e2 * g3 - c2 * e3 * g3,\n -c3 * e3 * g1 - c3 * e2 * g2 - c2 * e3 * g2 - c3 * e1 * g3 - c2 * e2 * g3 - c1 * e3 * g3,\n -c3 * e3 * g0 - c3 * e2 * g1 - c2 * e3 * g1 - c3 * e1 * g2 - c2 * e2 * g2 - c1 * e3 * g2 - c3 * e0 * g3 - c2 * e1 * g3 - c1 * e2 * g3 - c0 * e3 * g3 + b * f3 * g3 + c3 * d * h3 - a * f3 * h3 + a * e3 * i3,\n -c3 * e2 * g0 - c2 * e3 * g0 - c3 * e1 * g1 - c2 * e2 * g1 - c1 * e3 * g1 - c3 * e0 * g2 - c2 * e1 * g2 - c1 * e2 * g2 - c0 * e3 * g2 + b * f3 * g2 - c2 * e0 * g3 - c1 * e1 * g3 - c0 * e2 * g3 + b * f2 * g3 + c3 * d * h2 - a * f3 * h2 + c2 * d * h3 - a * f2 * h3 + a * e3 * i2 + a * e2 * i3,\n -c3 * e1 * g0 - c2 * e2 * g0 - c1 * e3 * g0 - c3 * e0 * g1 - c2 * e1 * g1 - c1 * e2 * g1 - c0 * e3 * g1 + b * f3 * g1 - c2 * e0 * g2 - c1 * e1 * g2 - c0 * e2 * g2 + b * f2 * g2 - c1 * e0 * g3 - c0 * e1 * g3 + b * f1 * g3 + c3 * d * h1 - a * f3 * h1 + c2 * d * h2 - a * f2 * h2 + c1 * d * h3 - a * f1 * h3 + a * e3 * i1 + a * e2 * i2 + a * e1 * i3,\n -c3 * e0 * g0 - c2 * e1 * g0 - c1 * e2 * g0 - c0 * e3 * g0 + b * f3 * g0 - c2 * e0 * g1 - c1 * e1 * g1 - c0 * e2 * g1 + b * f2 * g1 - c1 * e0 * g2 - c0 * e1 * g2 + b * f1 * g2 - c0 * e0 * g3 + b * f0 * g3 + c3 * d * h0 - a * f3 * h0 + c2 * d * h1 - a * f2 * h1 + c1 * d * h2 - a * f1 * h2 + c0 * d * h3 - a * f0 * h3 + a * e3 * i0 + a * e2 * i1 + a * e1 * i2 - b * d * i3 + a * e0 * i3,\n -c2 * e0 * g0 - c1 * e1 * g0 - c0 * e2 * g0 + b * f2 * g0 - c1 * e0 * g1 - c0 * e1 * g1 + b * f1 * g1 - c0 * e0 * g2 + b * f0 * g2 + c2 * d * h0 - a * f2 * h0 + c1 * d * h1 - a * f1 * h1 + c0 * d * h2 - a * f0 * h2 + a * e2 * i0 + a * e1 * i1 - b * d * i2 + a * e0 * i2,\n -c1 * e0 * g0 - c0 * e1 * g0 + b * f1 * g0 - c0 * e0 * g1 + b * f0 * g1 + c1 * d * h0 - a * f1 * h0 + c0 * d * h1 - a * f0 * h1 + a * e1 * i0 - b * d * i1 + a * e0 * i1,\n -c0 * e0 * g0 + b * f0 * g0 + c0 * d * h0 - a * f0 * h0 - b * d * i0 + a * e0 * i0\n );\n poly.simplify();\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xp = new Polynomial(\n c13.x,\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c13.y,\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Circle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} c\n * @param {number} r\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) {\n return Intersection.intersectBezier3Ellipse(p1, p2, p3, p4, c, r, r);\n};\n\n\n/**\n * intersectBezier3Ellipse\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const poly = new Polynomial(\n c3.x*c3.x*ryry + c3.y*c3.y*rxrx,\n 2*(c3.x*c2.x*ryry + c3.y*c2.y*rxrx),\n 2*(c3.x*c1.x*ryry + c3.y*c1.y*rxrx) + c2.x*c2.x*ryry + c2.y*c2.y*rxrx,\n 2*c3.x*ryry*(c0.x - ec.x) + 2*c3.y*rxrx*(c0.y - ec.y) +\n 2*(c2.x*c1.x*ryry + c2.y*c1.y*rxrx),\n 2*c2.x*ryry*(c0.x - ec.x) + 2*c2.y*rxrx*(c0.y - ec.y) +\n c1.x*c1.x*ryry + c1.y*c1.y*rxrx,\n 2*c1.x*ryry*(c0.x - ec.x) + 2*c1.y*rxrx*(c0.y - ec.y),\n c0.x*c0.x*ryry - 2*c0.y*ec.y*rxrx - 2*c0.x*ec.x*ryry +\n c0.y*c0.y*rxrx + ec.x*ec.x*ryry + ec.y*ec.y*rxrx - rxrx*ryry\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const t of roots) {\n result.points.push(\n c3.multiply(t*t*t).add(c2.multiply(t*t).add(c1.multiply(t).add(c0)))\n );\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Line\n *\n * Many thanks to Dan Sunday at SoftSurfer.com. He gave me a very thorough\n * sketch of the algorithm used here. Without his help, I'm not sure when I\n * would have figured out this intersection problem.\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n // Start with Bezier using Bernstein polynomials for weighting functions:\n // (1-t^3)P1 + 3t(1-t)^2P2 + 3t^2(1-t)P3 + t^3P4\n //\n // Expand and collect terms to form linear combinations of original Bezier\n // controls. This ends up with a vector cubic in t:\n // (-P1+3P2-3P3+P4)t^3 + (3P1-6P2+3P3)t^2 + (-3P1+3P2)t + P1\n // /\\ /\\ /\\ /\\\n // || || || ||\n // c3 c2 c1 c0\n\n // Calculate the coefficients\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // ?Rotate each cubic coefficient using line for new coordinate system?\n // Find roots of rotated cubic\n const roots = new Polynomial(\n n.dot(c3),\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p5 = p1.lerp(p2, t);\n const p6 = p2.lerp(p3, t);\n const p7 = p3.lerp(p4, t);\n\n const p8 = p5.lerp(p6, t);\n const p9 = p6.lerp(p7, t);\n\n const p10 = p8.lerp(p9, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p10\n if (a1.x == a2.x) {\n if (min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p10.x && p10.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (min.x <= p10.x && p10.x <= max.x && min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Polygon\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) {\n return this.intersectBezier3Polyline(p1, p2, p3, p4, closePolygon(points));\n};\n\n\n/**\n * intersectBezier3Polyline\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier3Line(p1, p2, p3, p4, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Rectangle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier3Line(p1, p2, p3, p4, min, topRight);\n const inter2 = Intersection.intersectBezier3Line(p1, p2, p3, p4, topRight, max);\n const inter3 = Intersection.intersectBezier3Line(p1, p2, p3, p4, max, bottomLeft);\n const inter4 = Intersection.intersectBezier3Line(p1, p2, p3, p4, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleCircle\n *\n * @param {Point2D} c1\n * @param {number} r1\n * @param {Point2D} c2\n * @param {number} r2\n * @returns {Intersection}\n */\nIntersection.intersectCircleCircle = function(c1, r1, c2, r2) {\n let result;\n\n // Determine minimum and maximum radii where circles can intersect\n const r_max = r1 + r2;\n const r_min = Math.abs(r1 - r2);\n\n // Determine actual distance between circle circles\n const c_dist = c1.distanceFrom(c2);\n\n if (c_dist > r_max) {\n result = new Intersection(\"Outside\");\n }\n else if (c_dist < r_min) {\n result = new Intersection(\"Inside\");\n }\n else {\n result = new Intersection(\"Intersection\");\n\n const a = (r1*r1 - r2*r2 + c_dist*c_dist) / (2*c_dist);\n const h = Math.sqrt(r1*r1 - a*a);\n const p = c1.lerp(c2, a/c_dist);\n const b = h / c_dist;\n\n result.points.push(\n new Point2D(\n p.x - b * (c2.y - c1.y),\n p.y + b * (c2.x - c1.x)\n )\n );\n result.points.push(\n new Point2D(\n p.x + b * (c2.y - c1.y),\n p.y - b * (c2.x - c1.x)\n )\n );\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleEllipse\n *\n * @param {Point2D} cc\n * @param {number} r\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) {\n return Intersection.intersectEllipseEllipse(cc, r, r, ec, rx, ry);\n};\n\n\n/**\n * intersectCircleLine\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectCircleLine = function(c, r, a1, a2) {\n let result;\n const a = (a2.x - a1.x) * (a2.x - a1.x) +\n (a2.y - a1.y) * (a2.y - a1.y);\n const b = 2 * ((a2.x - a1.x) * (a1.x - c.x) +\n (a2.y - a1.y) * (a1.y - c.y));\n const cc = c.x*c.x + c.y*c.y + a1.x*a1.x + a1.y*a1.y -\n 2 * (c.x * a1.x + c.y * a1.y) - r*r;\n const deter = b*b - 4*a*cc;\n\n if (deter < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (deter == 0) {\n result = new Intersection(\"Tangent\");\n // NOTE: should calculate this point\n }\n else {\n const e = Math.sqrt(deter);\n const u1 = (-b + e) / (2*a);\n const u2 = (-b - e) / (2*a);\n\n if ((u1 < 0 || u1 > 1) && (u2 < 0 || u2 > 1)) {\n if ((u1 < 0 && u2 < 0) || (u1 > 1 && u2 > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n\n if (0 <= u1 && u1 <= 1) {\n result.points.push(a1.lerp(a2, u1));\n }\n\n if (0 <= u2 && u2 <= 1) {\n result.points.push(a1.lerp(a2, u2));\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectCirclePolygon\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectCirclePolygon = function(c, r, points) {\n return this.intersectCirclePolyline(c, r, closePolygon(points));\n};\n\n\n/**\n * intersectCirclePolyline\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectCirclePolyline = function(c, r, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n let inter;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n\n inter = Intersection.intersectCircleLine(c, r, a1, a2);\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleRectangle\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectCircleRectangle = function(c, r, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectCircleLine(c, r, min, topRight);\n const inter2 = Intersection.intersectCircleLine(c, r, topRight, max);\n const inter3 = Intersection.intersectCircleLine(c, r, max, bottomLeft);\n const inter4 = Intersection.intersectCircleLine(c, r, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter1.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseEllipse\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {Point2D} c1\n * @param {number} rx1\n * @param {number} ry1\n * @param {Point2D} c2\n * @param {number} rx2\n * @param {number} ry2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) {\n const a = [\n ry1*ry1, 0, rx1*rx1, -2*ry1*ry1*c1.x, -2*rx1*rx1*c1.y,\n ry1*ry1*c1.x*c1.x + rx1*rx1*c1.y*c1.y - rx1*rx1*ry1*ry1\n ];\n const b = [\n ry2*ry2, 0, rx2*rx2, -2*ry2*ry2*c2.x, -2*rx2*rx2*c2.y,\n ry2*ry2*c2.x*c2.x + rx2*rx2*c2.y*c2.y - rx2*rx2*ry2*ry2\n ];\n\n const yPoly = Intersection.bezout(a, b);\n const yRoots = yPoly.getRoots();\n const epsilon = 1e-3;\n const norm0 = (a[0]*a[0] + 2*a[1]*a[1] + a[2]*a[2]) * epsilon;\n const norm1 = (b[0]*b[0] + 2*b[1]*b[1] + b[2]*b[2]) * epsilon;\n const result = new Intersection(\"No Intersection\");\n\n for (let y = 0; y < yRoots.length; y++) {\n const xPoly = new Polynomial(\n a[0],\n a[3] + yRoots[y] * a[1],\n a[5] + yRoots[y] * (a[4] + yRoots[y]*a[2])\n );\n const xRoots = xPoly.getRoots();\n\n for (let x = 0; x < xRoots.length; x++) {\n let tst =\n (a[0]*xRoots[x] + a[1]*yRoots[y] + a[3]) * xRoots[x] +\n (a[2]*yRoots[y] + a[4]) * yRoots[y] + a[5];\n if (Math.abs(tst) < norm0) {\n tst =\n (b[0]*xRoots[x] + b[1]*yRoots[y] + b[3]) * xRoots[x] +\n (b[2]*yRoots[y] + b[4]) * yRoots[y] + b[5];\n if (Math.abs(tst) < norm1) {\n result.appendPoint(new Point2D(xRoots[x], yRoots[y]));\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseLine\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseLine = function(c, rx, ry, a1, a2) {\n let result;\n const orign = new Vector2D(a1.x, a1.y);\n const dir = Vector2D.fromPoints(a1, a2);\n const center = new Vector2D(c.x, c.y);\n const diff = orign.subtract(center);\n const mDir = new Vector2D(dir.x/(rx*rx), dir.y/(ry*ry));\n const mDiff = new Vector2D(diff.x/(rx*rx), diff.y/(ry*ry));\n\n const a = dir.dot(mDir);\n const b = dir.dot(mDiff);\n c = diff.dot(mDiff) - 1.0;\n const d = b*b - a*c;\n\n if (d < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (d > 0) {\n const root = Math.sqrt(d); // eslint-disable-line no-shadow\n const t_a = (-b - root) / a;\n const t_b = (-b + root) / a;\n\n if ((t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b)) {\n if ((t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n if (0 <= t_a && t_a <= 1) {\n result.appendPoint(a1.lerp(a2, t_a));\n }\n if (0 <= t_b && t_b <= 1) {\n result.appendPoint(a1.lerp(a2, t_b));\n }\n }\n }\n else {\n const t = -b/a;\n\n if (0 <= t && t <= 1) {\n result = new Intersection(\"Intersection\");\n result.appendPoint(a1.lerp(a2, t));\n }\n else {\n result = new Intersection(\"Outside\");\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipsePolygon\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectEllipsePolygon = function(c, rx, ry, points) {\n return this.intersectEllipsePolyline(c, rx, ry, closePolygon(points));\n};\n\n\n/**\n * intersectEllipsePolyline\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectEllipsePolyline = function(c, rx, ry, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectEllipseLine(c, rx, ry, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseRectangle\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectEllipseLine(c, rx, ry, min, topRight);\n const inter2 = Intersection.intersectEllipseLine(c, rx, ry, topRight, max);\n const inter3 = Intersection.intersectEllipseLine(c, rx, ry, max, bottomLeft);\n const inter4 = Intersection.intersectEllipseLine(c, rx, ry, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineLine\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectLineLine = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n const ub = ub_t / u_b;\n\n if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * intersectLinePolygon\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectLinePolygon = function(a1, a2, points) {\n return this.intersectLinePolyline(a1, a2, closePolygon(points));\n};\n\n\n/**\n * intersectLinePolyline\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectLinePolyline = function(a1, a2, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectLineLine(a1, a2, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineRectangle\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectLineRectangle = function(a1, a2, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineLine(min, topRight, a1, a2);\n const inter2 = Intersection.intersectLineLine(topRight, max, a1, a2);\n const inter3 = Intersection.intersectLineLine(max, bottomLeft, a1, a2);\n const inter4 = Intersection.intersectLineLine(bottomLeft, min, a1, a2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolygonPolygon\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonPolygon = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), closePolygon(points2));\n};\n\n\n/**\n * intersectPolygonPolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonPolyline = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), points2);\n};\n\n\n/**\n * intersectPolygonRectangle\n *\n * @param {Array} points\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonRectangle = function(points, r1, r2) {\n return this.intersectPolylineRectangle(closePolygon(points), r1, r2);\n};\n\n\n/**\n * intersectPolylinePolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolylinePolyline = function(points1, points2) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points1;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points1[i];\n const a2 = points1[i + 1];\n const inter = Intersection.intersectLinePolyline(a1, a2, points2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolylineRectangle\n *\n * @param {Array} points\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectPolylineRectangle = function(points, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLinePolyline(min, topRight, points);\n const inter2 = Intersection.intersectLinePolyline(topRight, max, points);\n const inter3 = Intersection.intersectLinePolyline(max, bottomLeft, points);\n const inter4 = Intersection.intersectLinePolyline(bottomLeft, min, points);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRectangleRectangle\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectRectangleRectangle = function(a1, a2, b1, b2) {\n const min = a1.min(a2);\n const max = a1.max(a2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineRectangle(min, topRight, b1, b2);\n const inter2 = Intersection.intersectLineRectangle(topRight, max, b1, b2);\n const inter3 = Intersection.intersectLineRectangle(max, bottomLeft, b1, b2);\n const inter4 = Intersection.intersectLineRectangle(bottomLeft, min, b1, b2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRayRay\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectRayRay = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * bezout\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * @param {Array} e1\n * @param {Array} e2\n * @returns {Polynomial}\n */\nIntersection.bezout = function(e1, e2) {\n const AB = e1[0]*e2[1] - e2[0]*e1[1];\n const AC = e1[0]*e2[2] - e2[0]*e1[2];\n const AD = e1[0]*e2[3] - e2[0]*e1[3];\n const AE = e1[0]*e2[4] - e2[0]*e1[4];\n const AF = e1[0]*e2[5] - e2[0]*e1[5];\n const BC = e1[1]*e2[2] - e2[1]*e1[2];\n const BE = e1[1]*e2[4] - e2[1]*e1[4];\n const BF = e1[1]*e2[5] - e2[1]*e1[5];\n const CD = e1[2]*e2[3] - e2[2]*e1[3];\n const DE = e1[3]*e2[4] - e2[3]*e1[4];\n const DF = e1[3]*e2[5] - e2[3]*e1[5];\n const BFpDE = BF + DE;\n const BEmCD = BE - CD;\n\n return new Polynomial(\n AB*BC - AC*AC,\n AB*BEmCD + AD*BC - 2*AC*AE,\n AB*BFpDE + AD*BEmCD - AE*AE - 2*AC*AF,\n AB*DF + AD*BFpDE - 2*AE*AF,\n AD*DF - AF*AF\n );\n};\n\nexport default Intersection;\n","/**\n *\n * IntersectionArgs.js\n *\n * @copyright 2002, 2017 Kevin Lindsey\n *\n */\n\n/**\n * IntersectionArgs\n *\n */\nclass IntersectionArgs {\n /**\n * @param {string} name\n * @param {Array} args\n * @returns {IntersectionArgs}\n */\n constructor(name, args) {\n this.init(name, args);\n }\n /**\n * init\n *\n * @param {string} name\n * @param {Array} args\n */\n init(name, args) {\n this.name = name;\n this.args = args;\n }\n}\n\nexport default IntersectionArgs;\n","/**\n * Shapes\n *\n * @copyright 2017, Kevin Lindsey\n */\n\nimport {Point2D} from \"kld-affine\";\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\nconst Shapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @returns {IntersectionArgs}\n */\nShapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) {\n return new IntersectionArgs(\"Bezier2\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y)\n ]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @param {number} p4x\n * @param {number} p4y\n * @returns {IntersectionArgs}\n */\nShapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) {\n return new IntersectionArgs(\"Bezier3\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y),\n new Point2D(p4x, p4y)\n ]);\n};\n\n\n/**\n * circle\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radius\n * @returns {IntersectionArgs}\n */\nShapes.circle = function(centerX, centerY, radius) {\n return new IntersectionArgs(\"Circle\", [\n new Point2D(centerX, centerY),\n radius\n ]);\n};\n\n\n/**\n * ellipse\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {IntersectionArgs}\n */\nShapes.ellipse = function(centerX, centerY, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [\n new Point2D(centerX, centerY),\n radiusX,\n radiusY\n ]);\n};\n\n\n/**\n * line\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @returns {IntersectionArgs}\n */\nShapes.line = function(p1x, p1y, p2x, p2y) {\n return new IntersectionArgs(\"Line\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y)\n ]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {IntersectionArgs}\n */\nShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", segments);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} coords\n * @returns {IntersectionArgs}\n */\nShapes.polygon = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} coords\n * @returns {IntersectionArgs}\n */\nShapes.polyline = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n * @returns {IntersectionArgs}\n */\nShapes.rectangle = function(x, y, width, height) {\n return new IntersectionArgs(\"Rectangle\", [\n new Point2D(x, y),\n new Point2D(x + width, y + height)\n ]);\n};\n\n\nexport default Shapes;\n","/**\n * AffineShapes\n *\n * @copyright 2017, Kevin Lindsey\n */\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\nconst AffineShapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @returns {IntersectionArgs}\n */\nAffineShapes.quadraticBezier = function(p1, p2, p3) {\n return new IntersectionArgs(\"Bezier2\", [p1, p2, p3]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @returns {IntersectionArgs}\n */\nAffineShapes.cubicBezier = function(p1, p2, p3, p4) {\n return new IntersectionArgs(\"Bezier3\", [p1, p2, p3, p4]);\n};\n\n\n/**\n * circle\n *\n * @param {Point2D} center\n * @param {number} radius\n * @returns {IntersectionArgs}\n */\nAffineShapes.circle = function(center, radius) {\n return new IntersectionArgs(\"Circle\", [center, radius]);\n};\n\n\n/**\n * ellipse\n *\n * @param {Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {IntersectionArgs}\n */\nAffineShapes.ellipse = function(center, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [center, radiusX, radiusY]);\n};\n\n\n/**\n * line\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {IntersectionArgs}\n */\nAffineShapes.line = function(p1, p2) {\n return new IntersectionArgs(\"Line\", [p1, p2]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {IntersectionArgs}\n */\nAffineShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", [segments]);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} points\n * @returns {IntersectionArgs}\n */\nAffineShapes.polygon = function(points) {\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} points\n * @returns {IntersectionArgs}\n */\nAffineShapes.polyline = function(points) {\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {Point2D} topLeft\n * @param {Vector2D} size\n * @returns {IntersectionArgs}\n */\nAffineShapes.rectangle = function(topLeft, size) {\n return new IntersectionArgs(\"Rectangle\", [topLeft, topLeft.add(size)]);\n};\n\n\nexport default AffineShapes;\n","/**\n *\n * IntersectionQuery.js\n *\n * @copyright 2017 Kevin Lindsey\n *\n */\n\nimport {Vector2D} from \"kld-affine\";\n\n/**\n *\n */\nconst IntersectionQuery = {};\n\n\n/**\n * pointInCircle\n *\n * @param {Point2D} point\n * @param {Point2D} center\n * @param {number} radius\n * @returns {boolean}\n */\nIntersectionQuery.pointInCircle = function(point, center, radius) {\n const v = Vector2D.fromPoints(center, point);\n\n return v.length() <= radius;\n};\n\n\n/**\n * pointInEllipse\n *\n * @param {Point2D} point\n * @param {Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {boolean}\n */\nIntersectionQuery.pointInEllipse = function(point, center, radiusX, radiusY) {\n const len = point.subtract(center);\n\n return (len.x * len.x) / (radiusX * radiusX) + (len.y * len.y) / (radiusY * radiusY) <= 1;\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolyline = function(point, points) {\n const {length: len} = points;\n let counter = 0;\n let xInter;\n\n let p1 = points[0];\n\n for (let i = 1; i <= len; i++) {\n const p2 = points[i % len];\n const minY = Math.min(p1.y, p2.y);\n const maxY = Math.max(p1.y, p2.y);\n const maxX = Math.max(p1.x, p2.x);\n\n if (p1.y !== p2.y && minY < point.y && point.y <= maxY && point.x <= maxX) {\n xInter = (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;\n\n if (p1.x === p2.x || point.x <= xInter) {\n counter++;\n }\n }\n\n p1 = p2;\n }\n\n return (counter % 2 === 1);\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline;\n\n\n/**\n * pointInRectangle\n *\n * @param {Point2D} point\n * @param {Point2D} topLeft\n * @param {Point2D} bottomRight\n * @returns {boolean}\n */\nIntersectionQuery.pointInRectangle = function(point, topLeft, bottomRight) {\n return (\n topLeft.x <= point.x && point.x < bottomRight.x &&\n topLeft.y <= point.y && point.y < bottomRight.y\n );\n};\n\n\nexport default IntersectionQuery;\n"],"names":["Point2D","x","y","Object","defineProperties","this","value","undefined","writable","enumerable","configurable","prototype","clone","constructor","add","that","subtract","multiply","scalar","divide","equals","precisionEquals","precision","Math","abs","lerp","t","omt","distanceFrom","dx","dy","sqrt","min","max","transform","matrix","a","c","e","b","d","f","toString","module","Vector2D","fromPoints","p1","p2","length","magnitude","dot","cross","determinant","unit","angleBetween","cos","radians","acos","perp","perpendicular","project","percent","setReadonlyProperty","object","property","defineProperty","Matrix2D","IDENTITY","translation","tx","ty","scaling","scale","scalingAt","center","nonUniformScaling","scaleX","scaleY","nonUniformScalingAt","rotation","s","sin","rotationAt","rotationFromVector","vector","xFlip","yFlip","xSkew","tan","ySkew","isIdentity","inverse","det1","idet","det2","det3","translate","scaleAt","scaleNonUniform","scaleNonUniformAt","rotate","rotateAt","cx","cy","rotateFromVector","flipX","flipY","skewX","skewY","isInvertible","getScale","getDecomposition","E","F","G","H","Q","R","a1","atan2","a2","theta","phi","rotation0","join","require","Polynomial","init","arguments","TOLERANCE","ACCURACY","interpolate","xs","ys","n","offset","Array","Error","isNaN","ns","diff","i","dift","m","ho","hp","w","den","coefs","push","_variable","_s","eval","result","d1","getDegree","d2","dmax","v1","v2","j","divide_scalar","simplify","pop","bisection","minValue","maxValue","tmp1","log","tmp2","LN10","iters","ceil","LN2","signs","round","sign","trapezoid","range","it","delta","sum","simpson","st","os","ost","romberg","MAX","h","getDerivative","derivative","getRoots","getLinearRoot","getQuadraticRoots","getCubicRoots","getQuarticRoots","getRootsInInterval","root","roots","droots","results","c3","c2","c1","discrim","halfB","ZEROepsilon","zeroErrorEstimate","tmp","pow","distance","angle","sqrt3","NaN","poly","slice","poly_d","derrt","sort","dery","nr","rb","bounds","maxabsX","minX","maxX","guesses","minmax","df","newton_secant_bisection","concat","an","reduce","v","nm","bounds_UpperReal_Fujiwara","map","coefSelectionFunc","find2Max","acc","bi","nearmax","max_nearmax_pos","negX","posX","bounds_LowerReal_Fujiwara","reverse","res","urb","x0","max_iterations","dfx","x_correction","x_new","y_atmin","y_atmax","prev_dfx","prev_x_ef_correction","min_correction_factor","isBounded","isEnoughCorrection","SqrtPolynomial","VERSION","superclass","call","isNullish","o","closePolygon","points","copy","Intersection","status","point","intersect","shape1","shape2","name","intersectPathShape","method","args","apply","path","shape","segment","inter","appendPoints","intersectBezier2Bezier2","a3","b1","b2","b3","c12","c11","c10","c22","c21","c20","g","xp","xRoots","yp","yRoots","checkRoots","xRoot","k","intersectBezier2Bezier3","b4","c23","c10x2","c10y2","c11x2","c11y2","c12x2","c12y2","c20x2","c20y2","c21x2","c21y2","c22x2","c22y2","c23x2","c23y2","intersectBezier2Circle","p3","r","intersectBezier2Ellipse","ec","rx","ry","c0","rxrx","ryry","intersectBezier2Line","cl","p4","p5","p6","appendPoint","intersectBezier2Polygon","intersectBezier2Polyline","len","intersectBezier2Rectangle","r1","r2","topRight","bottomLeft","inter1","inter2","inter3","inter4","intersectBezier3Bezier3","a4","c13","e0","e1","e2","e3","f0","f1","f2","f3","g0","g1","g2","g3","h0","h1","h2","h3","i0","i1","i2","i3","intersectBezier3Circle","intersectBezier3Ellipse","intersectBezier3Line","p7","p8","p9","p10","intersectBezier3Polygon","intersectBezier3Polyline","intersectBezier3Rectangle","intersectCircleCircle","r_max","r_min","c_dist","p","intersectCircleEllipse","cc","intersectEllipseEllipse","intersectCircleLine","deter","u1","u2","intersectCirclePolygon","intersectCirclePolyline","intersectCircleRectangle","rx1","ry1","rx2","ry2","bezout","norm0","norm1","tst","intersectEllipseLine","orign","dir","mDir","mDiff","t_a","t_b","intersectEllipsePolygon","intersectEllipsePolyline","intersectEllipseRectangle","intersectLineLine","ua_t","ub_t","u_b","ua","ub","intersectLinePolygon","intersectLinePolyline","intersectLineRectangle","intersectPolygonPolygon","points1","points2","intersectPolylinePolyline","intersectPolygonPolyline","intersectPolygonRectangle","intersectPolylineRectangle","intersectRectangleRectangle","intersectRayRay","AB","AC","AD","AE","AF","BC","BE","BF","CD","DE","DF","BFpDE","BEmCD","IntersectionArgs","Shapes","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","centerX","centerY","radius","radiusX","radiusY","segments","coords","width","height","AffineShapes","topLeft","size","IntersectionQuery","xInter","counter","minY","maxY","pointInPolygon","pointInPolyline","pointInRectangle","bottomRight"],"mappings":"8YAeA,SAASA,EAAQC,EAAGC,GAChBC,OAAOC,iBAAiBC,KAAM,GACrB,CACDC,WAAaC,IAANN,EAAkBA,EAAI,EAC7BO,UAAU,EACVC,YAAY,EACZC,cAAc,KAEb,CACDJ,WAAaC,IAANL,EAAkBA,EAAI,EAC7BM,UAAU,EACVC,YAAY,EACZC,cAAc,KAU1BV,EAAQW,UAAUC,MAAQ,kBACf,IAAIP,KAAKQ,YAAYR,KAAKJ,EAAGI,KAAKH,IAS7CF,EAAQW,UAAUG,IAAM,SAASC,UACtB,IAAIV,KAAKQ,YAAYR,KAAKJ,EAAEc,EAAKd,EAAGI,KAAKH,EAAEa,EAAKb,IAS3DF,EAAQW,UAAUK,SAAW,SAASD,UAC3B,IAAIV,KAAKQ,YAAYR,KAAKJ,EAAEc,EAAKd,EAAGI,KAAKH,EAAEa,EAAKb,IAS3DF,EAAQW,UAAUM,SAAW,SAASC,UAC3B,IAAIb,KAAKQ,YAAYR,KAAKJ,EAAEiB,EAAQb,KAAKH,EAAEgB,IAStDlB,EAAQW,UAAUQ,OAAS,SAASD,UACzB,IAAIb,KAAKQ,YAAYR,KAAKJ,EAAEiB,EAAQb,KAAKH,EAAEgB,IAStDlB,EAAQW,UAAUS,OAAS,SAASL,UACvBV,KAAKJ,IAAMc,EAAKd,GAAKI,KAAKH,IAAMa,EAAKb,GAUlDF,EAAQW,UAAUU,gBA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at end of file +{"version":3,"file":"index-esm.min.js","sources":["../node_modules/kld-affine/lib/Point2D.js","../node_modules/kld-affine/lib/Vector2D.js","../node_modules/kld-affine/lib/Matrix2D.js","../node_modules/kld-affine/index.js","../node_modules/kld-polynomial/lib/Polynomial.js","../node_modules/kld-polynomial/lib/SqrtPolynomial.js","../node_modules/kld-polynomial/index.js","../lib/Intersection.js","../lib/IntersectionArgs.js","../lib/Shapes.js","../lib/AffineShapes.js","../lib/IntersectionQuery.js"],"sourcesContent":["/**\n *\n * Point2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Point2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Point2D}\n */\nfunction Point2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * clone\n *\n * @returns {Point2D}\n */\nPoint2D.prototype.clone = function() {\n return new this.constructor(this.x, this.y);\n};\n\n/**\n * add\n *\n * @param {Point2D|Vector2D} that\n * @returns {Point2D}\n */\nPoint2D.prototype.add = function(that) {\n return new this.constructor(this.x+that.x, this.y+that.y);\n};\n\n/**\n * subtract\n *\n * @param { Vector2D | Point2D } that\n * @returns {Point2D}\n */\nPoint2D.prototype.subtract = function(that) {\n return new this.constructor(this.x-that.x, this.y-that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x*scalar, this.y*scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x/scalar, this.y/scalar);\n};\n\n/**\n * equals\n *\n * @param {Point2D} that\n * @returns {Boolean}\n */\nPoint2D.prototype.equals = function(that) {\n return ( this.x === that.x && this.y === that.y );\n};\n\n/**\n * precisionEquals\n *\n * @param {Point2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nPoint2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n// utility methods\n\n/**\n * lerp\n *\n * @param { Vector2D | Point2D } that\n * @param {Number} t\n @ @returns {Point2D}\n */\nPoint2D.prototype.lerp = function(that, t) {\n var omt = 1.0 - t;\n\n return new this.constructor(\n this.x * omt + that.x * t,\n this.y * omt + that.y * t\n );\n};\n\n/**\n * distanceFrom\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.distanceFrom = function(that) {\n var dx = this.x - that.x;\n var dy = this.y - that.y;\n\n return Math.sqrt(dx*dx + dy*dy);\n};\n\n/**\n * min\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.min = function(that) {\n return new this.constructor(\n Math.min( this.x, that.x ),\n Math.min( this.y, that.y )\n );\n};\n\n/**\n * max\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.max = function(that) {\n return new this.constructor(\n Math.max( this.x, that.x ),\n Math.max( this.y, that.y )\n );\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @result {Point2D}\n */\nPoint2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y + matrix.e,\n matrix.b * this.x + matrix.d * this.y + matrix.f\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nPoint2D.prototype.toString = function() {\n return \"point(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Point2D;\n}\n","/**\n *\n * Vector2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Vector2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Vector2D}\n */\nfunction Vector2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * fromPoints\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {Vector2D}\n */\nVector2D.fromPoints = function(p1, p2) {\n return new Vector2D(\n p2.x - p1.x,\n p2.y - p1.y\n );\n};\n\n/**\n * length\n *\n * @returns {Number}\n */\nVector2D.prototype.length = function() {\n return Math.sqrt(this.x*this.x + this.y*this.y);\n};\n\n/**\n * magnitude\n *\n * @returns {Number}\n */\nVector2D.prototype.magnitude = function() {\n return this.x*this.x + this.y*this.y;\n};\n\n/**\n * dot\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.dot = function(that) {\n return this.x*that.x + this.y*that.y;\n};\n\n/**\n * cross\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.cross = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * determinant\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.determinant = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * unit\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.unit = function() {\n return this.divide( this.length() );\n};\n\n/**\n * add\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.add = function(that) {\n return new this.constructor(this.x + that.x, this.y + that.y);\n};\n\n/**\n * subtract\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.subtract = function(that) {\n return new this.constructor(this.x - that.x, this.y - that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x * scalar, this.y * scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x / scalar, this.y / scalar);\n};\n\n/**\n * angleBetween\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.angleBetween = function(that) {\n var cos = this.dot(that) / (this.length() * that.length());\n cos = Math.max(-1, Math.min(cos, 1));\n var radians = Math.acos(cos);\n\n return (this.cross(that) < 0.0) ? -radians : radians;\n};\n\n/**\n * Find a vector is that is perpendicular to this vector\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.perp = function() {\n return new this.constructor(-this.y, this.x);\n};\n\n/**\n * Find the component of the specified vector that is perpendicular to\n * this vector\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.perpendicular = function(that) {\n return this.subtract(this.project(that));\n};\n\n/**\n * project\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.project = function(that) {\n var percent = this.dot(that) / that.dot(that);\n\n return that.multiply(percent);\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @returns {Vector2D}\n */\nVector2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y,\n matrix.b * this.x + matrix.d * this.y\n );\n};\n\n/**\n * equals\n *\n * @param {Vector2D} that\n * @returns {Boolean}\n */\nVector2D.prototype.equals = function(that) {\n return (\n this.x === that.x &&\n this.y === that.y\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Vector2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nVector2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nVector2D.prototype.toString = function() {\n return \"vector(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Vector2D;\n}\n","/**\n * Matrix2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n */\n\nfunction setReadonlyProperty(object, property, value) {\n Object.defineProperty(object, property, {\n value: value,\n writable: false,\n enumerable: true,\n configurable: false\n });\n}\n\n/**\n * Identity matrix\n *\n * @returns {Matrix2D}\n */\nsetReadonlyProperty(Matrix2D, \"IDENTITY\", new Matrix2D(1, 0, 0, 1, 0, 0));\nsetReadonlyProperty(Matrix2D.IDENTITY, \"isIdentity\", function () { return true; });\n\n\n/**\n * Matrix2D\n *\n * [a c e]\n * [b d f]\n * [0 0 1]\n *\n * @param {Number} a\n * @param {Number} b\n * @param {Number} c\n * @param {Number} d\n * @param {Number} e\n * @param {Number} f\n * @returns {Matrix2D}\n */\nfunction Matrix2D(a, b, c, d, e, f) {\n setReadonlyProperty(this, \"a\", (a !== undefined) ? a : 1);\n setReadonlyProperty(this, \"b\", (b !== undefined) ? b : 0);\n setReadonlyProperty(this, \"c\", (c !== undefined) ? c : 0);\n setReadonlyProperty(this, \"d\", (d !== undefined) ? d : 1);\n setReadonlyProperty(this, \"e\", (e !== undefined) ? e : 0);\n setReadonlyProperty(this, \"f\", (f !== undefined) ? f : 0);\n}\n\n\n// *** STATIC METHODS\n\n/**\n * translation\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.translation = function(tx, ty) {\n return new Matrix2D(1, 0, 0, 1, tx, ty);\n};\n\n/**\n * scaling\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.scaling = function(scale) {\n return new Matrix2D(scale, 0, 0, scale, 0, 0);\n};\n\n/**\n * scalingAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.scalingAt = function(scale, center) {\n return new Matrix2D(\n scale,\n 0,\n 0,\n scale,\n center.x - center.x * scale,\n center.y - center.y * scale\n );\n}\n\n\n/**\n * nonUniformScaling\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScaling = function(scaleX, scaleY) {\n return new Matrix2D(scaleX, 0, 0, scaleY, 0, 0);\n};\n\n/**\n * nonUniformScalingAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScalingAt = function(scaleX, scaleY, center) {\n return new Matrix2D(\n scaleX,\n 0,\n 0,\n scaleY,\n center.x - center.x * scaleX,\n center.y - center.y * scaleY\n );\n};\n\n/**\n * rotation\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.rotation = function(radians) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * rotationAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.rotationAt = function(radians, center) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(\n c,\n s,\n -s,\n c,\n center.x - center.x * c + center.y * s,\n center.y - center.y * c - center.x * s\n );\n};\n\n/**\n * rotationFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.rotationFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * xFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.xFlip = function() {\n return new Matrix2D(-1, 0, 0, 1, 0, 0);\n};\n\n/**\n * yFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.yFlip = function() {\n return new Matrix2D(1, 0, 0, -1, 0, 0);\n};\n\n/**\n * xSkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.xSkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, 0, t, 1, 0, 0);\n};\n\n/**\n * ySkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.ySkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, t, 0, 1, 0, 0);\n};\n\n\n// *** METHODS\n\n/**\n * multiply\n *\n * @pararm {Matrix2D} that\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.multiply = function (that) {\n if (this.isIdentity()) {\n return that;\n }\n\n if (that.isIdentity()) {\n return this;\n }\n\n return new this.constructor(\n this.a * that.a + this.c * that.b,\n this.b * that.a + this.d * that.b,\n this.a * that.c + this.c * that.d,\n this.b * that.c + this.d * that.d,\n this.a * that.e + this.c * that.f + this.e,\n this.b * that.e + this.d * that.f + this.f\n );\n};\n\n/**\n * inverse\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.inverse = function () {\n if (this.isIdentity()) {\n return this;\n }\n\n var det1 = this.a * this.d - this.b * this.c;\n\n if ( det1 === 0.0 ) {\n throw(\"Matrix is not invertible\");\n }\n\n var idet = 1.0 / det1;\n var det2 = this.f * this.c - this.e * this.d;\n var det3 = this.e * this.b - this.f * this.a;\n\n return new this.constructor(\n this.d * idet,\n -this.b * idet,\n -this.c * idet,\n this.a * idet,\n det2 * idet,\n det3 * idet\n );\n};\n\n/**\n * translate\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.translate = function(tx, ty) {\n return new this.constructor(\n this.a,\n this.b,\n this.c,\n this.d,\n this.a * tx + this.c * ty + this.e,\n this.b * tx + this.d * ty + this.f\n );\n};\n\n/**\n * scale\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scale = function(scale) {\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleAt = function(scale, center) {\n var dx = center.x - scale * center.x;\n var dy = center.y - scale * center.y;\n\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * scaleNonUniform\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniform = function(scaleX, scaleY) {\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleNonUniformAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniformAt = function(scaleX, scaleY, center) {\n var dx = center.x - scaleX * center.x;\n var dy = center.y - scaleY * center.y;\n\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * rotate\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotate = function(radians) {\n var c = Math.cos(radians);\n var s = Math.sin(radians);\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * rotateAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @result {Matrix2D}\n */\nMatrix2D.prototype.rotateAt = function(radians, center) {\n var cos = Math.cos(radians);\n var sin = Math.sin(radians);\n var cx = center.x;\n var cy = center.y;\n\n var a = this.a * cos + this.c * sin;\n var b = this.b * cos + this.d * sin;\n var c = this.c * cos - this.a * sin;\n var d = this.d * cos - this.b * sin;\n\n return new this.constructor(\n a,\n b,\n c,\n d,\n (this.a - a) * cx + (this.c - c) * cy + this.e,\n (this.b - b) * cx + (this.d - d) * cy + this.f\n );\n};\n\n/**\n * rotateFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotateFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * flipX\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipX = function() {\n return new this.constructor(\n -this.a,\n -this.b,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * flipY\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipY = function() {\n return new this.constructor(\n this.a,\n this.b,\n -this.c,\n -this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * skewX\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewX = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a,\n this.b,\n this.c + this.a * t,\n this.d + this.b * t,\n this.e,\n this.f\n );\n};\n\n// TODO: skewXAt\n\n/**\n * skewY\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewY = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a + this.c * t,\n this.b + this.d * t,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n// TODO: skewYAt\n\n/**\n * isIdentity\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isIdentity = function() {\n return (\n this.a === 1.0 &&\n this.b === 0.0 &&\n this.c === 0.0 &&\n this.d === 1.0 &&\n this.e === 0.0 &&\n this.f === 0.0\n );\n};\n\n/**\n * isInvertible\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isInvertible = function() {\n return this.a * this.d - this.b * this.c !== 0.0;\n};\n\n/**\n * getScale\n *\n * @returns {{ scaleX: Number, scaleY: Number }}\n */\nMatrix2D.prototype.getScale = function() {\n return {\n scaleX: Math.sqrt(this.a * this.a + this.c * this.c),\n scaleY: Math.sqrt(this.b * this.b + this.d * this.d)\n };\n};\n\n/**\n * getDecomposition\n *\n * Calculates matrix Singular Value Decomposition\n *\n * The resulting matrices, translation, rotation, scale, and rotation0, return\n * this matrix when they are muliplied together in the listed order\n *\n * @see Jim Blinn's article {@link http://dx.doi.org/10.1109/38.486688}\n * @see {@link http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation}\n *\n * @returns {{ translation: Matrix2D, rotation: Matrix2D, scale: Matrix2D, rotation0: Matrix2D }}\n */\nMatrix2D.prototype.getDecomposition = function () {\n var E = (this.a + this.d) * 0.5;\n var F = (this.a - this.d) * 0.5;\n var G = (this.b + this.c) * 0.5;\n var H = (this.b - this.c) * 0.5;\n\n var Q = Math.sqrt(E * E + H * H);\n var R = Math.sqrt(F * F + G * G);\n var scaleX = Q + R;\n var scaleY = Q - R;\n\n var a1 = Math.atan2(G, F);\n var a2 = Math.atan2(H, E);\n var theta = (a2 - a1) * 0.5;\n var phi = (a2 + a1) * 0.5;\n\n // TODO: Add static methods to generate translation, rotation, etc.\n // matrices directly\n\n return {\n translation: new this.constructor(1, 0, 0, 1, this.e, this.f),\n rotation: this.constructor.IDENTITY.rotate(phi),\n scale: new this.constructor(scaleX, 0, 0, scaleY, 0, 0),\n rotation0: this.constructor.IDENTITY.rotate(theta)\n };\n};\n\n/**\n * equals\n *\n * @param {Matrix2D} that\n * @returns {Boolean}\n */\nMatrix2D.prototype.equals = function(that) {\n return (\n this.a === that.a &&\n this.b === that.b &&\n this.c === that.c &&\n this.d === that.d &&\n this.e === that.e &&\n this.f === that.f\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Matrix2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nMatrix2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.a - that.a) < precision &&\n Math.abs(this.b - that.b) < precision &&\n Math.abs(this.c - that.c) < precision &&\n Math.abs(this.d - that.d) < precision &&\n Math.abs(this.e - that.e) < precision &&\n Math.abs(this.f - that.f) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nMatrix2D.prototype.toString = function() {\n return \"matrix(\" + [this.a, this.b, this.c, this.d, this.e, this.f].join(\",\") + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Matrix2D;\n}\n","// expose classes\n\nexports.Point2D = require('./lib/Point2D');\nexports.Vector2D = require('./lib/Vector2D');\nexports.Matrix2D = require('./lib/Matrix2D');\n","/**\n *\n * Polynomial.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n * \n * contribution {@link http://github.com/Quazistax/kld-polynomial}\n * @copyright 2015 Robert Benko (Quazistax) \n * @license MIT\n */\n\nPolynomial.TOLERANCE = 1e-6;\nPolynomial.ACCURACY = 15;\n\n\n/**\n * interpolate\n *\n * Based on poloint in \"Numerical Recipes in C, 2nd Edition\", pages 109-110\n *\n * @param {Array} xs\n * @param {Array} ys\n * @param {Number} n\n * @param {Number} offset\n * @param {Number} x\n *\n * @returns {{y: Number, dy: Number}}\n */\nPolynomial.interpolate = function(xs, ys, n, offset, x) {\n if ( xs.constructor !== Array || ys.constructor !== Array ) {\n throw new Error(\"Polynomial.interpolate: xs and ys must be arrays\");\n }\n if ( isNaN(n) || isNaN(offset) || isNaN(x) ) {\n throw new Error(\"Polynomial.interpolate: n, offset, and x must be numbers\");\n }\n\n var y = 0;\n var dy = 0;\n var c = new Array(n);\n var d = new Array(n);\n var ns = 0;\n\n var diff = Math.abs(x - xs[offset]);\n\n for ( var i = 0; i < n; i++ ) {\n var dift = Math.abs(x - xs[offset+i]);\n\n if ( dift < diff ) {\n ns = i;\n diff = dift;\n }\n c[i] = d[i] = ys[offset+i];\n }\n\n y = ys[offset+ns];\n ns--;\n\n for ( var m = 1; m < n; m++ ) {\n for ( var i = 0; i < n-m; i++ ) {\n var ho = xs[offset+i] - x;\n var hp = xs[offset+i+m] - x;\n var w = c[i+1]-d[i];\n var den = ho - hp;\n\n if ( den == 0.0 ) {\n throw new Error(\"Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)\");\n }\n\n den = w / den;\n d[i] = hp*den;\n c[i] = ho*den;\n }\n\n dy = (2*(ns+1) < (n-m)) ? c[ns+1] : d[ns--];\n y += dy;\n }\n\n return { y: y, dy: dy };\n};\n\n\n/**\n * Polynomial\n *\n * @returns {Polynomial}\n */\nfunction Polynomial() {\n this.init( arguments );\n}\n\n\n/**\n * init\n */\nPolynomial.prototype.init = function(coefs) {\n this.coefs = new Array();\n\n for ( var i = coefs.length - 1; i >= 0; i-- )\n this.coefs.push( coefs[i] );\n\n this._variable = \"t\";\n this._s = 0;\n};\n\n\n/**\n * eval\n */\nPolynomial.prototype.eval = function(x) {\n if ( isNaN(x) ) {\n throw new Error(\"Polynomial.eval: parameter must be a number\");\n }\n\n var result = 0;\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n result = result * x + this.coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * add\n */\nPolynomial.prototype.add = function(that) {\n var result = new Polynomial();\n var d1 = this.getDegree();\n var d2 = that.getDegree();\n var dmax = Math.max(d1,d2);\n\n for ( var i = 0; i <= dmax; i++ ) {\n var v1 = (i <= d1) ? this.coefs[i] : 0;\n var v2 = (i <= d2) ? that.coefs[i] : 0;\n\n result.coefs[i] = v1 + v2;\n }\n\n return result;\n};\n\n\n/**\n * multiply\n */\nPolynomial.prototype.multiply = function(that) {\n var result = new Polynomial();\n\n for ( var i = 0; i <= this.getDegree() + that.getDegree(); i++ ) {\n result.coefs.push(0);\n }\n\n for ( var i = 0; i <= this.getDegree(); i++ ) {\n for ( var j = 0; j <= that.getDegree(); j++ ) {\n result.coefs[i+j] += this.coefs[i] * that.coefs[j];\n }\n }\n\n return result;\n};\n\n\n/**\n * divide_scalar\n */\nPolynomial.prototype.divide_scalar = function(scalar) {\n for ( var i = 0; i < this.coefs.length; i++ ) {\n this.coefs[i] /= scalar;\n }\n};\n\n\n/**\n * simplify\n */\nPolynomial.prototype.simplify = function(TOLERANCE) {\n if (TOLERANCE === undefined) TOLERANCE = 1e-12;\n\n for ( var i = this.getDegree(); i >= 0; i-- ) {\n if ( Math.abs( this.coefs[i] ) <= TOLERANCE ) {\n this.coefs.pop();\n }\n else {\n break;\n }\n }\n};\n\n\n/**\n * bisection\n */\nPolynomial.prototype.bisection = function(min, max) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n var result;\n\n if ( Math.abs(minValue) <= Polynomial.TOLERANCE ) {\n result = min;\n }\n else if ( Math.abs(maxValue) <= Polynomial.TOLERANCE ) {\n result = max;\n }\n else if ( minValue * maxValue <= 0 ) {\n var tmp1 = Math.log(max - min);\n var tmp2 = Math.LN10 * Polynomial.ACCURACY;\n var iters = Math.ceil( (tmp1+tmp2) / Math.LN2 );\n\n for ( var i = 0; i < iters; i++ ) {\n result = 0.5 * (min + max);\n var value = this.eval(result);\n\n if ( Math.abs(value) <= Polynomial.TOLERANCE ) {\n break;\n }\n\n if ( value * minValue < 0 ) {\n max = result;\n maxValue = value;\n }\n else {\n min = result;\n minValue = value;\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * toString\n */\nPolynomial.prototype.toString = function() {\n var coefs = new Array();\n var signs = new Array();\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n var value = Math.round(this.coefs[i]*1000)/1000;\n //var value = this.coefs[i];\n\n if ( value != 0 ) {\n var sign = ( value < 0 ) ? \" - \" : \" + \";\n\n value = Math.abs(value);\n\n if ( i > 0 ) {\n if ( value == 1 ) {\n value = this._variable;\n }\n else {\n value += this._variable;\n }\n }\n\n if ( i > 1 ) {\n value += \"^\" + i;\n }\n\n signs.push( sign );\n coefs.push( value );\n }\n }\n\n signs[0] = ( signs[0] == \" + \" ) ? \"\" : \"-\";\n\n var result = \"\";\n\n for ( var i = 0; i < coefs.length; i++ ) {\n result += signs[i] + coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * trapezoid\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 137\n */\nPolynomial.prototype.trapezoid = function(min, max, n) {\n if ( isNaN(min) || isNaN(max) || isNaN(n) ) {\n throw new Error(\"Polynomial.trapezoid: parameters must be numbers\");\n }\n\n var range = max - min;\n var TOLERANCE = 1e-7;\n\n if ( n == 1 ) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n\n this._s = 0.5*range*( minValue + maxValue );\n }\n else {\n var it = 1 << (n-2);\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 0; i < it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n this._s = 0.5*(this._s + range*sum/it);\n }\n\n if ( isNaN(this._s) ) {\n throw new Error(\"Polynomial.trapezoid: this._s is NaN\");\n }\n\n return this._s;\n};\n\n\n/**\n * simpson\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 139\n */\nPolynomial.prototype.simpson = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.simpson: parameters must be numbers\");\n }\n\n var range = max - min;\n var st = 0.5 * range * ( this.eval(min) + this.eval(max) );\n var t = st;\n var s = 4.0*st/3.0;\n var os = s;\n var ost = st;\n var TOLERANCE = 1e-7;\n\n var it = 1;\n\n for ( var n = 2; n <= 20; n++ ) {\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 1; i <= it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n t = 0.5 * (t + range * sum / it);\n st = t;\n s = (4.0*st - ost)/3.0;\n\n if ( Math.abs(s-os) < TOLERANCE*Math.abs(os) ) {\n break;\n }\n\n os = s;\n ost = st;\n it <<= 1;\n }\n\n return s;\n};\n\n\n/**\n * romberg\n */\nPolynomial.prototype.romberg = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.romberg: parameters must be numbers\");\n }\n\n var MAX = 20;\n var K = 3;\n var TOLERANCE = 1e-6;\n var s = new Array(MAX+1);\n var h = new Array(MAX+1);\n var result = { y: 0, dy: 0 };\n\n h[0] = 1.0;\n\n for ( var j = 1; j <= MAX; j++ ) {\n s[j-1] = this.trapezoid(min, max, j);\n\n if ( j >= K ) {\n result = Polynomial.interpolate(h, s, K, j-K, 0.0);\n if ( Math.abs(result.dy) <= TOLERANCE*result.y) break;\n }\n\n s[j] = s[j-1];\n h[j] = 0.25 * h[j-1];\n }\n\n return result.y;\n};\n\n// getters and setters\n\n/**\n * get degree\n */\nPolynomial.prototype.getDegree = function() {\n return this.coefs.length - 1;\n};\n\n\n/**\n * getDerivative\n */\nPolynomial.prototype.getDerivative = function() {\n var derivative = new Polynomial();\n\n for ( var i = 1; i < this.coefs.length; i++ ) {\n derivative.coefs.push(i*this.coefs[i]);\n }\n\n return derivative;\n};\n\n\n/**\n * getRoots\n */\nPolynomial.prototype.getRoots = function() {\n var result;\n\n this.simplify();\n\n switch ( this.getDegree() ) {\n case 0: result = []; break;\n case 1: result = this.getLinearRoot(); break;\n case 2: result = this.getQuadraticRoots(); break;\n case 3: result = this.getCubicRoots(); break;\n case 4: result = this.getQuarticRoots(); break;\n default:\n result = [];\n }\n\n return result;\n};\n\n\n/**\n * getRootsInInterval\n */\nPolynomial.prototype.getRootsInInterval = function(min, max) {\n var roots = new Array();\n var root;\n\n if ( this.getDegree() == 1 ) {\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // get roots of derivative\n var deriv = this.getDerivative();\n var droots = deriv.getRootsInInterval(min, max);\n\n if ( droots.length > 0 ) {\n // find root on [min, droots[0]]\n root = this.bisection(min, droots[0]);\n\n if ( root != null ) {\n roots.push(root);\n }\n\n // find root on [droots[i],droots[i+1]] for 0 <= i <= count-2\n for ( i = 0; i <= droots.length-2; i++ ) {\n root = this.bisection(droots[i], droots[i+1]);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n\n // find root on [droots[count-1],xmax]\n root = this.bisection(droots[droots.length-1], max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // polynomial is monotone on [min,max], has at most one root\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n }\n\n return roots;\n};\n\n\n/**\n * getLinearRoot\n */\nPolynomial.prototype.getLinearRoot = function() {\n var result = [];\n var a = this.coefs[1];\n\n if ( a != 0 ) {\n result.push( -this.coefs[0] / a );\n }\n\n return result;\n};\n\n\n/**\n * getQuadraticRoots\n */\nPolynomial.prototype.getQuadraticRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 2 ) {\n var a = this.coefs[2];\n var b = this.coefs[1] / a;\n var c = this.coefs[0] / a;\n var d = b*b - 4*c;\n\n if ( d > 0 ) {\n var e = Math.sqrt(d);\n\n results.push( 0.5 * (-b + e) );\n results.push( 0.5 * (-b - e) );\n }\n else if ( d == 0 ) {\n // really two roots with same value, but we only return one\n results.push( 0.5 * -b );\n }\n }\n\n return results;\n};\n\n\n/**\n * getCubicRoots\n *\n * This code is based on MgcPolynomial.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.geometrictools.com\n */\nPolynomial.prototype.getCubicRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 3 ) {\n var c3 = this.coefs[3];\n var c2 = this.coefs[2] / c3;\n var c1 = this.coefs[1] / c3;\n var c0 = this.coefs[0] / c3;\n\n var a = (3*c1 - c2*c2) / 3;\n var b = (2*c2*c2*c2 - 9*c1*c2 + 27*c0) / 27;\n var offset = c2 / 3;\n var discrim = b*b/4 + a*a*a/27;\n var halfB = b / 2;\n\n var ZEROepsilon = this.zeroErrorEstimate();\n if (Math.abs(discrim) <= ZEROepsilon) {\n discrim = 0;\n }\n\n if ( discrim > 0 ) {\n var e = Math.sqrt(discrim);\n var tmp;\n var root;\n\n tmp = -halfB + e;\n\n if ( tmp >= 0 ) {\n root = Math.pow(tmp, 1/3);\n }\n else {\n root = -Math.pow(-tmp, 1/3);\n }\n\n tmp = -halfB - e;\n\n if ( tmp >= 0 ) {\n root += Math.pow(tmp, 1/3);\n }\n else {\n root -= Math.pow(-tmp, 1/3);\n }\n\n results.push( root - offset );\n }\n else if ( discrim < 0 ) {\n var distance = Math.sqrt(-a/3);\n var angle = Math.atan2( Math.sqrt(-discrim), -halfB) / 3;\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n var sqrt3 = Math.sqrt(3);\n\n results.push( 2*distance*cos - offset );\n results.push( -distance * (cos + sqrt3 * sin) - offset);\n results.push( -distance * (cos - sqrt3 * sin) - offset);\n }\n else {\n var tmp;\n\n if ( halfB >= 0 ) {\n tmp = -Math.pow(halfB, 1/3);\n }\n else {\n tmp = Math.pow(-halfB, 1/3);\n }\n\n results.push( 2*tmp - offset );\n // really should return next root twice, but we return only one\n results.push( -tmp - offset );\n }\n }\n\n return results;\n};\n\n\n/**\n * Sign of a number (+1, -1, +0, -0).\n */\nvar sign = function (x) {\n return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? x : NaN : NaN;\n};\n\n\n/**\n * Calculates roots of quartic polynomial.
\n * First, derivative roots are found, then used to split quartic polynomial \n * into segments, each containing one root of quartic polynomial.\n * Segments are then passed to newton's method to find roots.\n *\n * @returns {Array} roots\n */\nPolynomial.prototype.getQuarticRoots = function () {\n var results = [];\n\n var n = this.getDegree();\n\n if (n == 4) {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice();\n poly.divide_scalar(poly.coefs[n]);\n\n var ERRF = 1e-15;\n\n if (Math.abs(poly.coefs[0]) < 10 * ERRF * Math.abs(poly.coefs[3])) {\n poly.coefs[0] = 0;\n }\n\n var poly_d = poly.getDerivative();\n var derrt = poly_d.getRoots().sort(function (a, b) { return a - b; });\n var dery = [];\n var nr = derrt.length - 1;\n var i;\n var rb = this.bounds();\n\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n\n var ZEROepsilon = this.zeroErrorEstimate(maxabsX);\n \n for (i = 0; i <= nr; i++) {\n dery.push(poly.eval(derrt[i]));\n }\n\n for (i = 0; i <= nr; i++) {\n if (Math.abs(dery[i]) < ZEROepsilon) {\n dery[i] = 0;\n }\n }\n\n i = 0;\n var dx = Math.max(0.1 * (rb.maxX - rb.minX) / n, ERRF);\n var guesses = [];\n var minmax = [];\n\n if (nr > -1) {\n if (dery[0] != 0) {\n if (sign(dery[0]) != sign(poly.eval(derrt[0] - dx) - dery[0])) {\n guesses.push(derrt[0] - dx);\n minmax.push([rb.minX, derrt[0]]);\n }\n }\n else {\n results.push(derrt[0], derrt[0]);\n i++;\n }\n\n for (; i < nr; i++) {\n if (dery[i + 1] == 0) {\n results.push(derrt[i + 1], derrt[i + 1]);\n i++;\n }\n else if (sign(dery[i]) != sign(dery[i + 1])) {\n guesses.push((derrt[i] + derrt[i + 1]) / 2);\n minmax.push([derrt[i], derrt[i + 1]]);\n }\n }\n if (dery[nr] != 0 && sign(dery[nr]) != sign(poly.eval(derrt[nr] + dx) - dery[nr])) {\n guesses.push(derrt[nr] + dx);\n minmax.push([derrt[nr], rb.maxX]);\n }\n }\n\n var f = function (x) { return poly.eval(x); };\n var df = function (x) { return poly_d.eval(x); };\n\n if (guesses.length > 0) {\n for (i = 0; i < guesses.length; i++) {\n guesses[i] = Polynomial.newton_secant_bisection(guesses[i], f, df, 32, minmax[i][0], minmax[i][1]);\n }\n }\n\n results = results.concat(guesses);\n }\n\n return results;\n};\n\n\n/**\n * Estimate what is the maximum polynomial evaluation error value under which polynomial evaluation could be in fact 0.\n * \n * @returns {Number} \n */\nPolynomial.prototype.zeroErrorEstimate = function (maxabsX) {\n var poly = this;\n var ERRF = 1e-15;\n\n if (typeof maxabsX === 'undefined') {\n var rb = poly.bounds();\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n }\n\n if (maxabsX < 0.001) {\n return 2*Math.abs(poly.eval(ERRF));\n }\n\n var n = poly.coefs.length - 1;\n var an = poly.coefs[n];\n\n return 10 * ERRF * poly.coefs.reduce(function (m, v, i) {\n var nm = v / an * Math.pow(maxabsX, i);\n return nm > m ? nm : m;\n }, 0);\n}\n\n\n/**\n * Calculates upper Real roots bounds.
\n * Real roots are in interval [negX, posX]. Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_UpperReal_Fujiwara = function () {\n var a = this.coefs;\n var n = a.length - 1;\n var an = a[n];\n\n if (an != 1) {\n a = this.coefs.map(function (v) {\n return v / an;\n });\n }\n\n var b = a.map(function (v, i) {\n return (i < n)\n ? Math.pow(Math.abs((i == 0) ? v / 2 : v), 1 / (n - i))\n : v;\n });\n\n var coefSelectionFunc;\n var find2Max = function (acc, bi, i) {\n if (coefSelectionFunc(i)) {\n if (acc.max < bi) {\n acc.nearmax = acc.max;\n acc.max = bi;\n }\n else if (acc.nearmax < bi) {\n acc.nearmax = bi;\n }\n }\n return acc;\n };\n\n coefSelectionFunc = function (i) { return i < n && a[i] < 0; };\n var max_nearmax_pos = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n coefSelectionFunc = function (i) { return i < n && ((n % 2 == i % 2) ? a[i] < 0 : a[i] > 0); };\n var max_nearmax_neg = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n return {\n negX: -2 * max_nearmax_neg.max,\n posX: 2 * max_nearmax_pos.max\n };\n};\n\n\n/** \n * Calculates lower Real roots bounds.
\n * There are no Real roots in interval . Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_LowerReal_Fujiwara = function () {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice().reverse();\n\n var res = poly.bounds_UpperReal_Fujiwara();\n\n res.negX = 1 / res.negX;\n res.posX = 1 / res.posX;\n\n return res;\n};\n\n\n/** \n * Calculates left and right Real roots bounds.
\n * Real roots are in interval [minX, maxX]. Combines Fujiwara lower and upper bounds to get minimal interval.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ minX: Number, maxX: Number }}\n*/\nPolynomial.prototype.bounds = function () {\n var urb = this.bounds_UpperReal_Fujiwara();\n var rb = { minX: urb.negX, maxX: urb.posX };\n\n if (urb.negX === 0 && urb.posX === 0) {\n return rb;\n }\n\n if (urb.negX === 0) {\n rb.minX = this.bounds_LowerReal_Fujiwara().posX;\n }\n else if (urb.posX === 0) {\n rb.maxX = this.bounds_LowerReal_Fujiwara().negX;\n }\n\n if (rb.minX > rb.maxX) {\n //console.log('Polynomial.prototype.bounds: poly has no real roots? or floating point error?');\n rb.minX = rb.maxX = 0;\n }\n\n return rb;\n // TODO: if sure that there are no complex roots \n // (maybe by using Sturm's theorem) use:\n // return this.bounds_Real_Laguerre();\n};\n\n\n/**\n * Newton's (Newton-Raphson) method for finding Real roots on univariate function.
\n * When using bounds, algorithm falls back to secant if newton goes out of range.\n * Bisection is fallback for secant when determined secant is not efficient enough.\n * @see {@link http://en.wikipedia.org/wiki/Newton%27s_method}\n * @see {@link http://en.wikipedia.org/wiki/Secant_method}\n * @see {@link http://en.wikipedia.org/wiki/Bisection_method}\n *\n * @param {Number} x0 - Inital root guess\n * @param {function(x)} f - Function which root we are trying to find\n * @param {function(x)} df - Derivative of function f\n * @param {Number} max_iterations - Maximum number of algorithm iterations\n * @param {Number} [min_x] - Left bound value\n * @param {Number} [max_x] - Right bound value\n * @returns {Number} - root\n */\nPolynomial.newton_secant_bisection = function (x0, f, df, max_iterations, min, max) {\n var x, prev_dfx = 0, dfx, prev_x_ef_correction = 0, x_correction, x_new;\n var v, y_atmin, y_atmax;\n\n x = x0;\n\n var ACCURACY = 14;\n var min_correction_factor = Math.pow(10, -ACCURACY);\n var isBounded = (typeof min === 'number' && typeof max === 'number');\n\n if (isBounded) {\n if (min > max) {\n throw new Error(\"newton root finding: min must be greater than max\");\n }\n\n y_atmin = f(min);\n y_atmax = f(max);\n\n if (sign(y_atmin) == sign(y_atmax)) {\n throw new Error(\"newton root finding: y values of bounds must be of opposite sign\");\n }\n }\n\n var isEnoughCorrection = function () {\n // stop if correction is too small or if correction is in simple loop\n return (Math.abs(x_correction) <= min_correction_factor * Math.abs(x))\n || (prev_x_ef_correction == (x - x_correction) - x);\n };\n\n var i;\n\n for (i = 0; i < max_iterations; i++) {\n dfx = df(x);\n\n if (dfx == 0) {\n if (prev_dfx == 0) {\n // error\n throw new Error(\"newton root finding: df(x) is zero\");\n }\n else {\n // use previous derivation value\n dfx = prev_dfx;\n }\n // or move x a little?\n //dfx = df(x != 0 ? x + x * 1e-15 : 1e-15);\n }\n\n prev_dfx = dfx;\n y = f(x);\n x_correction = y / dfx;\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n\n if (isBounded) {\n if (sign(y) == sign(y_atmax)) {\n max = x;\n y_atmax = y;\n }\n else if (sign(y) == sign(y_atmin)) {\n min = x;\n y_atmin = y;\n }\n else {\n x = x_new;\n break;\n }\n\n if ((x_new < min) || (x_new > max)) {\n if (sign(y_atmin) == sign(y_atmax)) {\n break;\n }\n\n var RATIO_LIMIT = 50;\n var AIMED_BISECT_OFFSET = 0.25; // [0, 0.5)\n var dy = y_atmax - y_atmin;\n var dx = max - min;\n\n if (dy == 0) {\n x_correction = x - (min + dx * 0.5);\n }\n else if (Math.abs(dy / Math.min(y_atmin, y_atmax)) > RATIO_LIMIT) {\n x_correction = x - (min + dx * (0.5 + (Math.abs(y_atmin) < Math.abs(y_atmax) ? -AIMED_BISECT_OFFSET : AIMED_BISECT_OFFSET)));\n }\n else {\n x_correction = x - (min - y_atmin / dy * dx);\n }\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n }\n }\n\n prev_x_ef_correction = x - x_new;\n x = x_new;\n }\n\n return x;\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Polynomial;\n}\n","/**\n *\n * SqrtPolynomial.js\n *\n * copyright 2003, 2013 Kevin Lindsey\n *\n */\n\nif (typeof module !== \"undefined\") {\n var Polynomial = require(\"./Polynomial\");\n}\n\n/**\n * class variables\n */\nSqrtPolynomial.VERSION = 1.0;\n\n// setup inheritance\nSqrtPolynomial.prototype = new Polynomial();\nSqrtPolynomial.prototype.constructor = SqrtPolynomial;\nSqrtPolynomial.superclass = Polynomial.prototype;\n\n\n/**\n * SqrtPolynomial\n */\nfunction SqrtPolynomial() {\n this.init( arguments );\n}\n\n\n/**\n * eval\n *\n * @param {Number} x\n * @returns {Number}\n */\nSqrtPolynomial.prototype.eval = function(x) {\n var TOLERANCE = 1e-7;\n var result = SqrtPolynomial.superclass.eval.call(this, x);\n\n // NOTE: May need to change the following. I added these to capture\n // some really small negative values that were being generated by one\n // of my Bezier arcLength functions\n if ( Math.abs(result) < TOLERANCE ) result = 0;\n if ( result < 0 )\n throw new Error(\"SqrtPolynomial.eval: cannot take square root of negative number\");\n\n return Math.sqrt(result);\n};\n\nSqrtPolynomial.prototype.toString = function() {\n var result = SqrtPolynomial.superclass.toString.call(this);\n\n return \"sqrt(\" + result + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = SqrtPolynomial;\n}\n","// expose classes\n\nexports.Polynomial = require('./lib/Polynomial');\nexports.SqrtPolynomial = require('./lib/SqrtPolynomial');\n","/* eslint-disable camelcase, eqeqeq, no-labels, space-infix-ops */\n/**\n *\n * Intersection.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n */\n\nimport {Point2D, Vector2D} from \"kld-affine\";\nimport {Polynomial} from \"kld-polynomial\";\n\n/**\n * @memberof module:kld-intersections.Intersection~\n * @param {*} o\n * @returns {boolean}\n */\nfunction isNullish(o) {\n return o === null || o === undefined;\n}\n\n/**\n * closePolygon\n * @memberof module:kld-intersections.Intersection~\n * @param {Array} points\n * @returns {Array}\n */\nfunction closePolygon(points) {\n const copy = points.slice();\n\n copy.push(points[0]);\n\n return copy;\n}\n\n\n/**\n * Intersection\n * @memberof module:kld-intersections\n */\nclass Intersection {\n /**\n * @param {string} status\n * @returns {module:kld-intersections.Intersection}\n */\n constructor(status) {\n this.init(status);\n }\n\n\n /**\n * init\n *\n * @param {string} status\n * @returns {module:kld-intersections.Intersection}\n */\n init(status) {\n this.status = status;\n this.points = [];\n }\n\n\n /**\n * appendPoint\n *\n * @param {module:kld-intersections.Point2D} point\n */\n appendPoint(point) {\n this.points.push(point);\n }\n\n\n /**\n * appendPoints\n *\n * @param {Array} points\n */\n appendPoints(points) {\n this.points = this.points.concat(points);\n }\n}\n\n// static methods\n\n/**\n * intersect\n *\n * @param {module:kld-intersections.IntersectionArgs} shape1\n * @param {module:kld-intersections.IntersectionArgs} shape2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersect = function(shape1, shape2) {\n let result;\n\n if (!isNullish(shape1) && !isNullish(shape2)) {\n if (shape1.name === \"Path\") {\n result = Intersection.intersectPathShape(shape1, shape2);\n }\n else if (shape2.name === \"Path\") {\n result = Intersection.intersectPathShape(shape2, shape1);\n }\n else {\n let method;\n let args;\n\n if (shape1.name < shape2.name) {\n method = \"intersect\" + shape1.name + shape2.name;\n args = shape1.args.concat(shape2.args);\n }\n else {\n method = \"intersect\" + shape2.name + shape1.name;\n args = shape2.args.concat(shape1.args);\n }\n\n if (!(method in Intersection)) {\n throw new Error(\"Intersection not available: \" + method);\n }\n\n result = Intersection[method].apply(null, args);\n }\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n\n return result;\n};\n\n\n/**\n * intersectPathShape\n *\n * @param {module:kld-intersections.IntersectionArgs} path\n * @param {module:kld-intersections.IntersectionArgs} shape\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPathShape = function(path, shape) {\n const result = new Intersection(\"No Intersection\");\n\n for (const segment of path.args) {\n const inter = Intersection.intersect(segment, shape);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier2\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) {\n let a, b;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b2.multiply(-2);\n const c22 = b1.add(a.add(b3));\n\n a = b1.multiply(-2);\n b = b2.multiply(2);\n const c21 = a.add(b);\n\n const c20 = new Point2D(b1.x, b1.y);\n\n // bezout\n a = c12.x*c11.y - c11.x*c12.y;\n b = c22.x*c11.y - c11.x*c22.y;\n const c = c21.x*c11.y - c11.x*c21.y;\n const d = c11.x*(c10.y - c20.y) + c11.y*(-c10.x + c20.x);\n const e = c22.x*c12.y - c12.x*c22.y;\n const f = c21.x*c12.y - c12.x*c21.y;\n const g = c12.x*(c10.y - c20.y) + c12.y*(-c10.x + c20.x);\n\n // determinant\n const poly = new Polynomial(\n -e*e,\n -2*e*f,\n a*b - f*f - 2*e*g,\n a*c - 2*f*g,\n a*d - g*g\n );\n\n const roots = poly.getRoots();\n\n for (const s of roots) {\n if (0 <= s && s <= 1) {\n const xp = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(c22.multiply(s*s).add(c21.multiply(s).add(c20)));\n break checkRoots;\n }\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier3\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @param {module:kld-intersections.Point2D} b4\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) {\n let a, b, c, d;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n const c10x2 = c10.x*c10.x;\n const c10y2 = c10.y*c10.y;\n const c11x2 = c11.x*c11.x;\n const c11y2 = c11.y*c11.y;\n const c12x2 = c12.x*c12.x;\n const c12y2 = c12.y*c12.y;\n const c20x2 = c20.x*c20.x;\n const c20y2 = c20.y*c20.y;\n const c21x2 = c21.x*c21.x;\n const c21y2 = c21.y*c21.y;\n const c22x2 = c22.x*c22.x;\n const c22y2 = c22.y*c22.y;\n const c23x2 = c23.x*c23.x;\n const c23y2 = c23.y*c23.y;\n\n const poly = new Polynomial(\n -2*c12.x*c12.y*c23.x*c23.y + c12x2*c23y2 + c12y2*c23x2,\n -2*c12.x*c12.y*c22.x*c23.y - 2*c12.x*c12.y*c22.y*c23.x + 2*c12y2*c22.x*c23.x +\n 2*c12x2*c22.y*c23.y,\n -2*c12.x*c21.x*c12.y*c23.y - 2*c12.x*c12.y*c21.y*c23.x - 2*c12.x*c12.y*c22.x*c22.y +\n 2*c21.x*c12y2*c23.x + c12y2*c22x2 + c12x2*(2*c21.y*c23.y + c22y2),\n 2*c10.x*c12.x*c12.y*c23.y + 2*c10.y*c12.x*c12.y*c23.x + c11.x*c11.y*c12.x*c23.y +\n c11.x*c11.y*c12.y*c23.x - 2*c20.x*c12.x*c12.y*c23.y - 2*c12.x*c20.y*c12.y*c23.x -\n 2*c12.x*c21.x*c12.y*c22.y - 2*c12.x*c12.y*c21.y*c22.x - 2*c10.x*c12y2*c23.x -\n 2*c10.y*c12x2*c23.y + 2*c20.x*c12y2*c23.x + 2*c21.x*c12y2*c22.x -\n c11y2*c12.x*c23.x - c11x2*c12.y*c23.y + c12x2*(2*c20.y*c23.y + 2*c21.y*c22.y),\n 2*c10.x*c12.x*c12.y*c22.y + 2*c10.y*c12.x*c12.y*c22.x + c11.x*c11.y*c12.x*c22.y +\n c11.x*c11.y*c12.y*c22.x - 2*c20.x*c12.x*c12.y*c22.y - 2*c12.x*c20.y*c12.y*c22.x -\n 2*c12.x*c21.x*c12.y*c21.y - 2*c10.x*c12y2*c22.x - 2*c10.y*c12x2*c22.y +\n 2*c20.x*c12y2*c22.x - c11y2*c12.x*c22.x - c11x2*c12.y*c22.y + c21x2*c12y2 +\n c12x2*(2*c20.y*c22.y + c21y2),\n 2*c10.x*c12.x*c12.y*c21.y + 2*c10.y*c12.x*c21.x*c12.y + c11.x*c11.y*c12.x*c21.y +\n c11.x*c11.y*c21.x*c12.y - 2*c20.x*c12.x*c12.y*c21.y - 2*c12.x*c20.y*c21.x*c12.y -\n 2*c10.x*c21.x*c12y2 - 2*c10.y*c12x2*c21.y + 2*c20.x*c21.x*c12y2 -\n c11y2*c12.x*c21.x - c11x2*c12.y*c21.y + 2*c12x2*c20.y*c21.y,\n -2*c10.x*c10.y*c12.x*c12.y - c10.x*c11.x*c11.y*c12.y - c10.y*c11.x*c11.y*c12.x +\n 2*c10.x*c12.x*c20.y*c12.y + 2*c10.y*c20.x*c12.x*c12.y + c11.x*c20.x*c11.y*c12.y +\n c11.x*c11.y*c12.x*c20.y - 2*c20.x*c12.x*c20.y*c12.y - 2*c10.x*c20.x*c12y2 +\n c10.x*c11y2*c12.x + c10.y*c11x2*c12.y - 2*c10.y*c12x2*c20.y -\n c20.x*c11y2*c12.x - c11x2*c20.y*c12.y + c10x2*c12y2 + c10y2*c12x2 +\n c20x2*c12y2 + c12x2*c20y2\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xRoots = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n ).getRoots();\n const yRoots = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n ).getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Circle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Circle = function(p1, p2, p3, c, r) {\n return Intersection.intersectBezier2Ellipse(p1, p2, p3, c, r, r);\n};\n\n\n/**\n * intersectBezier2Ellipse\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) {\n let a; // temporary variables\n // c2, c1, c0; // coefficients of quadratic\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const roots = new Polynomial(\n ryry*c2.x*c2.x + rxrx*c2.y*c2.y,\n 2*(ryry*c2.x*c1.x + rxrx*c2.y*c1.y),\n ryry*(2*c2.x*c0.x + c1.x*c1.x) + rxrx*(2*c2.y*c0.y+c1.y*c1.y) -\n 2*(ryry*ec.x*c2.x + rxrx*ec.y*c2.y),\n 2*(ryry*c1.x*(c0.x-ec.x) + rxrx*c1.y*(c0.y-ec.y)),\n ryry*(c0.x*c0.x+ec.x*ec.x) + rxrx*(c0.y*c0.y + ec.y*ec.y) -\n 2*(ryry*ec.x*c0.x + rxrx*ec.y*c0.y) - rxrx*ryry\n ).getRoots();\n\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n result.points.push(c2.multiply(t*t).add(c1.multiply(t).add(c0)));\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Line\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) {\n let a; // temporary variables\n // let c2, c1, c0; // coefficients of quadratic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // Transform cubic coefficients to line's coordinate system and find roots\n // of cubic\n const roots = new Polynomial(\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p4 = p1.lerp(p2, t);\n const p5 = p2.lerp(p3, t);\n\n const p6 = p4.lerp(p5, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p6\n if (a1.x == a2.x) {\n if (min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p6.x && p6.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (min.x <= p6.x && p6.x <= max.x && min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Polygon\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Polygon = function(p1, p2, p3, points) {\n return Intersection.intersectBezier2Polyline(p1, p2, p3, closePolygon(points));\n};\n\n\n/**\n * intersectBezier2Polyline\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Polyline = function(p1, p2, p3, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier2Line(p1, p2, p3, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Rectangle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier2Line(p1, p2, p3, min, topRight);\n const inter2 = Intersection.intersectBezier2Line(p1, p2, p3, topRight, max);\n const inter3 = Intersection.intersectBezier2Line(p1, p2, p3, max, bottomLeft);\n const inter4 = Intersection.intersectBezier2Line(p1, p2, p3, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Bezier3\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} a4\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @param {module:kld-intersections.Point2D} b4\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) {\n let a, b, c, d; // temporary variables\n // c13, c12, c11, c10; // coefficients of cubic\n // c23, c22, c21, c20; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = a1.multiply(-1);\n b = a2.multiply(3);\n c = a3.multiply(-3);\n d = a.add(b.add(c.add(a4)));\n const c13 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(3);\n b = a2.multiply(-6);\n c = a3.multiply(3);\n d = a.add(b.add(c));\n const c12 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(-3);\n b = a2.multiply(3);\n c = a.add(b);\n const c11 = new Vector2D(c.x, c.y);\n\n const c10 = new Vector2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n // bezout\n a = c13.x * c12.y - c12.x * c13.y;\n b = c13.x * c11.y - c11.x * c13.y;\n const c0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const c1 = c21.x * c13.y - c13.x * c21.y;\n const c2 = c22.x * c13.y - c13.x * c22.y;\n const c3 = c23.x * c13.y - c13.x * c23.y;\n d = c13.x * c11.y - c11.x * c13.y;\n const e0 = c13.x * c10.y + c12.x * c11.y - c11.x * c12.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const e1 = c21.x * c13.y - c13.x * c21.y;\n const e2 = c22.x * c13.y - c13.x * c22.y;\n const e3 = c23.x * c13.y - c13.x * c23.y;\n const f0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const f1 = c21.x * c12.y - c12.x * c21.y;\n const f2 = c22.x * c12.y - c12.x * c22.y;\n const f3 = c23.x * c12.y - c12.x * c23.y;\n const g0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const g1 = c21.x * c13.y - c13.x * c21.y;\n const g2 = c22.x * c13.y - c13.x * c22.y;\n const g3 = c23.x * c13.y - c13.x * c23.y;\n const h0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const h1 = c21.x * c12.y - c12.x * c21.y;\n const h2 = c22.x * c12.y - c12.x * c22.y;\n const h3 = c23.x * c12.y - c12.x * c23.y;\n const i0 = c11.x * c10.y - c10.x * c11.y + c20.x * c11.y - c11.x * c20.y;\n const i1 = c21.x * c11.y - c11.x * c21.y;\n const i2 = c22.x * c11.y - c11.x * c22.y;\n const i3 = c23.x * c11.y - c11.x * c23.y;\n\n // determinant\n const poly = new Polynomial(\n -c3 * e3 * g3,\n -c3 * e3 * g2 - c3 * e2 * g3 - c2 * e3 * g3,\n -c3 * e3 * g1 - c3 * e2 * g2 - c2 * e3 * g2 - c3 * e1 * g3 - c2 * e2 * g3 - c1 * e3 * g3,\n -c3 * e3 * g0 - c3 * e2 * g1 - c2 * e3 * g1 - c3 * e1 * g2 - c2 * e2 * g2 - c1 * e3 * g2 - c3 * e0 * g3 - c2 * e1 * g3 - c1 * e2 * g3 - c0 * e3 * g3 + b * f3 * g3 + c3 * d * h3 - a * f3 * h3 + a * e3 * i3,\n -c3 * e2 * g0 - c2 * e3 * g0 - c3 * e1 * g1 - c2 * e2 * g1 - c1 * e3 * g1 - c3 * e0 * g2 - c2 * e1 * g2 - c1 * e2 * g2 - c0 * e3 * g2 + b * f3 * g2 - c2 * e0 * g3 - c1 * e1 * g3 - c0 * e2 * g3 + b * f2 * g3 + c3 * d * h2 - a * f3 * h2 + c2 * d * h3 - a * f2 * h3 + a * e3 * i2 + a * e2 * i3,\n -c3 * e1 * g0 - c2 * e2 * g0 - c1 * e3 * g0 - c3 * e0 * g1 - c2 * e1 * g1 - c1 * e2 * g1 - c0 * e3 * g1 + b * f3 * g1 - c2 * e0 * g2 - c1 * e1 * g2 - c0 * e2 * g2 + b * f2 * g2 - c1 * e0 * g3 - c0 * e1 * g3 + b * f1 * g3 + c3 * d * h1 - a * f3 * h1 + c2 * d * h2 - a * f2 * h2 + c1 * d * h3 - a * f1 * h3 + a * e3 * i1 + a * e2 * i2 + a * e1 * i3,\n -c3 * e0 * g0 - c2 * e1 * g0 - c1 * e2 * g0 - c0 * e3 * g0 + b * f3 * g0 - c2 * e0 * g1 - c1 * e1 * g1 - c0 * e2 * g1 + b * f2 * g1 - c1 * e0 * g2 - c0 * e1 * g2 + b * f1 * g2 - c0 * e0 * g3 + b * f0 * g3 + c3 * d * h0 - a * f3 * h0 + c2 * d * h1 - a * f2 * h1 + c1 * d * h2 - a * f1 * h2 + c0 * d * h3 - a * f0 * h3 + a * e3 * i0 + a * e2 * i1 + a * e1 * i2 - b * d * i3 + a * e0 * i3,\n -c2 * e0 * g0 - c1 * e1 * g0 - c0 * e2 * g0 + b * f2 * g0 - c1 * e0 * g1 - c0 * e1 * g1 + b * f1 * g1 - c0 * e0 * g2 + b * f0 * g2 + c2 * d * h0 - a * f2 * h0 + c1 * d * h1 - a * f1 * h1 + c0 * d * h2 - a * f0 * h2 + a * e2 * i0 + a * e1 * i1 - b * d * i2 + a * e0 * i2,\n -c1 * e0 * g0 - c0 * e1 * g0 + b * f1 * g0 - c0 * e0 * g1 + b * f0 * g1 + c1 * d * h0 - a * f1 * h0 + c0 * d * h1 - a * f0 * h1 + a * e1 * i0 - b * d * i1 + a * e0 * i1,\n -c0 * e0 * g0 + b * f0 * g0 + c0 * d * h0 - a * f0 * h0 - b * d * i0 + a * e0 * i0\n );\n poly.simplify();\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xp = new Polynomial(\n c13.x,\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c13.y,\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Circle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) {\n return Intersection.intersectBezier3Ellipse(p1, p2, p3, p4, c, r, r);\n};\n\n\n/**\n * intersectBezier3Ellipse\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const poly = new Polynomial(\n c3.x*c3.x*ryry + c3.y*c3.y*rxrx,\n 2*(c3.x*c2.x*ryry + c3.y*c2.y*rxrx),\n 2*(c3.x*c1.x*ryry + c3.y*c1.y*rxrx) + c2.x*c2.x*ryry + c2.y*c2.y*rxrx,\n 2*c3.x*ryry*(c0.x - ec.x) + 2*c3.y*rxrx*(c0.y - ec.y) +\n 2*(c2.x*c1.x*ryry + c2.y*c1.y*rxrx),\n 2*c2.x*ryry*(c0.x - ec.x) + 2*c2.y*rxrx*(c0.y - ec.y) +\n c1.x*c1.x*ryry + c1.y*c1.y*rxrx,\n 2*c1.x*ryry*(c0.x - ec.x) + 2*c1.y*rxrx*(c0.y - ec.y),\n c0.x*c0.x*ryry - 2*c0.y*ec.y*rxrx - 2*c0.x*ec.x*ryry +\n c0.y*c0.y*rxrx + ec.x*ec.x*ryry + ec.y*ec.y*rxrx - rxrx*ryry\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const t of roots) {\n result.points.push(\n c3.multiply(t*t*t).add(c2.multiply(t*t).add(c1.multiply(t).add(c0)))\n );\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Line\n *\n * Many thanks to Dan Sunday at SoftSurfer.com. He gave me a very thorough\n * sketch of the algorithm used here. Without his help, I'm not sure when I\n * would have figured out this intersection problem.\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n // Start with Bezier using Bernstein polynomials for weighting functions:\n // (1-t^3)P1 + 3t(1-t)^2P2 + 3t^2(1-t)P3 + t^3P4\n //\n // Expand and collect terms to form linear combinations of original Bezier\n // controls. This ends up with a vector cubic in t:\n // (-P1+3P2-3P3+P4)t^3 + (3P1-6P2+3P3)t^2 + (-3P1+3P2)t + P1\n // /\\ /\\ /\\ /\\\n // || || || ||\n // c3 c2 c1 c0\n\n // Calculate the coefficients\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // ?Rotate each cubic coefficient using line for new coordinate system?\n // Find roots of rotated cubic\n const roots = new Polynomial(\n n.dot(c3),\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p5 = p1.lerp(p2, t);\n const p6 = p2.lerp(p3, t);\n const p7 = p3.lerp(p4, t);\n\n const p8 = p5.lerp(p6, t);\n const p9 = p6.lerp(p7, t);\n\n const p10 = p8.lerp(p9, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p10\n if (a1.x == a2.x) {\n if (min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p10.x && p10.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (min.x <= p10.x && p10.x <= max.x && min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Polygon\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) {\n return this.intersectBezier3Polyline(p1, p2, p3, p4, closePolygon(points));\n};\n\n\n/**\n * intersectBezier3Polyline\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier3Line(p1, p2, p3, p4, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Rectangle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier3Line(p1, p2, p3, p4, min, topRight);\n const inter2 = Intersection.intersectBezier3Line(p1, p2, p3, p4, topRight, max);\n const inter3 = Intersection.intersectBezier3Line(p1, p2, p3, p4, max, bottomLeft);\n const inter4 = Intersection.intersectBezier3Line(p1, p2, p3, p4, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleCircle\n *\n * @param {module:kld-intersections.Point2D} c1\n * @param {number} r1\n * @param {module:kld-intersections.Point2D} c2\n * @param {number} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleCircle = function(c1, r1, c2, r2) {\n let result;\n\n // Determine minimum and maximum radii where circles can intersect\n const r_max = r1 + r2;\n const r_min = Math.abs(r1 - r2);\n\n // Determine actual distance between circle circles\n const c_dist = c1.distanceFrom(c2);\n\n if (c_dist > r_max) {\n result = new Intersection(\"Outside\");\n }\n else if (c_dist < r_min) {\n result = new Intersection(\"Inside\");\n }\n else {\n result = new Intersection(\"Intersection\");\n\n const a = (r1*r1 - r2*r2 + c_dist*c_dist) / (2*c_dist);\n const h = Math.sqrt(r1*r1 - a*a);\n const p = c1.lerp(c2, a/c_dist);\n const b = h / c_dist;\n\n result.points.push(\n new Point2D(\n p.x - b * (c2.y - c1.y),\n p.y + b * (c2.x - c1.x)\n )\n );\n result.points.push(\n new Point2D(\n p.x + b * (c2.y - c1.y),\n p.y - b * (c2.x - c1.x)\n )\n );\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleEllipse\n *\n * @param {module:kld-intersections.Point2D} cc\n * @param {number} r\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) {\n return Intersection.intersectEllipseEllipse(cc, r, r, ec, rx, ry);\n};\n\n\n/**\n * intersectCircleLine\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleLine = function(c, r, a1, a2) {\n let result;\n const a = (a2.x - a1.x) * (a2.x - a1.x) +\n (a2.y - a1.y) * (a2.y - a1.y);\n const b = 2 * ((a2.x - a1.x) * (a1.x - c.x) +\n (a2.y - a1.y) * (a1.y - c.y));\n const cc = c.x*c.x + c.y*c.y + a1.x*a1.x + a1.y*a1.y -\n 2 * (c.x * a1.x + c.y * a1.y) - r*r;\n const deter = b*b - 4*a*cc;\n\n if (deter < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (deter == 0) {\n result = new Intersection(\"Tangent\");\n // NOTE: should calculate this point\n }\n else {\n const e = Math.sqrt(deter);\n const u1 = (-b + e) / (2*a);\n const u2 = (-b - e) / (2*a);\n\n if ((u1 < 0 || u1 > 1) && (u2 < 0 || u2 > 1)) {\n if ((u1 < 0 && u2 < 0) || (u1 > 1 && u2 > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n\n if (0 <= u1 && u1 <= 1) {\n result.points.push(a1.lerp(a2, u1));\n }\n\n if (0 <= u2 && u2 <= 1) {\n result.points.push(a1.lerp(a2, u2));\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectCirclePolygon\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCirclePolygon = function(c, r, points) {\n return this.intersectCirclePolyline(c, r, closePolygon(points));\n};\n\n\n/**\n * intersectCirclePolyline\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCirclePolyline = function(c, r, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n let inter;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n\n inter = Intersection.intersectCircleLine(c, r, a1, a2);\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleRectangle\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleRectangle = function(c, r, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectCircleLine(c, r, min, topRight);\n const inter2 = Intersection.intersectCircleLine(c, r, topRight, max);\n const inter3 = Intersection.intersectCircleLine(c, r, max, bottomLeft);\n const inter4 = Intersection.intersectCircleLine(c, r, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter1.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseEllipse\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {module:kld-intersections.Point2D} c1\n * @param {number} rx1\n * @param {number} ry1\n * @param {module:kld-intersections.Point2D} c2\n * @param {number} rx2\n * @param {number} ry2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) {\n const a = [\n ry1*ry1, 0, rx1*rx1, -2*ry1*ry1*c1.x, -2*rx1*rx1*c1.y,\n ry1*ry1*c1.x*c1.x + rx1*rx1*c1.y*c1.y - rx1*rx1*ry1*ry1\n ];\n const b = [\n ry2*ry2, 0, rx2*rx2, -2*ry2*ry2*c2.x, -2*rx2*rx2*c2.y,\n ry2*ry2*c2.x*c2.x + rx2*rx2*c2.y*c2.y - rx2*rx2*ry2*ry2\n ];\n\n const yPoly = Intersection.bezout(a, b);\n const yRoots = yPoly.getRoots();\n const epsilon = 1e-3;\n const norm0 = (a[0]*a[0] + 2*a[1]*a[1] + a[2]*a[2]) * epsilon;\n const norm1 = (b[0]*b[0] + 2*b[1]*b[1] + b[2]*b[2]) * epsilon;\n const result = new Intersection(\"No Intersection\");\n\n for (let y = 0; y < yRoots.length; y++) {\n const xPoly = new Polynomial(\n a[0],\n a[3] + yRoots[y] * a[1],\n a[5] + yRoots[y] * (a[4] + yRoots[y]*a[2])\n );\n const xRoots = xPoly.getRoots();\n\n for (let x = 0; x < xRoots.length; x++) {\n let tst =\n (a[0]*xRoots[x] + a[1]*yRoots[y] + a[3]) * xRoots[x] +\n (a[2]*yRoots[y] + a[4]) * yRoots[y] + a[5];\n if (Math.abs(tst) < norm0) {\n tst =\n (b[0]*xRoots[x] + b[1]*yRoots[y] + b[3]) * xRoots[x] +\n (b[2]*yRoots[y] + b[4]) * yRoots[y] + b[5];\n if (Math.abs(tst) < norm1) {\n result.appendPoint(new Point2D(xRoots[x], yRoots[y]));\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseLine\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseLine = function(c, rx, ry, a1, a2) {\n let result;\n const orign = new Vector2D(a1.x, a1.y);\n const dir = Vector2D.fromPoints(a1, a2);\n const center = new Vector2D(c.x, c.y);\n const diff = orign.subtract(center);\n const mDir = new Vector2D(dir.x/(rx*rx), dir.y/(ry*ry));\n const mDiff = new Vector2D(diff.x/(rx*rx), diff.y/(ry*ry));\n\n const a = dir.dot(mDir);\n const b = dir.dot(mDiff);\n c = diff.dot(mDiff) - 1.0;\n const d = b*b - a*c;\n\n if (d < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (d > 0) {\n const root = Math.sqrt(d); // eslint-disable-line no-shadow\n const t_a = (-b - root) / a;\n const t_b = (-b + root) / a;\n\n if ((t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b)) {\n if ((t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n if (0 <= t_a && t_a <= 1) {\n result.appendPoint(a1.lerp(a2, t_a));\n }\n if (0 <= t_b && t_b <= 1) {\n result.appendPoint(a1.lerp(a2, t_b));\n }\n }\n }\n else {\n const t = -b/a;\n\n if (0 <= t && t <= 1) {\n result = new Intersection(\"Intersection\");\n result.appendPoint(a1.lerp(a2, t));\n }\n else {\n result = new Intersection(\"Outside\");\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipsePolygon\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipsePolygon = function(c, rx, ry, points) {\n return this.intersectEllipsePolyline(c, rx, ry, closePolygon(points));\n};\n\n\n/**\n * intersectEllipsePolyline\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipsePolyline = function(c, rx, ry, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectEllipseLine(c, rx, ry, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseRectangle\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectEllipseLine(c, rx, ry, min, topRight);\n const inter2 = Intersection.intersectEllipseLine(c, rx, ry, topRight, max);\n const inter3 = Intersection.intersectEllipseLine(c, rx, ry, max, bottomLeft);\n const inter4 = Intersection.intersectEllipseLine(c, rx, ry, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineLine\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLineLine = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n const ub = ub_t / u_b;\n\n if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * intersectLinePolygon\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLinePolygon = function(a1, a2, points) {\n return this.intersectLinePolyline(a1, a2, closePolygon(points));\n};\n\n\n/**\n * intersectLinePolyline\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLinePolyline = function(a1, a2, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectLineLine(a1, a2, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineRectangle\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLineRectangle = function(a1, a2, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineLine(min, topRight, a1, a2);\n const inter2 = Intersection.intersectLineLine(topRight, max, a1, a2);\n const inter3 = Intersection.intersectLineLine(max, bottomLeft, a1, a2);\n const inter4 = Intersection.intersectLineLine(bottomLeft, min, a1, a2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolygonPolygon\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonPolygon = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), closePolygon(points2));\n};\n\n\n/**\n * intersectPolygonPolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonPolyline = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), points2);\n};\n\n\n/**\n * intersectPolygonRectangle\n *\n * @param {Array} points\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonRectangle = function(points, r1, r2) {\n return this.intersectPolylineRectangle(closePolygon(points), r1, r2);\n};\n\n\n/**\n * intersectPolylinePolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolylinePolyline = function(points1, points2) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points1;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points1[i];\n const a2 = points1[i + 1];\n const inter = Intersection.intersectLinePolyline(a1, a2, points2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolylineRectangle\n *\n * @param {Array} points\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolylineRectangle = function(points, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLinePolyline(min, topRight, points);\n const inter2 = Intersection.intersectLinePolyline(topRight, max, points);\n const inter3 = Intersection.intersectLinePolyline(max, bottomLeft, points);\n const inter4 = Intersection.intersectLinePolyline(bottomLeft, min, points);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRectangleRectangle\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectRectangleRectangle = function(a1, a2, b1, b2) {\n const min = a1.min(a2);\n const max = a1.max(a2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineRectangle(min, topRight, b1, b2);\n const inter2 = Intersection.intersectLineRectangle(topRight, max, b1, b2);\n const inter3 = Intersection.intersectLineRectangle(max, bottomLeft, b1, b2);\n const inter4 = Intersection.intersectLineRectangle(bottomLeft, min, b1, b2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRayRay\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectRayRay = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * bezout\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * @param {Array} e1\n * @param {Array} e2\n * @returns {external:Polynomial}\n */\nIntersection.bezout = function(e1, e2) {\n const AB = e1[0]*e2[1] - e2[0]*e1[1];\n const AC = e1[0]*e2[2] - e2[0]*e1[2];\n const AD = e1[0]*e2[3] - e2[0]*e1[3];\n const AE = e1[0]*e2[4] - e2[0]*e1[4];\n const AF = e1[0]*e2[5] - e2[0]*e1[5];\n const BC = e1[1]*e2[2] - e2[1]*e1[2];\n const BE = e1[1]*e2[4] - e2[1]*e1[4];\n const BF = e1[1]*e2[5] - e2[1]*e1[5];\n const CD = e1[2]*e2[3] - e2[2]*e1[3];\n const DE = e1[3]*e2[4] - e2[3]*e1[4];\n const DF = e1[3]*e2[5] - e2[3]*e1[5];\n const BFpDE = BF + DE;\n const BEmCD = BE - CD;\n\n return new Polynomial(\n AB*BC - AC*AC,\n AB*BEmCD + AD*BC - 2*AC*AE,\n AB*BFpDE + AD*BEmCD - AE*AE - 2*AC*AF,\n AB*DF + AD*BFpDE - 2*AE*AF,\n AD*DF - AF*AF\n );\n};\n\nexport default Intersection;\n","/**\n *\n * IntersectionArgs.js\n *\n * @copyright 2002, 2017 Kevin Lindsey\n *\n */\n\n/**\n * IntersectionArgs\n * @memberof module:kld-intersections\n */\nclass IntersectionArgs {\n /**\n * @param {string} name\n * @param {Array} args\n * @returns {module:kld-intersections.IntersectionArgs}\n */\n constructor(name, args) {\n this.init(name, args);\n }\n /**\n * init\n *\n * @param {string} name\n * @param {Array} args\n */\n init(name, args) {\n this.name = name;\n this.args = args;\n }\n}\n\nexport default IntersectionArgs;\n","/**\n * Shapes\n *\n * @copyright 2017, Kevin Lindsey\n * @module Shapes\n */\n\nimport {Point2D} from \"kld-affine\";\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\n/**\n * @namespace\n */\nconst Shapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) {\n return new IntersectionArgs(\"Bezier2\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y)\n ]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @param {number} p4x\n * @param {number} p4y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) {\n return new IntersectionArgs(\"Bezier3\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y),\n new Point2D(p4x, p4y)\n ]);\n};\n\n\n/**\n * circle\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radius\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.circle = function(centerX, centerY, radius) {\n return new IntersectionArgs(\"Circle\", [\n new Point2D(centerX, centerY),\n radius\n ]);\n};\n\n\n/**\n * ellipse\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.ellipse = function(centerX, centerY, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [\n new Point2D(centerX, centerY),\n radiusX,\n radiusY\n ]);\n};\n\n\n/**\n * line\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.line = function(p1x, p1y, p2x, p2y) {\n return new IntersectionArgs(\"Line\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y)\n ]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", segments);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} coords\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.polygon = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} coords\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.polyline = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.rectangle = function(x, y, width, height) {\n return new IntersectionArgs(\"Rectangle\", [\n new Point2D(x, y),\n new Point2D(x + width, y + height)\n ]);\n};\n\n\nexport default Shapes;\n","/**\n * AffineShapes\n *\n * @copyright 2017, Kevin Lindsey\n * @module AffineShapes\n */\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\n/**\n * @namespace\n */\nconst AffineShapes = {};\n\n/**\n * quadraticBezier\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.quadraticBezier = function(p1, p2, p3) {\n return new IntersectionArgs(\"Bezier2\", [p1, p2, p3]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.cubicBezier = function(p1, p2, p3, p4) {\n return new IntersectionArgs(\"Bezier3\", [p1, p2, p3, p4]);\n};\n\n\n/**\n * circle\n *\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radius\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.circle = function(center, radius) {\n return new IntersectionArgs(\"Circle\", [center, radius]);\n};\n\n\n/**\n * ellipse\n *\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.ellipse = function(center, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [center, radiusX, radiusY]);\n};\n\n\n/**\n * line\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.line = function(p1, p2) {\n return new IntersectionArgs(\"Line\", [p1, p2]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", [segments]);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} points\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.polygon = function(points) {\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} points\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.polyline = function(points) {\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {module:kld-intersections.Point2D} topLeft\n * @param {module:kld-intersections.Vector2D} size\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.rectangle = function(topLeft, size) {\n return new IntersectionArgs(\"Rectangle\", [topLeft, topLeft.add(size)]);\n};\n\n\nexport default AffineShapes;\n","/**\n *\n * IntersectionQuery.js\n *\n * @copyright 2017 Kevin Lindsey\n * @module IntersectionQuery\n */\n\nimport {Vector2D} from \"kld-affine\";\n\n/**\n * @namespace\n */\nconst IntersectionQuery = {};\n\n\n/**\n * pointInCircle\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radius\n * @returns {boolean}\n */\nIntersectionQuery.pointInCircle = function(point, center, radius) {\n const v = Vector2D.fromPoints(center, point);\n\n return v.length() <= radius;\n};\n\n\n/**\n * pointInEllipse\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {boolean}\n */\nIntersectionQuery.pointInEllipse = function(point, center, radiusX, radiusY) {\n const len = point.subtract(center);\n\n return (len.x * len.x) / (radiusX * radiusX) + (len.y * len.y) / (radiusY * radiusY) <= 1;\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolyline = function(point, points) {\n const {length: len} = points;\n let counter = 0;\n let xInter;\n\n let p1 = points[0];\n\n for (let i = 1; i <= len; i++) {\n const p2 = points[i % len];\n const minY = Math.min(p1.y, p2.y);\n const maxY = Math.max(p1.y, p2.y);\n const maxX = Math.max(p1.x, p2.x);\n\n if (p1.y !== p2.y && minY < point.y && point.y <= maxY && point.x <= maxX) {\n xInter = (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;\n\n if (p1.x === p2.x || point.x <= xInter) {\n counter++;\n }\n }\n\n p1 = p2;\n }\n\n return (counter % 2 === 1);\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline;\n\n\n/**\n * pointInRectangle\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} topLeft\n * @param {module:kld-intersections.Point2D} bottomRight\n * @returns {boolean}\n */\nIntersectionQuery.pointInRectangle = function(point, topLeft, bottomRight) {\n return (\n topLeft.x <= point.x && point.x < bottomRight.x &&\n topLeft.y <= point.y && point.y < bottomRight.y\n );\n};\n\n\nexport default IntersectionQuery;\n"],"names":["Point2D","x","y","Object","defineProperties","this","value","undefined","writable","enumerable","configurable","prototype","clone","constructor","add","that","subtract","multiply","scalar","divide","equals","precisionEquals","precision","Math","abs","lerp","t","omt","distanceFrom","dx","dy","sqrt","min","max","transform","matrix","a","c","e","b","d","f","toString","module","Vector2D","fromPoints","p1","p2","length","magnitude","dot","cross","determinant","unit","angleBetween","cos","radians","acos","perp","perpendicular","project","percent","setReadonlyProperty","object","property","defineProperty","Matrix2D","IDENTITY","translation","tx","ty","scaling","scale","scalingAt","center","nonUniformScaling","scaleX","scaleY","nonUniformScalingAt","rotation","s","sin","rotationAt","rotationFromVector","vector","xFlip","yFlip","xSkew","tan","ySkew","isIdentity","inverse","det1","idet","det2","det3","translate","scaleAt","scaleNonUniform","scaleNonUniformAt","rotate","rotateAt","cx","cy","rotateFromVector","flipX","flipY","skewX","skewY","isInvertible","getScale","getDecomposition","E","F","G","H","Q","R","a1","atan2","a2","theta","phi","rotation0","join","require","Polynomial","init","arguments","TOLERANCE","ACCURACY","interpolate","xs","ys","n","offset","Array","Error","isNaN","ns","diff","i","dift","m","ho","hp","w","den","coefs","push","_variable","_s","eval","result","d1","getDegree","d2","dmax","v1","v2","j","divide_scalar","simplify","pop","bisection","minValue","maxValue","tmp1","log","tmp2","LN10","iters","ceil","LN2","signs","round","sign","trapezoid","range","it","delta","sum","simpson","st","os","ost","romberg","MAX","h","getDerivative","derivative","getRoots","getLinearRoot","getQuadraticRoots","getCubicRoots","getQuarticRoots","getRootsInInterval","root","roots","droots","results","c3","c2","c1","discrim","halfB","ZEROepsilon","zeroErrorEstimate","tmp","pow","distance","angle","sqrt3","NaN","poly","slice","poly_d","derrt","sort","dery","nr","rb","bounds","maxabsX","minX","maxX","guesses","minmax","df","newton_secant_bisection","concat","an","reduce","v","nm","bounds_UpperReal_Fujiwara","map","coefSelectionFunc","find2Max","acc","bi","nearmax","max_nearmax_pos","negX","posX","bounds_LowerReal_Fujiwara","reverse","res","urb","x0","max_iterations","dfx","x_correction","x_new","y_atmin","y_atmax","prev_dfx","prev_x_ef_correction","min_correction_factor","isBounded","isEnoughCorrection","SqrtPolynomial","VERSION","superclass","call","isNullish","o","closePolygon","points","copy","Intersection","status","point","intersect","shape1","shape2","name","intersectPathShape","method","args","apply","path","shape","segment","inter","appendPoints","intersectBezier2Bezier2","a3","b1","b2","b3","c12","c11","c10","c22","c21","c20","g","xp","xRoots","yp","yRoots","checkRoots","xRoot","k","intersectBezier2Bezier3","b4","c23","c10x2","c10y2","c11x2","c11y2","c12x2","c12y2","c20x2","c20y2","c21x2","c21y2","c22x2","c22y2","c23x2","c23y2","intersectBezier2Circle","p3","r","intersectBezier2Ellipse","ec","rx","ry","c0","rxrx","ryry","intersectBezier2Line","cl","p4","p5","p6","appendPoint","intersectBezier2Polygon","intersectBezier2Polyline","len","intersectBezier2Rectangle","r1","r2","topRight","bottomLeft","inter1","inter2","inter3","inter4","intersectBezier3Bezier3","a4","c13","e0","e1","e2","e3","f0","f1","f2","f3","g0","g1","g2","g3","h0","h1","h2","h3","i0","i1","i2","i3","intersectBezier3Circle","intersectBezier3Ellipse","intersectBezier3Line","p7","p8","p9","p10","intersectBezier3Polygon","intersectBezier3Polyline","intersectBezier3Rectangle","intersectCircleCircle","r_max","r_min","c_dist","p","intersectCircleEllipse","cc","intersectEllipseEllipse","intersectCircleLine","deter","u1","u2","intersectCirclePolygon","intersectCirclePolyline","intersectCircleRectangle","rx1","ry1","rx2","ry2","bezout","norm0","norm1","tst","intersectEllipseLine","orign","dir","mDir","mDiff","t_a","t_b","intersectEllipsePolygon","intersectEllipsePolyline","intersectEllipseRectangle","intersectLineLine","ua_t","ub_t","u_b","ua","ub","intersectLinePolygon","intersectLinePolyline","intersectLineRectangle","intersectPolygonPolygon","points1","points2","intersectPolylinePolyline","intersectPolygonPolyline","intersectPolygonRectangle","intersectPolylineRectangle","intersectRectangleRectangle","intersectRayRay","AB","AC","AD","AE","AF","BC","BE","BF","CD","DE","DF","BFpDE","BEmCD","IntersectionArgs","Shapes","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","centerX","centerY","radius","radiusX","radiusY","segments","coords","width","height","AffineShapes","topLeft","size","IntersectionQuery","xInter","counter","minY","maxY","pointInPolygon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0M,EAFWlI,EAAOxE,EAAf5N,OACHua,EAAU,EAGVza,EAAK8N,EAAO,GAEP/H,EAAI,EAAGA,GAAKuM,EAAKvM,IAAK,KACrB9F,EAAK6N,EAAO/H,EAAIuM,GAChBoI,EAAOjc,KAAKS,IAAIc,EAAG5C,EAAG6C,EAAG7C,GACzBud,EAAOlc,KAAKU,IAAIa,EAAG5C,EAAG6C,EAAG7C,GACzB+N,EAAO1M,KAAKU,IAAIa,EAAG7C,EAAG8C,EAAG9C,GAE3B6C,EAAG5C,IAAM6C,EAAG7C,GAAKsd,EAAOxM,EAAM9Q,GAAK8Q,EAAM9Q,GAAKud,GAAQzM,EAAM/Q,GAAKgO,IACjEqP,GAAUtM,EAAM9Q,EAAI4C,EAAG5C,IAAM6C,EAAG9C,EAAI6C,EAAG7C,IAAM8C,EAAG7C,EAAI4C,EAAG5C,GAAK4C,EAAG7C,GAE3D6C,EAAG7C,IAAM8C,EAAG9C,GAAK+Q,EAAM/Q,GAAKqd,IAC5BC,KAIRza,EAAKC,SAGDwa,EAAU,GAAM,IAU5BF,EAAkBK,eAAiBL,EAAkBM,gBAWrDN,EAAkBO,iBAAmB,SAAS5M,EAAOmM,EAASU,UAEtDV,EAAQld,GAAK+Q,EAAM/Q,GAAK+Q,EAAM/Q,EAAI4d,EAAY5d,GAC9Ckd,EAAQjd,GAAK8Q,EAAM9Q,GAAK8Q,EAAM9Q,EAAI2d,EAAY3d"} \ No newline at end of file diff --git a/dist/index-umd.js b/dist/index-umd.js index e645cb7..4f21a75 100644 --- a/dist/index-umd.js +++ b/dist/index-umd.js @@ -2027,7 +2027,7 @@ var Polynomial = Polynomial_1; /** - * + * @memberof module:kld-intersections.Intersection~ * @param {*} o * @returns {boolean} */ @@ -2037,9 +2037,9 @@ } /** * closePolygon - * - * @param {Array} points - * @returns {Array} + * @memberof module:kld-intersections.Intersection~ + * @param {Array} points + * @returns {Array} */ @@ -2049,7 +2049,8 @@ return copy; } /** - * Intersection + * Intersection + * @memberof module:kld-intersections */ @@ -2058,6 +2059,7 @@ function () { /** * @param {string} status + * @returns {module:kld-intersections.Intersection} */ function Intersection(status) { _classCallCheck(this, Intersection); @@ -2068,7 +2070,7 @@ * init * * @param {string} status - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2081,7 +2083,7 @@ /** * appendPoint * - * @param {Point2D} point + * @param {module:kld-intersections.Point2D} point */ }, { @@ -2092,7 +2094,7 @@ /** * appendPoints * - * @param {Array} points + * @param {Array} points */ }, { @@ -2108,9 +2110,9 @@ /** * intersect * - * @param {IntersectionArgs} shape1 - * @param {IntersectionArgs} shape2 - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} shape1 + * @param {module:kld-intersections.IntersectionArgs} shape2 + * @returns {module:kld-intersections.Intersection} */ @@ -2149,9 +2151,9 @@ /** * intersectPathShape * - * @param {IntersectionArgs} path - * @param {IntersectionArgs} shape - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} path + * @param {module:kld-intersections.IntersectionArgs} shape + * @returns {module:kld-intersections.Intersection} */ @@ -2191,13 +2193,13 @@ /** * intersectBezier2Bezier2 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @returns {module:kld-intersections.Intersection} */ @@ -2303,14 +2305,14 @@ /** * intersectBezier2Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ @@ -2423,12 +2425,12 @@ /** * intersectBezier2Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2438,13 +2440,13 @@ /** * intersectBezier2Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2498,12 +2500,12 @@ /** * intersectBezier2Line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -2588,11 +2590,11 @@ /** * intersectBezier2Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -2602,11 +2604,11 @@ /** * intersectBezier2Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -2630,12 +2632,12 @@ /** * intersectBezier2Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -2663,15 +2665,15 @@ /** * intersectBezier3Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} a4 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} a4 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ @@ -2817,13 +2819,13 @@ /** * intersectBezier3Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2833,14 +2835,14 @@ /** * intersectBezier3Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -2906,13 +2908,13 @@ * sketch of the algorithm used here. Without his help, I'm not sure when I * would have figured out this intersection problem. * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3019,12 +3021,12 @@ /** * intersectBezier3Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3034,12 +3036,12 @@ /** * intersectBezier3Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3063,13 +3065,13 @@ /** * intersectBezier3Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3097,11 +3099,11 @@ /** * intersectCircleCircle * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} r1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} r2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3132,12 +3134,12 @@ /** * intersectCircleEllipse * - * @param {Point2D} cc + * @param {module:kld-intersections.Point2D} cc * @param {number} r - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3147,11 +3149,11 @@ /** * intersectCircleLine * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3195,10 +3197,10 @@ /** * intersectCirclePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3208,10 +3210,10 @@ /** * intersectCirclePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3238,11 +3240,11 @@ /** * intersectCircleRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3278,13 +3280,13 @@ * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} rx1 * @param {number} ry1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} rx2 * @param {number} ry2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ @@ -3326,12 +3328,12 @@ * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ @@ -3389,11 +3391,11 @@ /** * intersectEllipsePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3403,11 +3405,11 @@ /** * intersectEllipsePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3431,12 +3433,12 @@ /** * intersectEllipseRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3464,11 +3466,11 @@ /** * intersectLineLine * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3499,10 +3501,10 @@ /** * intersectLinePolygon * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3512,10 +3514,10 @@ /** * intersectLinePolyline * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ @@ -3539,11 +3541,11 @@ /** * intersectLineRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3571,9 +3573,9 @@ /** * intersectPolygonPolygon * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3583,9 +3585,9 @@ /** * intersectPolygonPolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3595,10 +3597,10 @@ /** * intersectPolygonRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3608,9 +3610,9 @@ /** * intersectPolylinePolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ @@ -3634,10 +3636,10 @@ /** * intersectPolylineRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ @@ -3665,11 +3667,11 @@ /** * intersectRectangleRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3697,11 +3699,11 @@ /** * intersectRayRay * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ @@ -3730,9 +3732,9 @@ * code along with many other excellent examples are avaiable at his site: * http://www.magic-software.com * - * @param {Array} e1 - * @param {Array} e2 - * @returns {Polynomial} + * @param {Array} e1 + * @param {Array} e2 + * @returns {external:Polynomial} */ @@ -3763,15 +3765,15 @@ /** * IntersectionArgs - * + * @memberof module:kld-intersections */ var IntersectionArgs = /*#__PURE__*/ function () { /** * @param {string} name - * @param {Array} args - * @returns {IntersectionArgs} + * @param {Array} args + * @returns {module:kld-intersections.IntersectionArgs} */ function IntersectionArgs(name, args) { _classCallCheck(this, IntersectionArgs); @@ -3782,7 +3784,7 @@ * init * * @param {string} name - * @param {Array} args + * @param {Array} args */ @@ -3801,7 +3803,12 @@ * Shapes * * @copyright 2017, Kevin Lindsey + * @module Shapes + */ + /** + * @namespace */ + var Shapes = {}; /** * quadraticBezier @@ -3812,7 +3819,7 @@ * @param {number} p2y * @param {number} p3x * @param {number} p3y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.quadraticBezier = function (p1x, p1y, p2x, p2y, p3x, p3y) { @@ -3829,7 +3836,7 @@ * @param {number} p3y * @param {number} p4x * @param {number} p4y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3842,7 +3849,7 @@ * @param {number} centerX * @param {number} centerY * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3856,7 +3863,7 @@ * @param {number} centerY * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3870,7 +3877,7 @@ * @param {number} p1y * @param {number} p2x * @param {number} p2y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3880,8 +3887,8 @@ /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3892,7 +3899,7 @@ * polygon * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3909,7 +3916,7 @@ * polyline * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3929,7 +3936,7 @@ * @param {number} y * @param {number} width * @param {number} height - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3941,15 +3948,19 @@ * AffineShapes * * @copyright 2017, Kevin Lindsey + * @module AffineShapes + */ + /** + * @namespace */ + var AffineShapes = {}; /** * quadraticBezier - * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.quadraticBezier = function (p1, p2, p3) { @@ -3958,11 +3969,11 @@ /** * cubicBezier * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3972,9 +3983,9 @@ /** * circle * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3984,10 +3995,10 @@ /** * ellipse * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -3997,9 +4008,9 @@ /** * line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4009,8 +4020,8 @@ /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4020,8 +4031,8 @@ /** * polygon * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4031,8 +4042,8 @@ /** * polyline * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4042,9 +4053,9 @@ /** * rectangle * - * @param {Point2D} topLeft - * @param {Vector2D} size - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Vector2D} size + * @returns {module:kld-intersections.IntersectionArgs} */ @@ -4057,18 +4068,18 @@ * IntersectionQuery.js * * @copyright 2017 Kevin Lindsey - * + * @module IntersectionQuery */ /** - * + * @namespace */ var IntersectionQuery = {}; /** * pointInCircle * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radius * @returns {boolean} */ @@ -4080,8 +4091,8 @@ /** * pointInEllipse * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY * @returns {boolean} @@ -4095,8 +4106,8 @@ /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ @@ -4128,8 +4139,8 @@ /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ @@ -4137,9 +4148,9 @@ /** * pointInRectangle * - * @param {Point2D} point - * @param {Point2D} topLeft - * @param {Point2D} bottomRight + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Point2D} bottomRight * @returns {boolean} */ @@ -4147,7 +4158,12 @@ return topLeft.x <= point.x && point.x < bottomRight.x && topLeft.y <= point.y && point.y < bottomRight.y; }; - // expose module classes + /** + * @module kld-intersections + */ + /** + * @external Polynomial + */ exports.AffineShapes = AffineShapes; exports.Intersection = Intersection; diff --git a/dist/index-umd.min.js.map b/dist/index-umd.min.js.map index b4a1187..4d17216 100644 --- a/dist/index-umd.min.js.map +++ b/dist/index-umd.min.js.map @@ -1 +1 @@ -{"version":3,"file":"index-umd.min.js","sources":["../node_modules/kld-affine/lib/Point2D.js","../node_modules/kld-affine/lib/Vector2D.js","../node_modules/kld-affine/lib/Matrix2D.js","../node_modules/kld-affine/index.js","../node_modules/kld-polynomial/lib/Polynomial.js","../node_modules/kld-polynomial/lib/SqrtPolynomial.js","../node_modules/kld-polynomial/index.js","../lib/Intersection.js","../lib/IntersectionArgs.js","../lib/Shapes.js","../lib/AffineShapes.js","../lib/IntersectionQuery.js"],"sourcesContent":["/**\n *\n * Point2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Point2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Point2D}\n */\nfunction Point2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * clone\n *\n * @returns {Point2D}\n */\nPoint2D.prototype.clone = function() {\n return new this.constructor(this.x, this.y);\n};\n\n/**\n * add\n *\n * @param {Point2D|Vector2D} that\n * @returns {Point2D}\n */\nPoint2D.prototype.add = function(that) {\n return new this.constructor(this.x+that.x, this.y+that.y);\n};\n\n/**\n * subtract\n *\n * @param { Vector2D | Point2D } that\n * @returns {Point2D}\n */\nPoint2D.prototype.subtract = function(that) {\n return new this.constructor(this.x-that.x, this.y-that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x*scalar, this.y*scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x/scalar, this.y/scalar);\n};\n\n/**\n * equals\n *\n * @param {Point2D} that\n * @returns {Boolean}\n */\nPoint2D.prototype.equals = function(that) {\n return ( this.x === that.x && this.y === that.y );\n};\n\n/**\n * precisionEquals\n *\n * @param {Point2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nPoint2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n// utility methods\n\n/**\n * lerp\n *\n * @param { Vector2D | Point2D } that\n * @param {Number} t\n @ @returns {Point2D}\n */\nPoint2D.prototype.lerp = function(that, t) {\n var omt = 1.0 - t;\n\n return new this.constructor(\n this.x * omt + that.x * t,\n this.y * omt + that.y * t\n );\n};\n\n/**\n * distanceFrom\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.distanceFrom = function(that) {\n var dx = this.x - that.x;\n var dy = this.y - that.y;\n\n return Math.sqrt(dx*dx + dy*dy);\n};\n\n/**\n * min\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.min = function(that) {\n return new this.constructor(\n Math.min( this.x, that.x ),\n Math.min( this.y, that.y )\n );\n};\n\n/**\n * max\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.max = function(that) {\n return new this.constructor(\n Math.max( this.x, that.x ),\n Math.max( this.y, that.y )\n );\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @result {Point2D}\n */\nPoint2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y + matrix.e,\n matrix.b * this.x + matrix.d * this.y + matrix.f\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nPoint2D.prototype.toString = function() {\n return \"point(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Point2D;\n}\n","/**\n *\n * Vector2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Vector2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Vector2D}\n */\nfunction Vector2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * fromPoints\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {Vector2D}\n */\nVector2D.fromPoints = function(p1, p2) {\n return new Vector2D(\n p2.x - p1.x,\n p2.y - p1.y\n );\n};\n\n/**\n * length\n *\n * @returns {Number}\n */\nVector2D.prototype.length = function() {\n return Math.sqrt(this.x*this.x + this.y*this.y);\n};\n\n/**\n * magnitude\n *\n * @returns {Number}\n */\nVector2D.prototype.magnitude = function() {\n return this.x*this.x + this.y*this.y;\n};\n\n/**\n * dot\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.dot = function(that) {\n return this.x*that.x + this.y*that.y;\n};\n\n/**\n * cross\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.cross = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * determinant\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.determinant = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * unit\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.unit = function() {\n return this.divide( this.length() );\n};\n\n/**\n * add\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.add = function(that) {\n return new this.constructor(this.x + that.x, this.y + that.y);\n};\n\n/**\n * subtract\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.subtract = function(that) {\n return new this.constructor(this.x - that.x, this.y - that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x * scalar, this.y * scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x / scalar, this.y / scalar);\n};\n\n/**\n * angleBetween\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.angleBetween = function(that) {\n var cos = this.dot(that) / (this.length() * that.length());\n cos = Math.max(-1, Math.min(cos, 1));\n var radians = Math.acos(cos);\n\n return (this.cross(that) < 0.0) ? -radians : radians;\n};\n\n/**\n * Find a vector is that is perpendicular to this vector\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.perp = function() {\n return new this.constructor(-this.y, this.x);\n};\n\n/**\n * Find the component of the specified vector that is perpendicular to\n * this vector\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.perpendicular = function(that) {\n return this.subtract(this.project(that));\n};\n\n/**\n * project\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.project = function(that) {\n var percent = this.dot(that) / that.dot(that);\n\n return that.multiply(percent);\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @returns {Vector2D}\n */\nVector2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y,\n matrix.b * this.x + matrix.d * this.y\n );\n};\n\n/**\n * equals\n *\n * @param {Vector2D} that\n * @returns {Boolean}\n */\nVector2D.prototype.equals = function(that) {\n return (\n this.x === that.x &&\n this.y === that.y\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Vector2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nVector2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nVector2D.prototype.toString = function() {\n return \"vector(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Vector2D;\n}\n","/**\n * Matrix2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n */\n\nfunction setReadonlyProperty(object, property, value) {\n Object.defineProperty(object, property, {\n value: value,\n writable: false,\n enumerable: true,\n configurable: false\n });\n}\n\n/**\n * Identity matrix\n *\n * @returns {Matrix2D}\n */\nsetReadonlyProperty(Matrix2D, \"IDENTITY\", new Matrix2D(1, 0, 0, 1, 0, 0));\nsetReadonlyProperty(Matrix2D.IDENTITY, \"isIdentity\", function () { return true; });\n\n\n/**\n * Matrix2D\n *\n * [a c e]\n * [b d f]\n * [0 0 1]\n *\n * @param {Number} a\n * @param {Number} b\n * @param {Number} c\n * @param {Number} d\n * @param {Number} e\n * @param {Number} f\n * @returns {Matrix2D}\n */\nfunction Matrix2D(a, b, c, d, e, f) {\n setReadonlyProperty(this, \"a\", (a !== undefined) ? a : 1);\n setReadonlyProperty(this, \"b\", (b !== undefined) ? b : 0);\n setReadonlyProperty(this, \"c\", (c !== undefined) ? c : 0);\n setReadonlyProperty(this, \"d\", (d !== undefined) ? d : 1);\n setReadonlyProperty(this, \"e\", (e !== undefined) ? e : 0);\n setReadonlyProperty(this, \"f\", (f !== undefined) ? f : 0);\n}\n\n\n// *** STATIC METHODS\n\n/**\n * translation\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.translation = function(tx, ty) {\n return new Matrix2D(1, 0, 0, 1, tx, ty);\n};\n\n/**\n * scaling\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.scaling = function(scale) {\n return new Matrix2D(scale, 0, 0, scale, 0, 0);\n};\n\n/**\n * scalingAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.scalingAt = function(scale, center) {\n return new Matrix2D(\n scale,\n 0,\n 0,\n scale,\n center.x - center.x * scale,\n center.y - center.y * scale\n );\n}\n\n\n/**\n * nonUniformScaling\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScaling = function(scaleX, scaleY) {\n return new Matrix2D(scaleX, 0, 0, scaleY, 0, 0);\n};\n\n/**\n * nonUniformScalingAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScalingAt = function(scaleX, scaleY, center) {\n return new Matrix2D(\n scaleX,\n 0,\n 0,\n scaleY,\n center.x - center.x * scaleX,\n center.y - center.y * scaleY\n );\n};\n\n/**\n * rotation\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.rotation = function(radians) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * rotationAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.rotationAt = function(radians, center) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(\n c,\n s,\n -s,\n c,\n center.x - center.x * c + center.y * s,\n center.y - center.y * c - center.x * s\n );\n};\n\n/**\n * rotationFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.rotationFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * xFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.xFlip = function() {\n return new Matrix2D(-1, 0, 0, 1, 0, 0);\n};\n\n/**\n * yFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.yFlip = function() {\n return new Matrix2D(1, 0, 0, -1, 0, 0);\n};\n\n/**\n * xSkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.xSkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, 0, t, 1, 0, 0);\n};\n\n/**\n * ySkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.ySkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, t, 0, 1, 0, 0);\n};\n\n\n// *** METHODS\n\n/**\n * multiply\n *\n * @pararm {Matrix2D} that\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.multiply = function (that) {\n if (this.isIdentity()) {\n return that;\n }\n\n if (that.isIdentity()) {\n return this;\n }\n\n return new this.constructor(\n this.a * that.a + this.c * that.b,\n this.b * that.a + this.d * that.b,\n this.a * that.c + this.c * that.d,\n this.b * that.c + this.d * that.d,\n this.a * that.e + this.c * that.f + this.e,\n this.b * that.e + this.d * that.f + this.f\n );\n};\n\n/**\n * inverse\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.inverse = function () {\n if (this.isIdentity()) {\n return this;\n }\n\n var det1 = this.a * this.d - this.b * this.c;\n\n if ( det1 === 0.0 ) {\n throw(\"Matrix is not invertible\");\n }\n\n var idet = 1.0 / det1;\n var det2 = this.f * this.c - this.e * this.d;\n var det3 = this.e * this.b - this.f * this.a;\n\n return new this.constructor(\n this.d * idet,\n -this.b * idet,\n -this.c * idet,\n this.a * idet,\n det2 * idet,\n det3 * idet\n );\n};\n\n/**\n * translate\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.translate = function(tx, ty) {\n return new this.constructor(\n this.a,\n this.b,\n this.c,\n this.d,\n this.a * tx + this.c * ty + this.e,\n this.b * tx + this.d * ty + this.f\n );\n};\n\n/**\n * scale\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scale = function(scale) {\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleAt = function(scale, center) {\n var dx = center.x - scale * center.x;\n var dy = center.y - scale * center.y;\n\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * scaleNonUniform\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniform = function(scaleX, scaleY) {\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleNonUniformAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniformAt = function(scaleX, scaleY, center) {\n var dx = center.x - scaleX * center.x;\n var dy = center.y - scaleY * center.y;\n\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * rotate\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotate = function(radians) {\n var c = Math.cos(radians);\n var s = Math.sin(radians);\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * rotateAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @result {Matrix2D}\n */\nMatrix2D.prototype.rotateAt = function(radians, center) {\n var cos = Math.cos(radians);\n var sin = Math.sin(radians);\n var cx = center.x;\n var cy = center.y;\n\n var a = this.a * cos + this.c * sin;\n var b = this.b * cos + this.d * sin;\n var c = this.c * cos - this.a * sin;\n var d = this.d * cos - this.b * sin;\n\n return new this.constructor(\n a,\n b,\n c,\n d,\n (this.a - a) * cx + (this.c - c) * cy + this.e,\n (this.b - b) * cx + (this.d - d) * cy + this.f\n );\n};\n\n/**\n * rotateFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotateFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * flipX\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipX = function() {\n return new this.constructor(\n -this.a,\n -this.b,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * flipY\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipY = function() {\n return new this.constructor(\n this.a,\n this.b,\n -this.c,\n -this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * skewX\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewX = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a,\n this.b,\n this.c + this.a * t,\n this.d + this.b * t,\n this.e,\n this.f\n );\n};\n\n// TODO: skewXAt\n\n/**\n * skewY\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewY = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a + this.c * t,\n this.b + this.d * t,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n// TODO: skewYAt\n\n/**\n * isIdentity\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isIdentity = function() {\n return (\n this.a === 1.0 &&\n this.b === 0.0 &&\n this.c === 0.0 &&\n this.d === 1.0 &&\n this.e === 0.0 &&\n this.f === 0.0\n );\n};\n\n/**\n * isInvertible\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isInvertible = function() {\n return this.a * this.d - this.b * this.c !== 0.0;\n};\n\n/**\n * getScale\n *\n * @returns {{ scaleX: Number, scaleY: Number }}\n */\nMatrix2D.prototype.getScale = function() {\n return {\n scaleX: Math.sqrt(this.a * this.a + this.c * this.c),\n scaleY: Math.sqrt(this.b * this.b + this.d * this.d)\n };\n};\n\n/**\n * getDecomposition\n *\n * Calculates matrix Singular Value Decomposition\n *\n * The resulting matrices, translation, rotation, scale, and rotation0, return\n * this matrix when they are muliplied together in the listed order\n *\n * @see Jim Blinn's article {@link http://dx.doi.org/10.1109/38.486688}\n * @see {@link http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation}\n *\n * @returns {{ translation: Matrix2D, rotation: Matrix2D, scale: Matrix2D, rotation0: Matrix2D }}\n */\nMatrix2D.prototype.getDecomposition = function () {\n var E = (this.a + this.d) * 0.5;\n var F = (this.a - this.d) * 0.5;\n var G = (this.b + this.c) * 0.5;\n var H = (this.b - this.c) * 0.5;\n\n var Q = Math.sqrt(E * E + H * H);\n var R = Math.sqrt(F * F + G * G);\n var scaleX = Q + R;\n var scaleY = Q - R;\n\n var a1 = Math.atan2(G, F);\n var a2 = Math.atan2(H, E);\n var theta = (a2 - a1) * 0.5;\n var phi = (a2 + a1) * 0.5;\n\n // TODO: Add static methods to generate translation, rotation, etc.\n // matrices directly\n\n return {\n translation: new this.constructor(1, 0, 0, 1, this.e, this.f),\n rotation: this.constructor.IDENTITY.rotate(phi),\n scale: new this.constructor(scaleX, 0, 0, scaleY, 0, 0),\n rotation0: this.constructor.IDENTITY.rotate(theta)\n };\n};\n\n/**\n * equals\n *\n * @param {Matrix2D} that\n * @returns {Boolean}\n */\nMatrix2D.prototype.equals = function(that) {\n return (\n this.a === that.a &&\n this.b === that.b &&\n this.c === that.c &&\n this.d === that.d &&\n this.e === that.e &&\n this.f === that.f\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Matrix2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nMatrix2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.a - that.a) < precision &&\n Math.abs(this.b - that.b) < precision &&\n Math.abs(this.c - that.c) < precision &&\n Math.abs(this.d - that.d) < precision &&\n Math.abs(this.e - that.e) < precision &&\n Math.abs(this.f - that.f) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nMatrix2D.prototype.toString = function() {\n return \"matrix(\" + [this.a, this.b, this.c, this.d, this.e, this.f].join(\",\") + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Matrix2D;\n}\n","// expose classes\n\nexports.Point2D = require('./lib/Point2D');\nexports.Vector2D = require('./lib/Vector2D');\nexports.Matrix2D = require('./lib/Matrix2D');\n","/**\n *\n * Polynomial.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n * \n * contribution {@link http://github.com/Quazistax/kld-polynomial}\n * @copyright 2015 Robert Benko (Quazistax) \n * @license MIT\n */\n\nPolynomial.TOLERANCE = 1e-6;\nPolynomial.ACCURACY = 15;\n\n\n/**\n * interpolate\n *\n * Based on poloint in \"Numerical Recipes in C, 2nd Edition\", pages 109-110\n *\n * @param {Array} xs\n * @param {Array} ys\n * @param {Number} n\n * @param {Number} offset\n * @param {Number} x\n *\n * @returns {{y: Number, dy: Number}}\n */\nPolynomial.interpolate = function(xs, ys, n, offset, x) {\n if ( xs.constructor !== Array || ys.constructor !== Array ) {\n throw new Error(\"Polynomial.interpolate: xs and ys must be arrays\");\n }\n if ( isNaN(n) || isNaN(offset) || isNaN(x) ) {\n throw new Error(\"Polynomial.interpolate: n, offset, and x must be numbers\");\n }\n\n var y = 0;\n var dy = 0;\n var c = new Array(n);\n var d = new Array(n);\n var ns = 0;\n\n var diff = Math.abs(x - xs[offset]);\n\n for ( var i = 0; i < n; i++ ) {\n var dift = Math.abs(x - xs[offset+i]);\n\n if ( dift < diff ) {\n ns = i;\n diff = dift;\n }\n c[i] = d[i] = ys[offset+i];\n }\n\n y = ys[offset+ns];\n ns--;\n\n for ( var m = 1; m < n; m++ ) {\n for ( var i = 0; i < n-m; i++ ) {\n var ho = xs[offset+i] - x;\n var hp = xs[offset+i+m] - x;\n var w = c[i+1]-d[i];\n var den = ho - hp;\n\n if ( den == 0.0 ) {\n throw new Error(\"Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)\");\n }\n\n den = w / den;\n d[i] = hp*den;\n c[i] = ho*den;\n }\n\n dy = (2*(ns+1) < (n-m)) ? c[ns+1] : d[ns--];\n y += dy;\n }\n\n return { y: y, dy: dy };\n};\n\n\n/**\n * Polynomial\n *\n * @returns {Polynomial}\n */\nfunction Polynomial() {\n this.init( arguments );\n}\n\n\n/**\n * init\n */\nPolynomial.prototype.init = function(coefs) {\n this.coefs = new Array();\n\n for ( var i = coefs.length - 1; i >= 0; i-- )\n this.coefs.push( coefs[i] );\n\n this._variable = \"t\";\n this._s = 0;\n};\n\n\n/**\n * eval\n */\nPolynomial.prototype.eval = function(x) {\n if ( isNaN(x) ) {\n throw new Error(\"Polynomial.eval: parameter must be a number\");\n }\n\n var result = 0;\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n result = result * x + this.coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * add\n */\nPolynomial.prototype.add = function(that) {\n var result = new Polynomial();\n var d1 = this.getDegree();\n var d2 = that.getDegree();\n var dmax = Math.max(d1,d2);\n\n for ( var i = 0; i <= dmax; i++ ) {\n var v1 = (i <= d1) ? this.coefs[i] : 0;\n var v2 = (i <= d2) ? that.coefs[i] : 0;\n\n result.coefs[i] = v1 + v2;\n }\n\n return result;\n};\n\n\n/**\n * multiply\n */\nPolynomial.prototype.multiply = function(that) {\n var result = new Polynomial();\n\n for ( var i = 0; i <= this.getDegree() + that.getDegree(); i++ ) {\n result.coefs.push(0);\n }\n\n for ( var i = 0; i <= this.getDegree(); i++ ) {\n for ( var j = 0; j <= that.getDegree(); j++ ) {\n result.coefs[i+j] += this.coefs[i] * that.coefs[j];\n }\n }\n\n return result;\n};\n\n\n/**\n * divide_scalar\n */\nPolynomial.prototype.divide_scalar = function(scalar) {\n for ( var i = 0; i < this.coefs.length; i++ ) {\n this.coefs[i] /= scalar;\n }\n};\n\n\n/**\n * simplify\n */\nPolynomial.prototype.simplify = function(TOLERANCE) {\n if (TOLERANCE === undefined) TOLERANCE = 1e-12;\n\n for ( var i = this.getDegree(); i >= 0; i-- ) {\n if ( Math.abs( this.coefs[i] ) <= TOLERANCE ) {\n this.coefs.pop();\n }\n else {\n break;\n }\n }\n};\n\n\n/**\n * bisection\n */\nPolynomial.prototype.bisection = function(min, max) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n var result;\n\n if ( Math.abs(minValue) <= Polynomial.TOLERANCE ) {\n result = min;\n }\n else if ( Math.abs(maxValue) <= Polynomial.TOLERANCE ) {\n result = max;\n }\n else if ( minValue * maxValue <= 0 ) {\n var tmp1 = Math.log(max - min);\n var tmp2 = Math.LN10 * Polynomial.ACCURACY;\n var iters = Math.ceil( (tmp1+tmp2) / Math.LN2 );\n\n for ( var i = 0; i < iters; i++ ) {\n result = 0.5 * (min + max);\n var value = this.eval(result);\n\n if ( Math.abs(value) <= Polynomial.TOLERANCE ) {\n break;\n }\n\n if ( value * minValue < 0 ) {\n max = result;\n maxValue = value;\n }\n else {\n min = result;\n minValue = value;\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * toString\n */\nPolynomial.prototype.toString = function() {\n var coefs = new Array();\n var signs = new Array();\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n var value = Math.round(this.coefs[i]*1000)/1000;\n //var value = this.coefs[i];\n\n if ( value != 0 ) {\n var sign = ( value < 0 ) ? \" - \" : \" + \";\n\n value = Math.abs(value);\n\n if ( i > 0 ) {\n if ( value == 1 ) {\n value = this._variable;\n }\n else {\n value += this._variable;\n }\n }\n\n if ( i > 1 ) {\n value += \"^\" + i;\n }\n\n signs.push( sign );\n coefs.push( value );\n }\n }\n\n signs[0] = ( signs[0] == \" + \" ) ? \"\" : \"-\";\n\n var result = \"\";\n\n for ( var i = 0; i < coefs.length; i++ ) {\n result += signs[i] + coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * trapezoid\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 137\n */\nPolynomial.prototype.trapezoid = function(min, max, n) {\n if ( isNaN(min) || isNaN(max) || isNaN(n) ) {\n throw new Error(\"Polynomial.trapezoid: parameters must be numbers\");\n }\n\n var range = max - min;\n var TOLERANCE = 1e-7;\n\n if ( n == 1 ) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n\n this._s = 0.5*range*( minValue + maxValue );\n }\n else {\n var it = 1 << (n-2);\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 0; i < it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n this._s = 0.5*(this._s + range*sum/it);\n }\n\n if ( isNaN(this._s) ) {\n throw new Error(\"Polynomial.trapezoid: this._s is NaN\");\n }\n\n return this._s;\n};\n\n\n/**\n * simpson\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 139\n */\nPolynomial.prototype.simpson = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.simpson: parameters must be numbers\");\n }\n\n var range = max - min;\n var st = 0.5 * range * ( this.eval(min) + this.eval(max) );\n var t = st;\n var s = 4.0*st/3.0;\n var os = s;\n var ost = st;\n var TOLERANCE = 1e-7;\n\n var it = 1;\n\n for ( var n = 2; n <= 20; n++ ) {\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 1; i <= it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n t = 0.5 * (t + range * sum / it);\n st = t;\n s = (4.0*st - ost)/3.0;\n\n if ( Math.abs(s-os) < TOLERANCE*Math.abs(os) ) {\n break;\n }\n\n os = s;\n ost = st;\n it <<= 1;\n }\n\n return s;\n};\n\n\n/**\n * romberg\n */\nPolynomial.prototype.romberg = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.romberg: parameters must be numbers\");\n }\n\n var MAX = 20;\n var K = 3;\n var TOLERANCE = 1e-6;\n var s = new Array(MAX+1);\n var h = new Array(MAX+1);\n var result = { y: 0, dy: 0 };\n\n h[0] = 1.0;\n\n for ( var j = 1; j <= MAX; j++ ) {\n s[j-1] = this.trapezoid(min, max, j);\n\n if ( j >= K ) {\n result = Polynomial.interpolate(h, s, K, j-K, 0.0);\n if ( Math.abs(result.dy) <= TOLERANCE*result.y) break;\n }\n\n s[j] = s[j-1];\n h[j] = 0.25 * h[j-1];\n }\n\n return result.y;\n};\n\n// getters and setters\n\n/**\n * get degree\n */\nPolynomial.prototype.getDegree = function() {\n return this.coefs.length - 1;\n};\n\n\n/**\n * getDerivative\n */\nPolynomial.prototype.getDerivative = function() {\n var derivative = new Polynomial();\n\n for ( var i = 1; i < this.coefs.length; i++ ) {\n derivative.coefs.push(i*this.coefs[i]);\n }\n\n return derivative;\n};\n\n\n/**\n * getRoots\n */\nPolynomial.prototype.getRoots = function() {\n var result;\n\n this.simplify();\n\n switch ( this.getDegree() ) {\n case 0: result = []; break;\n case 1: result = this.getLinearRoot(); break;\n case 2: result = this.getQuadraticRoots(); break;\n case 3: result = this.getCubicRoots(); break;\n case 4: result = this.getQuarticRoots(); break;\n default:\n result = [];\n }\n\n return result;\n};\n\n\n/**\n * getRootsInInterval\n */\nPolynomial.prototype.getRootsInInterval = function(min, max) {\n var roots = new Array();\n var root;\n\n if ( this.getDegree() == 1 ) {\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // get roots of derivative\n var deriv = this.getDerivative();\n var droots = deriv.getRootsInInterval(min, max);\n\n if ( droots.length > 0 ) {\n // find root on [min, droots[0]]\n root = this.bisection(min, droots[0]);\n\n if ( root != null ) {\n roots.push(root);\n }\n\n // find root on [droots[i],droots[i+1]] for 0 <= i <= count-2\n for ( i = 0; i <= droots.length-2; i++ ) {\n root = this.bisection(droots[i], droots[i+1]);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n\n // find root on [droots[count-1],xmax]\n root = this.bisection(droots[droots.length-1], max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // polynomial is monotone on [min,max], has at most one root\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n }\n\n return roots;\n};\n\n\n/**\n * getLinearRoot\n */\nPolynomial.prototype.getLinearRoot = function() {\n var result = [];\n var a = this.coefs[1];\n\n if ( a != 0 ) {\n result.push( -this.coefs[0] / a );\n }\n\n return result;\n};\n\n\n/**\n * getQuadraticRoots\n */\nPolynomial.prototype.getQuadraticRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 2 ) {\n var a = this.coefs[2];\n var b = this.coefs[1] / a;\n var c = this.coefs[0] / a;\n var d = b*b - 4*c;\n\n if ( d > 0 ) {\n var e = Math.sqrt(d);\n\n results.push( 0.5 * (-b + e) );\n results.push( 0.5 * (-b - e) );\n }\n else if ( d == 0 ) {\n // really two roots with same value, but we only return one\n results.push( 0.5 * -b );\n }\n }\n\n return results;\n};\n\n\n/**\n * getCubicRoots\n *\n * This code is based on MgcPolynomial.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.geometrictools.com\n */\nPolynomial.prototype.getCubicRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 3 ) {\n var c3 = this.coefs[3];\n var c2 = this.coefs[2] / c3;\n var c1 = this.coefs[1] / c3;\n var c0 = this.coefs[0] / c3;\n\n var a = (3*c1 - c2*c2) / 3;\n var b = (2*c2*c2*c2 - 9*c1*c2 + 27*c0) / 27;\n var offset = c2 / 3;\n var discrim = b*b/4 + a*a*a/27;\n var halfB = b / 2;\n\n var ZEROepsilon = this.zeroErrorEstimate();\n if (Math.abs(discrim) <= ZEROepsilon) {\n discrim = 0;\n }\n\n if ( discrim > 0 ) {\n var e = Math.sqrt(discrim);\n var tmp;\n var root;\n\n tmp = -halfB + e;\n\n if ( tmp >= 0 ) {\n root = Math.pow(tmp, 1/3);\n }\n else {\n root = -Math.pow(-tmp, 1/3);\n }\n\n tmp = -halfB - e;\n\n if ( tmp >= 0 ) {\n root += Math.pow(tmp, 1/3);\n }\n else {\n root -= Math.pow(-tmp, 1/3);\n }\n\n results.push( root - offset );\n }\n else if ( discrim < 0 ) {\n var distance = Math.sqrt(-a/3);\n var angle = Math.atan2( Math.sqrt(-discrim), -halfB) / 3;\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n var sqrt3 = Math.sqrt(3);\n\n results.push( 2*distance*cos - offset );\n results.push( -distance * (cos + sqrt3 * sin) - offset);\n results.push( -distance * (cos - sqrt3 * sin) - offset);\n }\n else {\n var tmp;\n\n if ( halfB >= 0 ) {\n tmp = -Math.pow(halfB, 1/3);\n }\n else {\n tmp = Math.pow(-halfB, 1/3);\n }\n\n results.push( 2*tmp - offset );\n // really should return next root twice, but we return only one\n results.push( -tmp - offset );\n }\n }\n\n return results;\n};\n\n\n/**\n * Sign of a number (+1, -1, +0, -0).\n */\nvar sign = function (x) {\n return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? x : NaN : NaN;\n};\n\n\n/**\n * Calculates roots of quartic polynomial.
\n * First, derivative roots are found, then used to split quartic polynomial \n * into segments, each containing one root of quartic polynomial.\n * Segments are then passed to newton's method to find roots.\n *\n * @returns {Array} roots\n */\nPolynomial.prototype.getQuarticRoots = function () {\n var results = [];\n\n var n = this.getDegree();\n\n if (n == 4) {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice();\n poly.divide_scalar(poly.coefs[n]);\n\n var ERRF = 1e-15;\n\n if (Math.abs(poly.coefs[0]) < 10 * ERRF * Math.abs(poly.coefs[3])) {\n poly.coefs[0] = 0;\n }\n\n var poly_d = poly.getDerivative();\n var derrt = poly_d.getRoots().sort(function (a, b) { return a - b; });\n var dery = [];\n var nr = derrt.length - 1;\n var i;\n var rb = this.bounds();\n\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n\n var ZEROepsilon = this.zeroErrorEstimate(maxabsX);\n \n for (i = 0; i <= nr; i++) {\n dery.push(poly.eval(derrt[i]));\n }\n\n for (i = 0; i <= nr; i++) {\n if (Math.abs(dery[i]) < ZEROepsilon) {\n dery[i] = 0;\n }\n }\n\n i = 0;\n var dx = Math.max(0.1 * (rb.maxX - rb.minX) / n, ERRF);\n var guesses = [];\n var minmax = [];\n\n if (nr > -1) {\n if (dery[0] != 0) {\n if (sign(dery[0]) != sign(poly.eval(derrt[0] - dx) - dery[0])) {\n guesses.push(derrt[0] - dx);\n minmax.push([rb.minX, derrt[0]]);\n }\n }\n else {\n results.push(derrt[0], derrt[0]);\n i++;\n }\n\n for (; i < nr; i++) {\n if (dery[i + 1] == 0) {\n results.push(derrt[i + 1], derrt[i + 1]);\n i++;\n }\n else if (sign(dery[i]) != sign(dery[i + 1])) {\n guesses.push((derrt[i] + derrt[i + 1]) / 2);\n minmax.push([derrt[i], derrt[i + 1]]);\n }\n }\n if (dery[nr] != 0 && sign(dery[nr]) != sign(poly.eval(derrt[nr] + dx) - dery[nr])) {\n guesses.push(derrt[nr] + dx);\n minmax.push([derrt[nr], rb.maxX]);\n }\n }\n\n var f = function (x) { return poly.eval(x); };\n var df = function (x) { return poly_d.eval(x); };\n\n if (guesses.length > 0) {\n for (i = 0; i < guesses.length; i++) {\n guesses[i] = Polynomial.newton_secant_bisection(guesses[i], f, df, 32, minmax[i][0], minmax[i][1]);\n }\n }\n\n results = results.concat(guesses);\n }\n\n return results;\n};\n\n\n/**\n * Estimate what is the maximum polynomial evaluation error value under which polynomial evaluation could be in fact 0.\n * \n * @returns {Number} \n */\nPolynomial.prototype.zeroErrorEstimate = function (maxabsX) {\n var poly = this;\n var ERRF = 1e-15;\n\n if (typeof maxabsX === 'undefined') {\n var rb = poly.bounds();\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n }\n\n if (maxabsX < 0.001) {\n return 2*Math.abs(poly.eval(ERRF));\n }\n\n var n = poly.coefs.length - 1;\n var an = poly.coefs[n];\n\n return 10 * ERRF * poly.coefs.reduce(function (m, v, i) {\n var nm = v / an * Math.pow(maxabsX, i);\n return nm > m ? nm : m;\n }, 0);\n}\n\n\n/**\n * Calculates upper Real roots bounds.
\n * Real roots are in interval [negX, posX]. Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_UpperReal_Fujiwara = function () {\n var a = this.coefs;\n var n = a.length - 1;\n var an = a[n];\n\n if (an != 1) {\n a = this.coefs.map(function (v) {\n return v / an;\n });\n }\n\n var b = a.map(function (v, i) {\n return (i < n)\n ? Math.pow(Math.abs((i == 0) ? v / 2 : v), 1 / (n - i))\n : v;\n });\n\n var coefSelectionFunc;\n var find2Max = function (acc, bi, i) {\n if (coefSelectionFunc(i)) {\n if (acc.max < bi) {\n acc.nearmax = acc.max;\n acc.max = bi;\n }\n else if (acc.nearmax < bi) {\n acc.nearmax = bi;\n }\n }\n return acc;\n };\n\n coefSelectionFunc = function (i) { return i < n && a[i] < 0; };\n var max_nearmax_pos = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n coefSelectionFunc = function (i) { return i < n && ((n % 2 == i % 2) ? a[i] < 0 : a[i] > 0); };\n var max_nearmax_neg = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n return {\n negX: -2 * max_nearmax_neg.max,\n posX: 2 * max_nearmax_pos.max\n };\n};\n\n\n/** \n * Calculates lower Real roots bounds.
\n * There are no Real roots in interval . Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_LowerReal_Fujiwara = function () {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice().reverse();\n\n var res = poly.bounds_UpperReal_Fujiwara();\n\n res.negX = 1 / res.negX;\n res.posX = 1 / res.posX;\n\n return res;\n};\n\n\n/** \n * Calculates left and right Real roots bounds.
\n * Real roots are in interval [minX, maxX]. Combines Fujiwara lower and upper bounds to get minimal interval.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ minX: Number, maxX: Number }}\n*/\nPolynomial.prototype.bounds = function () {\n var urb = this.bounds_UpperReal_Fujiwara();\n var rb = { minX: urb.negX, maxX: urb.posX };\n\n if (urb.negX === 0 && urb.posX === 0) {\n return rb;\n }\n\n if (urb.negX === 0) {\n rb.minX = this.bounds_LowerReal_Fujiwara().posX;\n }\n else if (urb.posX === 0) {\n rb.maxX = this.bounds_LowerReal_Fujiwara().negX;\n }\n\n if (rb.minX > rb.maxX) {\n //console.log('Polynomial.prototype.bounds: poly has no real roots? or floating point error?');\n rb.minX = rb.maxX = 0;\n }\n\n return rb;\n // TODO: if sure that there are no complex roots \n // (maybe by using Sturm's theorem) use:\n // return this.bounds_Real_Laguerre();\n};\n\n\n/**\n * Newton's (Newton-Raphson) method for finding Real roots on univariate function.
\n * When using bounds, algorithm falls back to secant if newton goes out of range.\n * Bisection is fallback for secant when determined secant is not efficient enough.\n * @see {@link http://en.wikipedia.org/wiki/Newton%27s_method}\n * @see {@link http://en.wikipedia.org/wiki/Secant_method}\n * @see {@link http://en.wikipedia.org/wiki/Bisection_method}\n *\n * @param {Number} x0 - Inital root guess\n * @param {function(x)} f - Function which root we are trying to find\n * @param {function(x)} df - Derivative of function f\n * @param {Number} max_iterations - Maximum number of algorithm iterations\n * @param {Number} [min_x] - Left bound value\n * @param {Number} [max_x] - Right bound value\n * @returns {Number} - root\n */\nPolynomial.newton_secant_bisection = function (x0, f, df, max_iterations, min, max) {\n var x, prev_dfx = 0, dfx, prev_x_ef_correction = 0, x_correction, x_new;\n var v, y_atmin, y_atmax;\n\n x = x0;\n\n var ACCURACY = 14;\n var min_correction_factor = Math.pow(10, -ACCURACY);\n var isBounded = (typeof min === 'number' && typeof max === 'number');\n\n if (isBounded) {\n if (min > max) {\n throw new Error(\"newton root finding: min must be greater than max\");\n }\n\n y_atmin = f(min);\n y_atmax = f(max);\n\n if (sign(y_atmin) == sign(y_atmax)) {\n throw new Error(\"newton root finding: y values of bounds must be of opposite sign\");\n }\n }\n\n var isEnoughCorrection = function () {\n // stop if correction is too small or if correction is in simple loop\n return (Math.abs(x_correction) <= min_correction_factor * Math.abs(x))\n || (prev_x_ef_correction == (x - x_correction) - x);\n };\n\n var i;\n\n for (i = 0; i < max_iterations; i++) {\n dfx = df(x);\n\n if (dfx == 0) {\n if (prev_dfx == 0) {\n // error\n throw new Error(\"newton root finding: df(x) is zero\");\n }\n else {\n // use previous derivation value\n dfx = prev_dfx;\n }\n // or move x a little?\n //dfx = df(x != 0 ? x + x * 1e-15 : 1e-15);\n }\n\n prev_dfx = dfx;\n y = f(x);\n x_correction = y / dfx;\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n\n if (isBounded) {\n if (sign(y) == sign(y_atmax)) {\n max = x;\n y_atmax = y;\n }\n else if (sign(y) == sign(y_atmin)) {\n min = x;\n y_atmin = y;\n }\n else {\n x = x_new;\n break;\n }\n\n if ((x_new < min) || (x_new > max)) {\n if (sign(y_atmin) == sign(y_atmax)) {\n break;\n }\n\n var RATIO_LIMIT = 50;\n var AIMED_BISECT_OFFSET = 0.25; // [0, 0.5)\n var dy = y_atmax - y_atmin;\n var dx = max - min;\n\n if (dy == 0) {\n x_correction = x - (min + dx * 0.5);\n }\n else if (Math.abs(dy / Math.min(y_atmin, y_atmax)) > RATIO_LIMIT) {\n x_correction = x - (min + dx * (0.5 + (Math.abs(y_atmin) < Math.abs(y_atmax) ? -AIMED_BISECT_OFFSET : AIMED_BISECT_OFFSET)));\n }\n else {\n x_correction = x - (min - y_atmin / dy * dx);\n }\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n }\n }\n\n prev_x_ef_correction = x - x_new;\n x = x_new;\n }\n\n return x;\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Polynomial;\n}\n","/**\n *\n * SqrtPolynomial.js\n *\n * copyright 2003, 2013 Kevin Lindsey\n *\n */\n\nif (typeof module !== \"undefined\") {\n var Polynomial = require(\"./Polynomial\");\n}\n\n/**\n * class variables\n */\nSqrtPolynomial.VERSION = 1.0;\n\n// setup inheritance\nSqrtPolynomial.prototype = new Polynomial();\nSqrtPolynomial.prototype.constructor = SqrtPolynomial;\nSqrtPolynomial.superclass = Polynomial.prototype;\n\n\n/**\n * SqrtPolynomial\n */\nfunction SqrtPolynomial() {\n this.init( arguments );\n}\n\n\n/**\n * eval\n *\n * @param {Number} x\n * @returns {Number}\n */\nSqrtPolynomial.prototype.eval = function(x) {\n var TOLERANCE = 1e-7;\n var result = SqrtPolynomial.superclass.eval.call(this, x);\n\n // NOTE: May need to change the following. I added these to capture\n // some really small negative values that were being generated by one\n // of my Bezier arcLength functions\n if ( Math.abs(result) < TOLERANCE ) result = 0;\n if ( result < 0 )\n throw new Error(\"SqrtPolynomial.eval: cannot take square root of negative number\");\n\n return Math.sqrt(result);\n};\n\nSqrtPolynomial.prototype.toString = function() {\n var result = SqrtPolynomial.superclass.toString.call(this);\n\n return \"sqrt(\" + result + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = SqrtPolynomial;\n}\n","// expose classes\n\nexports.Polynomial = require('./lib/Polynomial');\nexports.SqrtPolynomial = require('./lib/SqrtPolynomial');\n","/* eslint-disable camelcase, eqeqeq, no-labels, space-infix-ops */\n/**\n *\n * Intersection.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n *\n */\n\nimport {Point2D, Vector2D} from \"kld-affine\";\nimport {Polynomial} from \"kld-polynomial\";\n\n/**\n *\n * @param {*} o\n * @returns {boolean}\n */\nfunction isNullish(o) {\n return o === null || o === undefined;\n}\n\n/**\n * closePolygon\n *\n * @param {Array} points\n * @returns {Array}\n */\nfunction closePolygon(points) {\n const copy = points.slice();\n\n copy.push(points[0]);\n\n return copy;\n}\n\n\n/**\n * Intersection\n */\nclass Intersection {\n /**\n * @param {string} status\n */\n constructor(status) {\n this.init(status);\n }\n\n\n /**\n * init\n *\n * @param {string} status\n * @returns {Intersection}\n */\n init(status) {\n this.status = status;\n this.points = [];\n }\n\n\n /**\n * appendPoint\n *\n * @param {Point2D} point\n */\n appendPoint(point) {\n this.points.push(point);\n }\n\n\n /**\n * appendPoints\n *\n * @param {Array} points\n */\n appendPoints(points) {\n this.points = this.points.concat(points);\n }\n}\n\n// static methods\n\n/**\n * intersect\n *\n * @param {IntersectionArgs} shape1\n * @param {IntersectionArgs} shape2\n * @returns {Intersection}\n */\nIntersection.intersect = function(shape1, shape2) {\n let result;\n\n if (!isNullish(shape1) && !isNullish(shape2)) {\n if (shape1.name === \"Path\") {\n result = Intersection.intersectPathShape(shape1, shape2);\n }\n else if (shape2.name === \"Path\") {\n result = Intersection.intersectPathShape(shape2, shape1);\n }\n else {\n let method;\n let args;\n\n if (shape1.name < shape2.name) {\n method = \"intersect\" + shape1.name + shape2.name;\n args = shape1.args.concat(shape2.args);\n }\n else {\n method = \"intersect\" + shape2.name + shape1.name;\n args = shape2.args.concat(shape1.args);\n }\n\n if (!(method in Intersection)) {\n throw new Error(\"Intersection not available: \" + method);\n }\n\n result = Intersection[method].apply(null, args);\n }\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n\n return result;\n};\n\n\n/**\n * intersectPathShape\n *\n * @param {IntersectionArgs} path\n * @param {IntersectionArgs} shape\n * @returns {Intersection}\n */\nIntersection.intersectPathShape = function(path, shape) {\n const result = new Intersection(\"No Intersection\");\n\n for (const segment of path.args) {\n const inter = Intersection.intersect(segment, shape);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier2\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) {\n let a, b;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b2.multiply(-2);\n const c22 = b1.add(a.add(b3));\n\n a = b1.multiply(-2);\n b = b2.multiply(2);\n const c21 = a.add(b);\n\n const c20 = new Point2D(b1.x, b1.y);\n\n // bezout\n a = c12.x*c11.y - c11.x*c12.y;\n b = c22.x*c11.y - c11.x*c22.y;\n const c = c21.x*c11.y - c11.x*c21.y;\n const d = c11.x*(c10.y - c20.y) + c11.y*(-c10.x + c20.x);\n const e = c22.x*c12.y - c12.x*c22.y;\n const f = c21.x*c12.y - c12.x*c21.y;\n const g = c12.x*(c10.y - c20.y) + c12.y*(-c10.x + c20.x);\n\n // determinant\n const poly = new Polynomial(\n -e*e,\n -2*e*f,\n a*b - f*f - 2*e*g,\n a*c - 2*f*g,\n a*d - g*g\n );\n\n const roots = poly.getRoots();\n\n for (const s of roots) {\n if (0 <= s && s <= 1) {\n const xp = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(c22.multiply(s*s).add(c21.multiply(s).add(c20)));\n break checkRoots;\n }\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier3\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @param {Point2D} b4\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) {\n let a, b, c, d;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n const c10x2 = c10.x*c10.x;\n const c10y2 = c10.y*c10.y;\n const c11x2 = c11.x*c11.x;\n const c11y2 = c11.y*c11.y;\n const c12x2 = c12.x*c12.x;\n const c12y2 = c12.y*c12.y;\n const c20x2 = c20.x*c20.x;\n const c20y2 = c20.y*c20.y;\n const c21x2 = c21.x*c21.x;\n const c21y2 = c21.y*c21.y;\n const c22x2 = c22.x*c22.x;\n const c22y2 = c22.y*c22.y;\n const c23x2 = c23.x*c23.x;\n const c23y2 = c23.y*c23.y;\n\n const poly = new Polynomial(\n -2*c12.x*c12.y*c23.x*c23.y + c12x2*c23y2 + c12y2*c23x2,\n -2*c12.x*c12.y*c22.x*c23.y - 2*c12.x*c12.y*c22.y*c23.x + 2*c12y2*c22.x*c23.x +\n 2*c12x2*c22.y*c23.y,\n -2*c12.x*c21.x*c12.y*c23.y - 2*c12.x*c12.y*c21.y*c23.x - 2*c12.x*c12.y*c22.x*c22.y +\n 2*c21.x*c12y2*c23.x + c12y2*c22x2 + c12x2*(2*c21.y*c23.y + c22y2),\n 2*c10.x*c12.x*c12.y*c23.y + 2*c10.y*c12.x*c12.y*c23.x + c11.x*c11.y*c12.x*c23.y +\n c11.x*c11.y*c12.y*c23.x - 2*c20.x*c12.x*c12.y*c23.y - 2*c12.x*c20.y*c12.y*c23.x -\n 2*c12.x*c21.x*c12.y*c22.y - 2*c12.x*c12.y*c21.y*c22.x - 2*c10.x*c12y2*c23.x -\n 2*c10.y*c12x2*c23.y + 2*c20.x*c12y2*c23.x + 2*c21.x*c12y2*c22.x -\n c11y2*c12.x*c23.x - c11x2*c12.y*c23.y + c12x2*(2*c20.y*c23.y + 2*c21.y*c22.y),\n 2*c10.x*c12.x*c12.y*c22.y + 2*c10.y*c12.x*c12.y*c22.x + c11.x*c11.y*c12.x*c22.y +\n c11.x*c11.y*c12.y*c22.x - 2*c20.x*c12.x*c12.y*c22.y - 2*c12.x*c20.y*c12.y*c22.x -\n 2*c12.x*c21.x*c12.y*c21.y - 2*c10.x*c12y2*c22.x - 2*c10.y*c12x2*c22.y +\n 2*c20.x*c12y2*c22.x - c11y2*c12.x*c22.x - c11x2*c12.y*c22.y + c21x2*c12y2 +\n c12x2*(2*c20.y*c22.y + c21y2),\n 2*c10.x*c12.x*c12.y*c21.y + 2*c10.y*c12.x*c21.x*c12.y + c11.x*c11.y*c12.x*c21.y +\n c11.x*c11.y*c21.x*c12.y - 2*c20.x*c12.x*c12.y*c21.y - 2*c12.x*c20.y*c21.x*c12.y -\n 2*c10.x*c21.x*c12y2 - 2*c10.y*c12x2*c21.y + 2*c20.x*c21.x*c12y2 -\n c11y2*c12.x*c21.x - c11x2*c12.y*c21.y + 2*c12x2*c20.y*c21.y,\n -2*c10.x*c10.y*c12.x*c12.y - c10.x*c11.x*c11.y*c12.y - c10.y*c11.x*c11.y*c12.x +\n 2*c10.x*c12.x*c20.y*c12.y + 2*c10.y*c20.x*c12.x*c12.y + c11.x*c20.x*c11.y*c12.y +\n c11.x*c11.y*c12.x*c20.y - 2*c20.x*c12.x*c20.y*c12.y - 2*c10.x*c20.x*c12y2 +\n c10.x*c11y2*c12.x + c10.y*c11x2*c12.y - 2*c10.y*c12x2*c20.y -\n c20.x*c11y2*c12.x - c11x2*c20.y*c12.y + c10x2*c12y2 + c10y2*c12x2 +\n c20x2*c12y2 + c12x2*c20y2\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xRoots = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n ).getRoots();\n const yRoots = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n ).getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Circle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} c\n * @param {number} r\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Circle = function(p1, p2, p3, c, r) {\n return Intersection.intersectBezier2Ellipse(p1, p2, p3, c, r, r);\n};\n\n\n/**\n * intersectBezier2Ellipse\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) {\n let a; // temporary variables\n // c2, c1, c0; // coefficients of quadratic\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const roots = new Polynomial(\n ryry*c2.x*c2.x + rxrx*c2.y*c2.y,\n 2*(ryry*c2.x*c1.x + rxrx*c2.y*c1.y),\n ryry*(2*c2.x*c0.x + c1.x*c1.x) + rxrx*(2*c2.y*c0.y+c1.y*c1.y) -\n 2*(ryry*ec.x*c2.x + rxrx*ec.y*c2.y),\n 2*(ryry*c1.x*(c0.x-ec.x) + rxrx*c1.y*(c0.y-ec.y)),\n ryry*(c0.x*c0.x+ec.x*ec.x) + rxrx*(c0.y*c0.y + ec.y*ec.y) -\n 2*(ryry*ec.x*c0.x + rxrx*ec.y*c0.y) - rxrx*ryry\n ).getRoots();\n\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n result.points.push(c2.multiply(t*t).add(c1.multiply(t).add(c0)));\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Line\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) {\n let a; // temporary variables\n // let c2, c1, c0; // coefficients of quadratic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // Transform cubic coefficients to line's coordinate system and find roots\n // of cubic\n const roots = new Polynomial(\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p4 = p1.lerp(p2, t);\n const p5 = p2.lerp(p3, t);\n\n const p6 = p4.lerp(p5, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p6\n if (a1.x == a2.x) {\n if (min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p6.x && p6.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (min.x <= p6.x && p6.x <= max.x && min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Polygon\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Polygon = function(p1, p2, p3, points) {\n return Intersection.intersectBezier2Polyline(p1, p2, p3, closePolygon(points));\n};\n\n\n/**\n * intersectBezier2Polyline\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Polyline = function(p1, p2, p3, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier2Line(p1, p2, p3, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Rectangle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier2Line(p1, p2, p3, min, topRight);\n const inter2 = Intersection.intersectBezier2Line(p1, p2, p3, topRight, max);\n const inter3 = Intersection.intersectBezier2Line(p1, p2, p3, max, bottomLeft);\n const inter4 = Intersection.intersectBezier2Line(p1, p2, p3, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Bezier3\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} a3\n * @param {Point2D} a4\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @param {Point2D} b3\n * @param {Point2D} b4\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) {\n let a, b, c, d; // temporary variables\n // c13, c12, c11, c10; // coefficients of cubic\n // c23, c22, c21, c20; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = a1.multiply(-1);\n b = a2.multiply(3);\n c = a3.multiply(-3);\n d = a.add(b.add(c.add(a4)));\n const c13 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(3);\n b = a2.multiply(-6);\n c = a3.multiply(3);\n d = a.add(b.add(c));\n const c12 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(-3);\n b = a2.multiply(3);\n c = a.add(b);\n const c11 = new Vector2D(c.x, c.y);\n\n const c10 = new Vector2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n // bezout\n a = c13.x * c12.y - c12.x * c13.y;\n b = c13.x * c11.y - c11.x * c13.y;\n const c0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const c1 = c21.x * c13.y - c13.x * c21.y;\n const c2 = c22.x * c13.y - c13.x * c22.y;\n const c3 = c23.x * c13.y - c13.x * c23.y;\n d = c13.x * c11.y - c11.x * c13.y;\n const e0 = c13.x * c10.y + c12.x * c11.y - c11.x * c12.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const e1 = c21.x * c13.y - c13.x * c21.y;\n const e2 = c22.x * c13.y - c13.x * c22.y;\n const e3 = c23.x * c13.y - c13.x * c23.y;\n const f0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const f1 = c21.x * c12.y - c12.x * c21.y;\n const f2 = c22.x * c12.y - c12.x * c22.y;\n const f3 = c23.x * c12.y - c12.x * c23.y;\n const g0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const g1 = c21.x * c13.y - c13.x * c21.y;\n const g2 = c22.x * c13.y - c13.x * c22.y;\n const g3 = c23.x * c13.y - c13.x * c23.y;\n const h0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const h1 = c21.x * c12.y - c12.x * c21.y;\n const h2 = c22.x * c12.y - c12.x * c22.y;\n const h3 = c23.x * c12.y - c12.x * c23.y;\n const i0 = c11.x * c10.y - c10.x * c11.y + c20.x * c11.y - c11.x * c20.y;\n const i1 = c21.x * c11.y - c11.x * c21.y;\n const i2 = c22.x * c11.y - c11.x * c22.y;\n const i3 = c23.x * c11.y - c11.x * c23.y;\n\n // determinant\n const poly = new Polynomial(\n -c3 * e3 * g3,\n -c3 * e3 * g2 - c3 * e2 * g3 - c2 * e3 * g3,\n -c3 * e3 * g1 - c3 * e2 * g2 - c2 * e3 * g2 - c3 * e1 * g3 - c2 * e2 * g3 - c1 * e3 * g3,\n -c3 * e3 * g0 - c3 * e2 * g1 - c2 * e3 * g1 - c3 * e1 * g2 - c2 * e2 * g2 - c1 * e3 * g2 - c3 * e0 * g3 - c2 * e1 * g3 - c1 * e2 * g3 - c0 * e3 * g3 + b * f3 * g3 + c3 * d * h3 - a * f3 * h3 + a * e3 * i3,\n -c3 * e2 * g0 - c2 * e3 * g0 - c3 * e1 * g1 - c2 * e2 * g1 - c1 * e3 * g1 - c3 * e0 * g2 - c2 * e1 * g2 - c1 * e2 * g2 - c0 * e3 * g2 + b * f3 * g2 - c2 * e0 * g3 - c1 * e1 * g3 - c0 * e2 * g3 + b * f2 * g3 + c3 * d * h2 - a * f3 * h2 + c2 * d * h3 - a * f2 * h3 + a * e3 * i2 + a * e2 * i3,\n -c3 * e1 * g0 - c2 * e2 * g0 - c1 * e3 * g0 - c3 * e0 * g1 - c2 * e1 * g1 - c1 * e2 * g1 - c0 * e3 * g1 + b * f3 * g1 - c2 * e0 * g2 - c1 * e1 * g2 - c0 * e2 * g2 + b * f2 * g2 - c1 * e0 * g3 - c0 * e1 * g3 + b * f1 * g3 + c3 * d * h1 - a * f3 * h1 + c2 * d * h2 - a * f2 * h2 + c1 * d * h3 - a * f1 * h3 + a * e3 * i1 + a * e2 * i2 + a * e1 * i3,\n -c3 * e0 * g0 - c2 * e1 * g0 - c1 * e2 * g0 - c0 * e3 * g0 + b * f3 * g0 - c2 * e0 * g1 - c1 * e1 * g1 - c0 * e2 * g1 + b * f2 * g1 - c1 * e0 * g2 - c0 * e1 * g2 + b * f1 * g2 - c0 * e0 * g3 + b * f0 * g3 + c3 * d * h0 - a * f3 * h0 + c2 * d * h1 - a * f2 * h1 + c1 * d * h2 - a * f1 * h2 + c0 * d * h3 - a * f0 * h3 + a * e3 * i0 + a * e2 * i1 + a * e1 * i2 - b * d * i3 + a * e0 * i3,\n -c2 * e0 * g0 - c1 * e1 * g0 - c0 * e2 * g0 + b * f2 * g0 - c1 * e0 * g1 - c0 * e1 * g1 + b * f1 * g1 - c0 * e0 * g2 + b * f0 * g2 + c2 * d * h0 - a * f2 * h0 + c1 * d * h1 - a * f1 * h1 + c0 * d * h2 - a * f0 * h2 + a * e2 * i0 + a * e1 * i1 - b * d * i2 + a * e0 * i2,\n -c1 * e0 * g0 - c0 * e1 * g0 + b * f1 * g0 - c0 * e0 * g1 + b * f0 * g1 + c1 * d * h0 - a * f1 * h0 + c0 * d * h1 - a * f0 * h1 + a * e1 * i0 - b * d * i1 + a * e0 * i1,\n -c0 * e0 * g0 + b * f0 * g0 + c0 * d * h0 - a * f0 * h0 - b * d * i0 + a * e0 * i0\n );\n poly.simplify();\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xp = new Polynomial(\n c13.x,\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c13.y,\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Circle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} c\n * @param {number} r\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) {\n return Intersection.intersectBezier3Ellipse(p1, p2, p3, p4, c, r, r);\n};\n\n\n/**\n * intersectBezier3Ellipse\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const poly = new Polynomial(\n c3.x*c3.x*ryry + c3.y*c3.y*rxrx,\n 2*(c3.x*c2.x*ryry + c3.y*c2.y*rxrx),\n 2*(c3.x*c1.x*ryry + c3.y*c1.y*rxrx) + c2.x*c2.x*ryry + c2.y*c2.y*rxrx,\n 2*c3.x*ryry*(c0.x - ec.x) + 2*c3.y*rxrx*(c0.y - ec.y) +\n 2*(c2.x*c1.x*ryry + c2.y*c1.y*rxrx),\n 2*c2.x*ryry*(c0.x - ec.x) + 2*c2.y*rxrx*(c0.y - ec.y) +\n c1.x*c1.x*ryry + c1.y*c1.y*rxrx,\n 2*c1.x*ryry*(c0.x - ec.x) + 2*c1.y*rxrx*(c0.y - ec.y),\n c0.x*c0.x*ryry - 2*c0.y*ec.y*rxrx - 2*c0.x*ec.x*ryry +\n c0.y*c0.y*rxrx + ec.x*ec.x*ryry + ec.y*ec.y*rxrx - rxrx*ryry\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const t of roots) {\n result.points.push(\n c3.multiply(t*t*t).add(c2.multiply(t*t).add(c1.multiply(t).add(c0)))\n );\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Line\n *\n * Many thanks to Dan Sunday at SoftSurfer.com. He gave me a very thorough\n * sketch of the algorithm used here. Without his help, I'm not sure when I\n * would have figured out this intersection problem.\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n // Start with Bezier using Bernstein polynomials for weighting functions:\n // (1-t^3)P1 + 3t(1-t)^2P2 + 3t^2(1-t)P3 + t^3P4\n //\n // Expand and collect terms to form linear combinations of original Bezier\n // controls. This ends up with a vector cubic in t:\n // (-P1+3P2-3P3+P4)t^3 + (3P1-6P2+3P3)t^2 + (-3P1+3P2)t + P1\n // /\\ /\\ /\\ /\\\n // || || || ||\n // c3 c2 c1 c0\n\n // Calculate the coefficients\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // ?Rotate each cubic coefficient using line for new coordinate system?\n // Find roots of rotated cubic\n const roots = new Polynomial(\n n.dot(c3),\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p5 = p1.lerp(p2, t);\n const p6 = p2.lerp(p3, t);\n const p7 = p3.lerp(p4, t);\n\n const p8 = p5.lerp(p6, t);\n const p9 = p6.lerp(p7, t);\n\n const p10 = p8.lerp(p9, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p10\n if (a1.x == a2.x) {\n if (min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p10.x && p10.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (min.x <= p10.x && p10.x <= max.x && min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Polygon\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) {\n return this.intersectBezier3Polyline(p1, p2, p3, p4, closePolygon(points));\n};\n\n\n/**\n * intersectBezier3Polyline\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier3Line(p1, p2, p3, p4, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Rectangle\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier3Line(p1, p2, p3, p4, min, topRight);\n const inter2 = Intersection.intersectBezier3Line(p1, p2, p3, p4, topRight, max);\n const inter3 = Intersection.intersectBezier3Line(p1, p2, p3, p4, max, bottomLeft);\n const inter4 = Intersection.intersectBezier3Line(p1, p2, p3, p4, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleCircle\n *\n * @param {Point2D} c1\n * @param {number} r1\n * @param {Point2D} c2\n * @param {number} r2\n * @returns {Intersection}\n */\nIntersection.intersectCircleCircle = function(c1, r1, c2, r2) {\n let result;\n\n // Determine minimum and maximum radii where circles can intersect\n const r_max = r1 + r2;\n const r_min = Math.abs(r1 - r2);\n\n // Determine actual distance between circle circles\n const c_dist = c1.distanceFrom(c2);\n\n if (c_dist > r_max) {\n result = new Intersection(\"Outside\");\n }\n else if (c_dist < r_min) {\n result = new Intersection(\"Inside\");\n }\n else {\n result = new Intersection(\"Intersection\");\n\n const a = (r1*r1 - r2*r2 + c_dist*c_dist) / (2*c_dist);\n const h = Math.sqrt(r1*r1 - a*a);\n const p = c1.lerp(c2, a/c_dist);\n const b = h / c_dist;\n\n result.points.push(\n new Point2D(\n p.x - b * (c2.y - c1.y),\n p.y + b * (c2.x - c1.x)\n )\n );\n result.points.push(\n new Point2D(\n p.x + b * (c2.y - c1.y),\n p.y - b * (c2.x - c1.x)\n )\n );\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleEllipse\n *\n * @param {Point2D} cc\n * @param {number} r\n * @param {Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {Intersection}\n */\nIntersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) {\n return Intersection.intersectEllipseEllipse(cc, r, r, ec, rx, ry);\n};\n\n\n/**\n * intersectCircleLine\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectCircleLine = function(c, r, a1, a2) {\n let result;\n const a = (a2.x - a1.x) * (a2.x - a1.x) +\n (a2.y - a1.y) * (a2.y - a1.y);\n const b = 2 * ((a2.x - a1.x) * (a1.x - c.x) +\n (a2.y - a1.y) * (a1.y - c.y));\n const cc = c.x*c.x + c.y*c.y + a1.x*a1.x + a1.y*a1.y -\n 2 * (c.x * a1.x + c.y * a1.y) - r*r;\n const deter = b*b - 4*a*cc;\n\n if (deter < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (deter == 0) {\n result = new Intersection(\"Tangent\");\n // NOTE: should calculate this point\n }\n else {\n const e = Math.sqrt(deter);\n const u1 = (-b + e) / (2*a);\n const u2 = (-b - e) / (2*a);\n\n if ((u1 < 0 || u1 > 1) && (u2 < 0 || u2 > 1)) {\n if ((u1 < 0 && u2 < 0) || (u1 > 1 && u2 > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n\n if (0 <= u1 && u1 <= 1) {\n result.points.push(a1.lerp(a2, u1));\n }\n\n if (0 <= u2 && u2 <= 1) {\n result.points.push(a1.lerp(a2, u2));\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectCirclePolygon\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectCirclePolygon = function(c, r, points) {\n return this.intersectCirclePolyline(c, r, closePolygon(points));\n};\n\n\n/**\n * intersectCirclePolyline\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectCirclePolyline = function(c, r, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n let inter;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n\n inter = Intersection.intersectCircleLine(c, r, a1, a2);\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleRectangle\n *\n * @param {Point2D} c\n * @param {number} r\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectCircleRectangle = function(c, r, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectCircleLine(c, r, min, topRight);\n const inter2 = Intersection.intersectCircleLine(c, r, topRight, max);\n const inter3 = Intersection.intersectCircleLine(c, r, max, bottomLeft);\n const inter4 = Intersection.intersectCircleLine(c, r, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter1.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseEllipse\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {Point2D} c1\n * @param {number} rx1\n * @param {number} ry1\n * @param {Point2D} c2\n * @param {number} rx2\n * @param {number} ry2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) {\n const a = [\n ry1*ry1, 0, rx1*rx1, -2*ry1*ry1*c1.x, -2*rx1*rx1*c1.y,\n ry1*ry1*c1.x*c1.x + rx1*rx1*c1.y*c1.y - rx1*rx1*ry1*ry1\n ];\n const b = [\n ry2*ry2, 0, rx2*rx2, -2*ry2*ry2*c2.x, -2*rx2*rx2*c2.y,\n ry2*ry2*c2.x*c2.x + rx2*rx2*c2.y*c2.y - rx2*rx2*ry2*ry2\n ];\n\n const yPoly = Intersection.bezout(a, b);\n const yRoots = yPoly.getRoots();\n const epsilon = 1e-3;\n const norm0 = (a[0]*a[0] + 2*a[1]*a[1] + a[2]*a[2]) * epsilon;\n const norm1 = (b[0]*b[0] + 2*b[1]*b[1] + b[2]*b[2]) * epsilon;\n const result = new Intersection(\"No Intersection\");\n\n for (let y = 0; y < yRoots.length; y++) {\n const xPoly = new Polynomial(\n a[0],\n a[3] + yRoots[y] * a[1],\n a[5] + yRoots[y] * (a[4] + yRoots[y]*a[2])\n );\n const xRoots = xPoly.getRoots();\n\n for (let x = 0; x < xRoots.length; x++) {\n let tst =\n (a[0]*xRoots[x] + a[1]*yRoots[y] + a[3]) * xRoots[x] +\n (a[2]*yRoots[y] + a[4]) * yRoots[y] + a[5];\n if (Math.abs(tst) < norm0) {\n tst =\n (b[0]*xRoots[x] + b[1]*yRoots[y] + b[3]) * xRoots[x] +\n (b[2]*yRoots[y] + b[4]) * yRoots[y] + b[5];\n if (Math.abs(tst) < norm1) {\n result.appendPoint(new Point2D(xRoots[x], yRoots[y]));\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseLine\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseLine = function(c, rx, ry, a1, a2) {\n let result;\n const orign = new Vector2D(a1.x, a1.y);\n const dir = Vector2D.fromPoints(a1, a2);\n const center = new Vector2D(c.x, c.y);\n const diff = orign.subtract(center);\n const mDir = new Vector2D(dir.x/(rx*rx), dir.y/(ry*ry));\n const mDiff = new Vector2D(diff.x/(rx*rx), diff.y/(ry*ry));\n\n const a = dir.dot(mDir);\n const b = dir.dot(mDiff);\n c = diff.dot(mDiff) - 1.0;\n const d = b*b - a*c;\n\n if (d < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (d > 0) {\n const root = Math.sqrt(d); // eslint-disable-line no-shadow\n const t_a = (-b - root) / a;\n const t_b = (-b + root) / a;\n\n if ((t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b)) {\n if ((t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n if (0 <= t_a && t_a <= 1) {\n result.appendPoint(a1.lerp(a2, t_a));\n }\n if (0 <= t_b && t_b <= 1) {\n result.appendPoint(a1.lerp(a2, t_b));\n }\n }\n }\n else {\n const t = -b/a;\n\n if (0 <= t && t <= 1) {\n result = new Intersection(\"Intersection\");\n result.appendPoint(a1.lerp(a2, t));\n }\n else {\n result = new Intersection(\"Outside\");\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipsePolygon\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectEllipsePolygon = function(c, rx, ry, points) {\n return this.intersectEllipsePolyline(c, rx, ry, closePolygon(points));\n};\n\n\n/**\n * intersectEllipsePolyline\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectEllipsePolyline = function(c, rx, ry, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectEllipseLine(c, rx, ry, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseRectangle\n *\n * @param {Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectEllipseLine(c, rx, ry, min, topRight);\n const inter2 = Intersection.intersectEllipseLine(c, rx, ry, topRight, max);\n const inter3 = Intersection.intersectEllipseLine(c, rx, ry, max, bottomLeft);\n const inter4 = Intersection.intersectEllipseLine(c, rx, ry, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineLine\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectLineLine = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n const ub = ub_t / u_b;\n\n if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * intersectLinePolygon\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectLinePolygon = function(a1, a2, points) {\n return this.intersectLinePolyline(a1, a2, closePolygon(points));\n};\n\n\n/**\n * intersectLinePolyline\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Array} points\n * @returns {Intersection}\n */\nIntersection.intersectLinePolyline = function(a1, a2, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectLineLine(a1, a2, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineRectangle\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectLineRectangle = function(a1, a2, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineLine(min, topRight, a1, a2);\n const inter2 = Intersection.intersectLineLine(topRight, max, a1, a2);\n const inter3 = Intersection.intersectLineLine(max, bottomLeft, a1, a2);\n const inter4 = Intersection.intersectLineLine(bottomLeft, min, a1, a2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolygonPolygon\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonPolygon = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), closePolygon(points2));\n};\n\n\n/**\n * intersectPolygonPolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonPolyline = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), points2);\n};\n\n\n/**\n * intersectPolygonRectangle\n *\n * @param {Array} points\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectPolygonRectangle = function(points, r1, r2) {\n return this.intersectPolylineRectangle(closePolygon(points), r1, r2);\n};\n\n\n/**\n * intersectPolylinePolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {Intersection}\n */\nIntersection.intersectPolylinePolyline = function(points1, points2) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points1;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points1[i];\n const a2 = points1[i + 1];\n const inter = Intersection.intersectLinePolyline(a1, a2, points2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolylineRectangle\n *\n * @param {Array} points\n * @param {Point2D} r1\n * @param {Point2D} r2\n * @returns {Intersection}\n */\nIntersection.intersectPolylineRectangle = function(points, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLinePolyline(min, topRight, points);\n const inter2 = Intersection.intersectLinePolyline(topRight, max, points);\n const inter3 = Intersection.intersectLinePolyline(max, bottomLeft, points);\n const inter4 = Intersection.intersectLinePolyline(bottomLeft, min, points);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRectangleRectangle\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectRectangleRectangle = function(a1, a2, b1, b2) {\n const min = a1.min(a2);\n const max = a1.max(a2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineRectangle(min, topRight, b1, b2);\n const inter2 = Intersection.intersectLineRectangle(topRight, max, b1, b2);\n const inter3 = Intersection.intersectLineRectangle(max, bottomLeft, b1, b2);\n const inter4 = Intersection.intersectLineRectangle(bottomLeft, min, b1, b2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRayRay\n *\n * @param {Point2D} a1\n * @param {Point2D} a2\n * @param {Point2D} b1\n * @param {Point2D} b2\n * @returns {Intersection}\n */\nIntersection.intersectRayRay = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * bezout\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * @param {Array} e1\n * @param {Array} e2\n * @returns {Polynomial}\n */\nIntersection.bezout = function(e1, e2) {\n const AB = e1[0]*e2[1] - e2[0]*e1[1];\n const AC = e1[0]*e2[2] - e2[0]*e1[2];\n const AD = e1[0]*e2[3] - e2[0]*e1[3];\n const AE = e1[0]*e2[4] - e2[0]*e1[4];\n const AF = e1[0]*e2[5] - e2[0]*e1[5];\n const BC = e1[1]*e2[2] - e2[1]*e1[2];\n const BE = e1[1]*e2[4] - e2[1]*e1[4];\n const BF = e1[1]*e2[5] - e2[1]*e1[5];\n const CD = e1[2]*e2[3] - e2[2]*e1[3];\n const DE = e1[3]*e2[4] - e2[3]*e1[4];\n const DF = e1[3]*e2[5] - e2[3]*e1[5];\n const BFpDE = BF + DE;\n const BEmCD = BE - CD;\n\n return new Polynomial(\n AB*BC - AC*AC,\n AB*BEmCD + AD*BC - 2*AC*AE,\n AB*BFpDE + AD*BEmCD - AE*AE - 2*AC*AF,\n AB*DF + AD*BFpDE - 2*AE*AF,\n AD*DF - AF*AF\n );\n};\n\nexport default Intersection;\n","/**\n *\n * IntersectionArgs.js\n *\n * @copyright 2002, 2017 Kevin Lindsey\n *\n */\n\n/**\n * IntersectionArgs\n *\n */\nclass IntersectionArgs {\n /**\n * @param {string} name\n * @param {Array} args\n * @returns {IntersectionArgs}\n */\n constructor(name, args) {\n this.init(name, args);\n }\n /**\n * init\n *\n * @param {string} name\n * @param {Array} args\n */\n init(name, args) {\n this.name = name;\n this.args = args;\n }\n}\n\nexport default IntersectionArgs;\n","/**\n * Shapes\n *\n * @copyright 2017, Kevin Lindsey\n */\n\nimport {Point2D} from \"kld-affine\";\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\nconst Shapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @returns {IntersectionArgs}\n */\nShapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) {\n return new IntersectionArgs(\"Bezier2\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y)\n ]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @param {number} p4x\n * @param {number} p4y\n * @returns {IntersectionArgs}\n */\nShapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) {\n return new IntersectionArgs(\"Bezier3\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y),\n new Point2D(p4x, p4y)\n ]);\n};\n\n\n/**\n * circle\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radius\n * @returns {IntersectionArgs}\n */\nShapes.circle = function(centerX, centerY, radius) {\n return new IntersectionArgs(\"Circle\", [\n new Point2D(centerX, centerY),\n radius\n ]);\n};\n\n\n/**\n * ellipse\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {IntersectionArgs}\n */\nShapes.ellipse = function(centerX, centerY, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [\n new Point2D(centerX, centerY),\n radiusX,\n radiusY\n ]);\n};\n\n\n/**\n * line\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @returns {IntersectionArgs}\n */\nShapes.line = function(p1x, p1y, p2x, p2y) {\n return new IntersectionArgs(\"Line\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y)\n ]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {IntersectionArgs}\n */\nShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", segments);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} coords\n * @returns {IntersectionArgs}\n */\nShapes.polygon = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} coords\n * @returns {IntersectionArgs}\n */\nShapes.polyline = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n * @returns {IntersectionArgs}\n */\nShapes.rectangle = function(x, y, width, height) {\n return new IntersectionArgs(\"Rectangle\", [\n new Point2D(x, y),\n new Point2D(x + width, y + height)\n ]);\n};\n\n\nexport default Shapes;\n","/**\n * AffineShapes\n *\n * @copyright 2017, Kevin Lindsey\n */\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\nconst AffineShapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @returns {IntersectionArgs}\n */\nAffineShapes.quadraticBezier = function(p1, p2, p3) {\n return new IntersectionArgs(\"Bezier2\", [p1, p2, p3]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @param {Point2D} p3\n * @param {Point2D} p4\n * @returns {IntersectionArgs}\n */\nAffineShapes.cubicBezier = function(p1, p2, p3, p4) {\n return new IntersectionArgs(\"Bezier3\", [p1, p2, p3, p4]);\n};\n\n\n/**\n * circle\n *\n * @param {Point2D} center\n * @param {number} radius\n * @returns {IntersectionArgs}\n */\nAffineShapes.circle = function(center, radius) {\n return new IntersectionArgs(\"Circle\", [center, radius]);\n};\n\n\n/**\n * ellipse\n *\n * @param {Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {IntersectionArgs}\n */\nAffineShapes.ellipse = function(center, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [center, radiusX, radiusY]);\n};\n\n\n/**\n * line\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {IntersectionArgs}\n */\nAffineShapes.line = function(p1, p2) {\n return new IntersectionArgs(\"Line\", [p1, p2]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {IntersectionArgs}\n */\nAffineShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", [segments]);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} points\n * @returns {IntersectionArgs}\n */\nAffineShapes.polygon = function(points) {\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} points\n * @returns {IntersectionArgs}\n */\nAffineShapes.polyline = function(points) {\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {Point2D} topLeft\n * @param {Vector2D} size\n * @returns {IntersectionArgs}\n */\nAffineShapes.rectangle = function(topLeft, size) {\n return new IntersectionArgs(\"Rectangle\", [topLeft, topLeft.add(size)]);\n};\n\n\nexport default AffineShapes;\n","/**\n *\n * IntersectionQuery.js\n *\n * @copyright 2017 Kevin Lindsey\n *\n */\n\nimport {Vector2D} from \"kld-affine\";\n\n/**\n *\n */\nconst IntersectionQuery = {};\n\n\n/**\n * pointInCircle\n *\n * @param {Point2D} point\n * @param {Point2D} center\n * @param {number} radius\n * @returns {boolean}\n */\nIntersectionQuery.pointInCircle = function(point, center, radius) {\n const v = Vector2D.fromPoints(center, point);\n\n return v.length() <= radius;\n};\n\n\n/**\n * pointInEllipse\n *\n * @param {Point2D} point\n * @param {Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {boolean}\n */\nIntersectionQuery.pointInEllipse = function(point, center, radiusX, radiusY) {\n const len = point.subtract(center);\n\n return (len.x * len.x) / (radiusX * radiusX) + (len.y * len.y) / (radiusY * radiusY) <= 1;\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolyline = function(point, points) {\n const {length: len} = points;\n let counter = 0;\n let xInter;\n\n let p1 = points[0];\n\n for (let i = 1; i <= len; i++) {\n const p2 = points[i % len];\n const minY = Math.min(p1.y, p2.y);\n const maxY = Math.max(p1.y, p2.y);\n const maxX = Math.max(p1.x, p2.x);\n\n if (p1.y !== p2.y && minY < point.y && point.y <= maxY && point.x <= maxX) {\n xInter = (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;\n\n if (p1.x === p2.x || point.x <= xInter) {\n counter++;\n }\n }\n\n p1 = p2;\n }\n\n return (counter % 2 === 1);\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline;\n\n\n/**\n * pointInRectangle\n *\n * @param {Point2D} point\n * @param {Point2D} topLeft\n * @param {Point2D} bottomRight\n * @returns {boolean}\n */\nIntersectionQuery.pointInRectangle = function(point, topLeft, bottomRight) {\n return (\n topLeft.x <= point.x && point.x < bottomRight.x &&\n topLeft.y <= point.y && point.y < bottomRight.y\n );\n};\n\n\nexport default IntersectionQuery;\n"],"names":["Point2D","x","y","Object","defineProperties","this","value","undefined","writable","enumerable","configurable","prototype","clone","constructor","add","that","subtract","multiply","scalar","divide","equals","precisionEquals","precision","Math","abs","lerp","t","omt","distanceFrom","dx","dy","sqrt","min","max","transform","matrix","a","c","e","b","d","f","toString","module","Vector2D","fromPoints","p1","p2","length","magnitude","dot","cross","determinant","unit","angleBetween","cos","radians","acos","perp","perpendicular","project","percent","setReadonlyProperty","object","property","defineProperty","Matrix2D","IDENTITY","translation","tx","ty","scaling","scale","scalingAt","center","nonUniformScaling","scaleX","scaleY","nonUniformScalingAt","rotation","s","sin","rotationAt","rotationFromVector","vector","xFlip","yFlip","xSkew","tan","ySkew","isIdentity","inverse","det1","idet","det2","det3","translate","scaleAt","scaleNonUniform","scaleNonUniformAt","rotate","rotateAt","cx","cy","rotateFromVector","flipX","flipY","skewX","skewY","isInvertible","getScale","getDecomposition","E","F","G","H","Q","R","a1","atan2","a2","theta","phi","rotation0","join","require","Polynomial","init","arguments","TOLERANCE","ACCURACY","interpolate","xs","ys","n","offset","Array","Error","isNaN","ns","diff","i","dift","m","ho","hp","w","den","coefs","push","_variable","_s","eval","result","d1","getDegree","d2","dmax","v1","v2","j","divide_scalar","simplify","pop","bisection","minValue","maxValue","tmp1","log","tmp2","LN10","iters","ceil","LN2","signs","round","sign","trapezoid","range","it","delta","sum","simpson","st","os","ost","romberg","MAX","h","getDerivative","derivative","getRoots","getLinearRoot","getQuadraticRoots","getCubicRoots","getQuarticRoots","getRootsInInterval","root","roots","droots","results","c3","c2","c1","discrim","halfB","ZEROepsilon","zeroErrorEstimate","tmp","pow","distance","angle","sqrt3","NaN","poly","slice","poly_d","derrt","sort","dery","nr","rb","bounds","maxabsX","minX","maxX","guesses","minmax","df","newton_secant_bisection","concat","an","reduce","v","nm","bounds_UpperReal_Fujiwara","map","coefSelectionFunc","find2Max","acc","bi","nearmax","max_nearmax_pos","negX","posX","bounds_LowerReal_Fujiwara","reverse","res","urb","x0","max_iterations","dfx","x_correction","x_new","y_atmin","y_atmax","prev_dfx","prev_x_ef_correction","min_correction_factor","isBounded","isEnoughCorrection","SqrtPolynomial","VERSION","superclass","call","isNullish","o","closePolygon","points","copy","Intersection","status","point","intersect","shape1","shape2","name","intersectPathShape","method","args","apply","path","shape","segment","inter","appendPoints","intersectBezier2Bezier2","a3","b1","b2","b3","c12","c11","c10","c22","c21","c20","g","xp","xRoots","yp","yRoots","checkRoots","xRoot","k","intersectBezier2Bezier3","b4","c23","c10x2","c10y2","c11x2","c11y2","c12x2","c12y2","c20x2","c20y2","c21x2","c21y2","c22x2","c22y2","c23x2","c23y2","intersectBezier2Circle","p3","r","intersectBezier2Ellipse","ec","rx","ry","c0","rxrx","ryry","intersectBezier2Line","cl","p4","p5","p6","appendPoint","intersectBezier2Polygon","intersectBezier2Polyline","len","intersectBezier2Rectangle","r1","r2","topRight","bottomLeft","inter1","inter2","inter3","inter4","intersectBezier3Bezier3","a4","c13","e0","e1","e2","e3","f0","f1","f2","f3","g0","g1","g2","g3","h0","h1","h2","h3","i0","i1","i2","i3","intersectBezier3Circle","intersectBezier3Ellipse","intersectBezier3Line","p7","p8","p9","p10","intersectBezier3Polygon","intersectBezier3Polyline","intersectBezier3Rectangle","intersectCircleCircle","r_max","r_min","c_dist","p","intersectCircleEllipse","cc","intersectEllipseEllipse","intersectCircleLine","deter","u1","u2","intersectCirclePolygon","intersectCirclePolyline","intersectCircleRectangle","rx1","ry1","rx2","ry2","bezout","norm0","norm1","tst","intersectEllipseLine","orign","dir","mDir","mDiff","t_a","t_b","intersectEllipsePolygon","intersectEllipsePolyline","intersectEllipseRectangle","intersectLineLine","ua_t","ub_t","u_b","ua","ub","intersectLinePolygon","intersectLinePolyline","intersectLineRectangle","intersectPolygonPolygon","points1","points2","intersectPolylinePolyline","intersectPolygonPolyline","intersectPolygonRectangle","intersectPolylineRectangle","intersectRectangleRectangle","intersectRayRay","AB","AC","AD","AE","AF","BC","BE","BF","CD","DE","DF","BFpDE","BEmCD","IntersectionArgs","Shapes","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","centerX","centerY","radius","radiusX","radiusY","segments","coords","width","height","AffineShapes","topLeft","size","IntersectionQuery","xInter","counter","minY","maxY","pointInPolygon","pointInPolyline","pointInRectangle","bottomRight"],"mappings":"2lBAeA,SAASA,EAAQC,EAAGC,GAChBC,OAAOC,iBAAiBC,KAAM,GACrB,CACDC,WAAaC,IAANN,EAAkBA,EAAI,EAC7BO,UAAU,EACVC,YAAY,EACZC,cAAc,KAEb,CACDJ,WAAaC,IAANL,EAAkBA,EAAI,EAC7BM,UAAU,EACVC,Y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5C,EAAG6C,EAAG7C,GACzB+N,EAAO1M,KAAKU,IAAIa,EAAG7C,EAAG8C,EAAG9C,GAE3B6C,EAAG5C,IAAM6C,EAAG7C,GAAKsd,EAAOxM,EAAM9Q,GAAK8Q,EAAM9Q,GAAKud,GAAQzM,EAAM/Q,GAAKgO,IACjEqP,GAAUtM,EAAM9Q,EAAI4C,EAAG5C,IAAM6C,EAAG9C,EAAI6C,EAAG7C,IAAM8C,EAAG7C,EAAI4C,EAAG5C,GAAK4C,EAAG7C,GAE3D6C,EAAG7C,IAAM8C,EAAG9C,GAAK+Q,EAAM/Q,GAAKqd,IAC5BC,KAIRza,EAAKC,SAGDwa,EAAU,GAAM,IAU5BF,EAAkBK,eAAiBL,EAAkBM,gBAWrDN,EAAkBO,iBAAmB,SAAS5M,EAAOmM,EAASU,UAEtDV,EAAQld,GAAK+Q,EAAM/Q,GAAK+Q,EAAM/Q,EAAI4d,EAAY5d,GAC9Ckd,EAAQjd,GAAK8Q,EAAM9Q,GAAK8Q,EAAM9Q,EAAI2d,EAAY3d"} \ No newline at end of file +{"version":3,"file":"index-umd.min.js","sources":["../node_modules/kld-affine/lib/Point2D.js","../node_modules/kld-affine/lib/Vector2D.js","../node_modules/kld-affine/lib/Matrix2D.js","../node_modules/kld-affine/index.js","../node_modules/kld-polynomial/lib/Polynomial.js","../node_modules/kld-polynomial/lib/SqrtPolynomial.js","../node_modules/kld-polynomial/index.js","../lib/Intersection.js","../lib/IntersectionArgs.js","../lib/Shapes.js","../lib/AffineShapes.js","../lib/IntersectionQuery.js"],"sourcesContent":["/**\n *\n * Point2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Point2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Point2D}\n */\nfunction Point2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * clone\n *\n * @returns {Point2D}\n */\nPoint2D.prototype.clone = function() {\n return new this.constructor(this.x, this.y);\n};\n\n/**\n * add\n *\n * @param {Point2D|Vector2D} that\n * @returns {Point2D}\n */\nPoint2D.prototype.add = function(that) {\n return new this.constructor(this.x+that.x, this.y+that.y);\n};\n\n/**\n * subtract\n *\n * @param { Vector2D | Point2D } that\n * @returns {Point2D}\n */\nPoint2D.prototype.subtract = function(that) {\n return new this.constructor(this.x-that.x, this.y-that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x*scalar, this.y*scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Point2D}\n */\nPoint2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x/scalar, this.y/scalar);\n};\n\n/**\n * equals\n *\n * @param {Point2D} that\n * @returns {Boolean}\n */\nPoint2D.prototype.equals = function(that) {\n return ( this.x === that.x && this.y === that.y );\n};\n\n/**\n * precisionEquals\n *\n * @param {Point2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nPoint2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n// utility methods\n\n/**\n * lerp\n *\n * @param { Vector2D | Point2D } that\n * @param {Number} t\n @ @returns {Point2D}\n */\nPoint2D.prototype.lerp = function(that, t) {\n var omt = 1.0 - t;\n\n return new this.constructor(\n this.x * omt + that.x * t,\n this.y * omt + that.y * t\n );\n};\n\n/**\n * distanceFrom\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.distanceFrom = function(that) {\n var dx = this.x - that.x;\n var dy = this.y - that.y;\n\n return Math.sqrt(dx*dx + dy*dy);\n};\n\n/**\n * min\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.min = function(that) {\n return new this.constructor(\n Math.min( this.x, that.x ),\n Math.min( this.y, that.y )\n );\n};\n\n/**\n * max\n *\n * @param {Point2D} that\n * @returns {Number}\n */\nPoint2D.prototype.max = function(that) {\n return new this.constructor(\n Math.max( this.x, that.x ),\n Math.max( this.y, that.y )\n );\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @result {Point2D}\n */\nPoint2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y + matrix.e,\n matrix.b * this.x + matrix.d * this.y + matrix.f\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nPoint2D.prototype.toString = function() {\n return \"point(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Point2D;\n}\n","/**\n *\n * Vector2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n *\n */\n\n/**\n * Vector2D\n *\n * @param {Number} x\n * @param {Number} y\n * @returns {Vector2D}\n */\nfunction Vector2D(x, y) {\n Object.defineProperties(this, {\n \"x\": {\n value: x !== undefined ? x : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n },\n \"y\": {\n value: y !== undefined ? y : 0.0,\n writable: false,\n enumerable: true,\n configurable: false\n }\n });\n}\n\n/**\n * fromPoints\n *\n * @param {Point2D} p1\n * @param {Point2D} p2\n * @returns {Vector2D}\n */\nVector2D.fromPoints = function(p1, p2) {\n return new Vector2D(\n p2.x - p1.x,\n p2.y - p1.y\n );\n};\n\n/**\n * length\n *\n * @returns {Number}\n */\nVector2D.prototype.length = function() {\n return Math.sqrt(this.x*this.x + this.y*this.y);\n};\n\n/**\n * magnitude\n *\n * @returns {Number}\n */\nVector2D.prototype.magnitude = function() {\n return this.x*this.x + this.y*this.y;\n};\n\n/**\n * dot\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.dot = function(that) {\n return this.x*that.x + this.y*that.y;\n};\n\n/**\n * cross\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.cross = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * determinant\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.determinant = function(that) {\n return this.x*that.y - this.y*that.x;\n};\n\n/**\n * unit\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.unit = function() {\n return this.divide( this.length() );\n};\n\n/**\n * add\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.add = function(that) {\n return new this.constructor(this.x + that.x, this.y + that.y);\n};\n\n/**\n * subtract\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.subtract = function(that) {\n return new this.constructor(this.x - that.x, this.y - that.y);\n};\n\n/**\n * multiply\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.multiply = function(scalar) {\n return new this.constructor(this.x * scalar, this.y * scalar);\n};\n\n/**\n * divide\n *\n * @param {Number} scalar\n * @returns {Vector2D}\n */\nVector2D.prototype.divide = function(scalar) {\n return new this.constructor(this.x / scalar, this.y / scalar);\n};\n\n/**\n * angleBetween\n *\n * @param {Vector2D} that\n * @returns {Number}\n */\nVector2D.prototype.angleBetween = function(that) {\n var cos = this.dot(that) / (this.length() * that.length());\n cos = Math.max(-1, Math.min(cos, 1));\n var radians = Math.acos(cos);\n\n return (this.cross(that) < 0.0) ? -radians : radians;\n};\n\n/**\n * Find a vector is that is perpendicular to this vector\n *\n * @returns {Vector2D}\n */\nVector2D.prototype.perp = function() {\n return new this.constructor(-this.y, this.x);\n};\n\n/**\n * Find the component of the specified vector that is perpendicular to\n * this vector\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.perpendicular = function(that) {\n return this.subtract(this.project(that));\n};\n\n/**\n * project\n *\n * @param {Vector2D} that\n * @returns {Vector2D}\n */\nVector2D.prototype.project = function(that) {\n var percent = this.dot(that) / that.dot(that);\n\n return that.multiply(percent);\n};\n\n/**\n * transform\n *\n * @param {Matrix2D}\n * @returns {Vector2D}\n */\nVector2D.prototype.transform = function(matrix) {\n return new this.constructor(\n matrix.a * this.x + matrix.c * this.y,\n matrix.b * this.x + matrix.d * this.y\n );\n};\n\n/**\n * equals\n *\n * @param {Vector2D} that\n * @returns {Boolean}\n */\nVector2D.prototype.equals = function(that) {\n return (\n this.x === that.x &&\n this.y === that.y\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Vector2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nVector2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.x - that.x) < precision &&\n Math.abs(this.y - that.y) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nVector2D.prototype.toString = function() {\n return \"vector(\" + this.x + \",\" + this.y + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Vector2D;\n}\n","/**\n * Matrix2D.js\n *\n * copyright 2001-2002, 2013, 2017 Kevin Lindsey\n */\n\nfunction setReadonlyProperty(object, property, value) {\n Object.defineProperty(object, property, {\n value: value,\n writable: false,\n enumerable: true,\n configurable: false\n });\n}\n\n/**\n * Identity matrix\n *\n * @returns {Matrix2D}\n */\nsetReadonlyProperty(Matrix2D, \"IDENTITY\", new Matrix2D(1, 0, 0, 1, 0, 0));\nsetReadonlyProperty(Matrix2D.IDENTITY, \"isIdentity\", function () { return true; });\n\n\n/**\n * Matrix2D\n *\n * [a c e]\n * [b d f]\n * [0 0 1]\n *\n * @param {Number} a\n * @param {Number} b\n * @param {Number} c\n * @param {Number} d\n * @param {Number} e\n * @param {Number} f\n * @returns {Matrix2D}\n */\nfunction Matrix2D(a, b, c, d, e, f) {\n setReadonlyProperty(this, \"a\", (a !== undefined) ? a : 1);\n setReadonlyProperty(this, \"b\", (b !== undefined) ? b : 0);\n setReadonlyProperty(this, \"c\", (c !== undefined) ? c : 0);\n setReadonlyProperty(this, \"d\", (d !== undefined) ? d : 1);\n setReadonlyProperty(this, \"e\", (e !== undefined) ? e : 0);\n setReadonlyProperty(this, \"f\", (f !== undefined) ? f : 0);\n}\n\n\n// *** STATIC METHODS\n\n/**\n * translation\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.translation = function(tx, ty) {\n return new Matrix2D(1, 0, 0, 1, tx, ty);\n};\n\n/**\n * scaling\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.scaling = function(scale) {\n return new Matrix2D(scale, 0, 0, scale, 0, 0);\n};\n\n/**\n * scalingAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.scalingAt = function(scale, center) {\n return new Matrix2D(\n scale,\n 0,\n 0,\n scale,\n center.x - center.x * scale,\n center.y - center.y * scale\n );\n}\n\n\n/**\n * nonUniformScaling\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScaling = function(scaleX, scaleY) {\n return new Matrix2D(scaleX, 0, 0, scaleY, 0, 0);\n};\n\n/**\n * nonUniformScalingAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.nonUniformScalingAt = function(scaleX, scaleY, center) {\n return new Matrix2D(\n scaleX,\n 0,\n 0,\n scaleY,\n center.x - center.x * scaleX,\n center.y - center.y * scaleY\n );\n};\n\n/**\n * rotation\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.rotation = function(radians) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * rotationAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.rotationAt = function(radians, center) {\n let c = Math.cos(radians);\n let s = Math.sin(radians);\n\n return new Matrix2D(\n c,\n s,\n -s,\n c,\n center.x - center.x * c + center.y * s,\n center.y - center.y * c - center.x * s\n );\n};\n\n/**\n * rotationFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.rotationFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new Matrix2D(c, s, -s, c, 0, 0);\n};\n\n/**\n * xFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.xFlip = function() {\n return new Matrix2D(-1, 0, 0, 1, 0, 0);\n};\n\n/**\n * yFlip\n *\n * @returns {Matrix2D}\n */\nMatrix2D.yFlip = function() {\n return new Matrix2D(1, 0, 0, -1, 0, 0);\n};\n\n/**\n * xSkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.xSkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, 0, t, 1, 0, 0);\n};\n\n/**\n * ySkew\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.ySkew = function(radians) {\n var t = Math.tan(radians);\n\n return new Matrix2D(1, t, 0, 1, 0, 0);\n};\n\n\n// *** METHODS\n\n/**\n * multiply\n *\n * @pararm {Matrix2D} that\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.multiply = function (that) {\n if (this.isIdentity()) {\n return that;\n }\n\n if (that.isIdentity()) {\n return this;\n }\n\n return new this.constructor(\n this.a * that.a + this.c * that.b,\n this.b * that.a + this.d * that.b,\n this.a * that.c + this.c * that.d,\n this.b * that.c + this.d * that.d,\n this.a * that.e + this.c * that.f + this.e,\n this.b * that.e + this.d * that.f + this.f\n );\n};\n\n/**\n * inverse\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.inverse = function () {\n if (this.isIdentity()) {\n return this;\n }\n\n var det1 = this.a * this.d - this.b * this.c;\n\n if ( det1 === 0.0 ) {\n throw(\"Matrix is not invertible\");\n }\n\n var idet = 1.0 / det1;\n var det2 = this.f * this.c - this.e * this.d;\n var det3 = this.e * this.b - this.f * this.a;\n\n return new this.constructor(\n this.d * idet,\n -this.b * idet,\n -this.c * idet,\n this.a * idet,\n det2 * idet,\n det3 * idet\n );\n};\n\n/**\n * translate\n *\n * @param {Number} tx\n * @param {Number} ty\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.translate = function(tx, ty) {\n return new this.constructor(\n this.a,\n this.b,\n this.c,\n this.d,\n this.a * tx + this.c * ty + this.e,\n this.b * tx + this.d * ty + this.f\n );\n};\n\n/**\n * scale\n *\n * @param {Number} scale\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scale = function(scale) {\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleAt\n *\n * @param {Number} scale\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleAt = function(scale, center) {\n var dx = center.x - scale * center.x;\n var dy = center.y - scale * center.y;\n\n return new this.constructor(\n this.a * scale,\n this.b * scale,\n this.c * scale,\n this.d * scale,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * scaleNonUniform\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniform = function(scaleX, scaleY) {\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.e,\n this.f\n );\n};\n\n/**\n * scaleNonUniformAt\n *\n * @param {Number} scaleX\n * @param {Number} scaleY\n * @param {Point2D} center\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.scaleNonUniformAt = function(scaleX, scaleY, center) {\n var dx = center.x - scaleX * center.x;\n var dy = center.y - scaleY * center.y;\n\n return new this.constructor(\n this.a * scaleX,\n this.b * scaleX,\n this.c * scaleY,\n this.d * scaleY,\n this.a * dx + this.c * dy + this.e,\n this.b * dx + this.d * dy + this.f\n );\n};\n\n/**\n * rotate\n *\n * @param {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotate = function(radians) {\n var c = Math.cos(radians);\n var s = Math.sin(radians);\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * rotateAt\n *\n * @param {Number} radians\n * @param {Point2D} center\n * @result {Matrix2D}\n */\nMatrix2D.prototype.rotateAt = function(radians, center) {\n var cos = Math.cos(radians);\n var sin = Math.sin(radians);\n var cx = center.x;\n var cy = center.y;\n\n var a = this.a * cos + this.c * sin;\n var b = this.b * cos + this.d * sin;\n var c = this.c * cos - this.a * sin;\n var d = this.d * cos - this.b * sin;\n\n return new this.constructor(\n a,\n b,\n c,\n d,\n (this.a - a) * cx + (this.c - c) * cy + this.e,\n (this.b - b) * cx + (this.d - d) * cy + this.f\n );\n};\n\n/**\n * rotateFromVector\n *\n * @param {Vector2D}\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.rotateFromVector = function(vector) {\n var unit = vector.unit();\n var c = unit.x; // cos\n var s = unit.y; // sin\n\n return new this.constructor(\n this.a * c + this.c * s,\n this.b * c + this.d * s,\n this.a * -s + this.c * c,\n this.b * -s + this.d * c,\n this.e,\n this.f\n );\n};\n\n/**\n * flipX\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipX = function() {\n return new this.constructor(\n -this.a,\n -this.b,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * flipY\n *\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.flipY = function() {\n return new this.constructor(\n this.a,\n this.b,\n -this.c,\n -this.d,\n this.e,\n this.f\n );\n};\n\n/**\n * skewX\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewX = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a,\n this.b,\n this.c + this.a * t,\n this.d + this.b * t,\n this.e,\n this.f\n );\n};\n\n// TODO: skewXAt\n\n/**\n * skewY\n *\n * @pararm {Number} radians\n * @returns {Matrix2D}\n */\nMatrix2D.prototype.skewY = function(radians) {\n var t = Math.tan(radians);\n\n return new this.constructor(\n this.a + this.c * t,\n this.b + this.d * t,\n this.c,\n this.d,\n this.e,\n this.f\n );\n};\n\n// TODO: skewYAt\n\n/**\n * isIdentity\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isIdentity = function() {\n return (\n this.a === 1.0 &&\n this.b === 0.0 &&\n this.c === 0.0 &&\n this.d === 1.0 &&\n this.e === 0.0 &&\n this.f === 0.0\n );\n};\n\n/**\n * isInvertible\n *\n * @returns {Boolean}\n */\nMatrix2D.prototype.isInvertible = function() {\n return this.a * this.d - this.b * this.c !== 0.0;\n};\n\n/**\n * getScale\n *\n * @returns {{ scaleX: Number, scaleY: Number }}\n */\nMatrix2D.prototype.getScale = function() {\n return {\n scaleX: Math.sqrt(this.a * this.a + this.c * this.c),\n scaleY: Math.sqrt(this.b * this.b + this.d * this.d)\n };\n};\n\n/**\n * getDecomposition\n *\n * Calculates matrix Singular Value Decomposition\n *\n * The resulting matrices, translation, rotation, scale, and rotation0, return\n * this matrix when they are muliplied together in the listed order\n *\n * @see Jim Blinn's article {@link http://dx.doi.org/10.1109/38.486688}\n * @see {@link http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation}\n *\n * @returns {{ translation: Matrix2D, rotation: Matrix2D, scale: Matrix2D, rotation0: Matrix2D }}\n */\nMatrix2D.prototype.getDecomposition = function () {\n var E = (this.a + this.d) * 0.5;\n var F = (this.a - this.d) * 0.5;\n var G = (this.b + this.c) * 0.5;\n var H = (this.b - this.c) * 0.5;\n\n var Q = Math.sqrt(E * E + H * H);\n var R = Math.sqrt(F * F + G * G);\n var scaleX = Q + R;\n var scaleY = Q - R;\n\n var a1 = Math.atan2(G, F);\n var a2 = Math.atan2(H, E);\n var theta = (a2 - a1) * 0.5;\n var phi = (a2 + a1) * 0.5;\n\n // TODO: Add static methods to generate translation, rotation, etc.\n // matrices directly\n\n return {\n translation: new this.constructor(1, 0, 0, 1, this.e, this.f),\n rotation: this.constructor.IDENTITY.rotate(phi),\n scale: new this.constructor(scaleX, 0, 0, scaleY, 0, 0),\n rotation0: this.constructor.IDENTITY.rotate(theta)\n };\n};\n\n/**\n * equals\n *\n * @param {Matrix2D} that\n * @returns {Boolean}\n */\nMatrix2D.prototype.equals = function(that) {\n return (\n this.a === that.a &&\n this.b === that.b &&\n this.c === that.c &&\n this.d === that.d &&\n this.e === that.e &&\n this.f === that.f\n );\n};\n\n/**\n * precisionEquals\n *\n * @param {Matrix2D} that\n * @param {Number} precision\n * @returns {Boolean}\n */\nMatrix2D.prototype.precisionEquals = function(that, precision) {\n return (\n Math.abs(this.a - that.a) < precision &&\n Math.abs(this.b - that.b) < precision &&\n Math.abs(this.c - that.c) < precision &&\n Math.abs(this.d - that.d) < precision &&\n Math.abs(this.e - that.e) < precision &&\n Math.abs(this.f - that.f) < precision\n );\n};\n\n/**\n * toString\n *\n * @returns {String}\n */\nMatrix2D.prototype.toString = function() {\n return \"matrix(\" + [this.a, this.b, this.c, this.d, this.e, this.f].join(\",\") + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Matrix2D;\n}\n","// expose classes\n\nexports.Point2D = require('./lib/Point2D');\nexports.Vector2D = require('./lib/Vector2D');\nexports.Matrix2D = require('./lib/Matrix2D');\n","/**\n *\n * Polynomial.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n * \n * contribution {@link http://github.com/Quazistax/kld-polynomial}\n * @copyright 2015 Robert Benko (Quazistax) \n * @license MIT\n */\n\nPolynomial.TOLERANCE = 1e-6;\nPolynomial.ACCURACY = 15;\n\n\n/**\n * interpolate\n *\n * Based on poloint in \"Numerical Recipes in C, 2nd Edition\", pages 109-110\n *\n * @param {Array} xs\n * @param {Array} ys\n * @param {Number} n\n * @param {Number} offset\n * @param {Number} x\n *\n * @returns {{y: Number, dy: Number}}\n */\nPolynomial.interpolate = function(xs, ys, n, offset, x) {\n if ( xs.constructor !== Array || ys.constructor !== Array ) {\n throw new Error(\"Polynomial.interpolate: xs and ys must be arrays\");\n }\n if ( isNaN(n) || isNaN(offset) || isNaN(x) ) {\n throw new Error(\"Polynomial.interpolate: n, offset, and x must be numbers\");\n }\n\n var y = 0;\n var dy = 0;\n var c = new Array(n);\n var d = new Array(n);\n var ns = 0;\n\n var diff = Math.abs(x - xs[offset]);\n\n for ( var i = 0; i < n; i++ ) {\n var dift = Math.abs(x - xs[offset+i]);\n\n if ( dift < diff ) {\n ns = i;\n diff = dift;\n }\n c[i] = d[i] = ys[offset+i];\n }\n\n y = ys[offset+ns];\n ns--;\n\n for ( var m = 1; m < n; m++ ) {\n for ( var i = 0; i < n-m; i++ ) {\n var ho = xs[offset+i] - x;\n var hp = xs[offset+i+m] - x;\n var w = c[i+1]-d[i];\n var den = ho - hp;\n\n if ( den == 0.0 ) {\n throw new Error(\"Unable to interpolate polynomial. Two numbers in n were identical (to within roundoff)\");\n }\n\n den = w / den;\n d[i] = hp*den;\n c[i] = ho*den;\n }\n\n dy = (2*(ns+1) < (n-m)) ? c[ns+1] : d[ns--];\n y += dy;\n }\n\n return { y: y, dy: dy };\n};\n\n\n/**\n * Polynomial\n *\n * @returns {Polynomial}\n */\nfunction Polynomial() {\n this.init( arguments );\n}\n\n\n/**\n * init\n */\nPolynomial.prototype.init = function(coefs) {\n this.coefs = new Array();\n\n for ( var i = coefs.length - 1; i >= 0; i-- )\n this.coefs.push( coefs[i] );\n\n this._variable = \"t\";\n this._s = 0;\n};\n\n\n/**\n * eval\n */\nPolynomial.prototype.eval = function(x) {\n if ( isNaN(x) ) {\n throw new Error(\"Polynomial.eval: parameter must be a number\");\n }\n\n var result = 0;\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n result = result * x + this.coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * add\n */\nPolynomial.prototype.add = function(that) {\n var result = new Polynomial();\n var d1 = this.getDegree();\n var d2 = that.getDegree();\n var dmax = Math.max(d1,d2);\n\n for ( var i = 0; i <= dmax; i++ ) {\n var v1 = (i <= d1) ? this.coefs[i] : 0;\n var v2 = (i <= d2) ? that.coefs[i] : 0;\n\n result.coefs[i] = v1 + v2;\n }\n\n return result;\n};\n\n\n/**\n * multiply\n */\nPolynomial.prototype.multiply = function(that) {\n var result = new Polynomial();\n\n for ( var i = 0; i <= this.getDegree() + that.getDegree(); i++ ) {\n result.coefs.push(0);\n }\n\n for ( var i = 0; i <= this.getDegree(); i++ ) {\n for ( var j = 0; j <= that.getDegree(); j++ ) {\n result.coefs[i+j] += this.coefs[i] * that.coefs[j];\n }\n }\n\n return result;\n};\n\n\n/**\n * divide_scalar\n */\nPolynomial.prototype.divide_scalar = function(scalar) {\n for ( var i = 0; i < this.coefs.length; i++ ) {\n this.coefs[i] /= scalar;\n }\n};\n\n\n/**\n * simplify\n */\nPolynomial.prototype.simplify = function(TOLERANCE) {\n if (TOLERANCE === undefined) TOLERANCE = 1e-12;\n\n for ( var i = this.getDegree(); i >= 0; i-- ) {\n if ( Math.abs( this.coefs[i] ) <= TOLERANCE ) {\n this.coefs.pop();\n }\n else {\n break;\n }\n }\n};\n\n\n/**\n * bisection\n */\nPolynomial.prototype.bisection = function(min, max) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n var result;\n\n if ( Math.abs(minValue) <= Polynomial.TOLERANCE ) {\n result = min;\n }\n else if ( Math.abs(maxValue) <= Polynomial.TOLERANCE ) {\n result = max;\n }\n else if ( minValue * maxValue <= 0 ) {\n var tmp1 = Math.log(max - min);\n var tmp2 = Math.LN10 * Polynomial.ACCURACY;\n var iters = Math.ceil( (tmp1+tmp2) / Math.LN2 );\n\n for ( var i = 0; i < iters; i++ ) {\n result = 0.5 * (min + max);\n var value = this.eval(result);\n\n if ( Math.abs(value) <= Polynomial.TOLERANCE ) {\n break;\n }\n\n if ( value * minValue < 0 ) {\n max = result;\n maxValue = value;\n }\n else {\n min = result;\n minValue = value;\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * toString\n */\nPolynomial.prototype.toString = function() {\n var coefs = new Array();\n var signs = new Array();\n\n for ( var i = this.coefs.length - 1; i >= 0; i-- ) {\n var value = Math.round(this.coefs[i]*1000)/1000;\n //var value = this.coefs[i];\n\n if ( value != 0 ) {\n var sign = ( value < 0 ) ? \" - \" : \" + \";\n\n value = Math.abs(value);\n\n if ( i > 0 ) {\n if ( value == 1 ) {\n value = this._variable;\n }\n else {\n value += this._variable;\n }\n }\n\n if ( i > 1 ) {\n value += \"^\" + i;\n }\n\n signs.push( sign );\n coefs.push( value );\n }\n }\n\n signs[0] = ( signs[0] == \" + \" ) ? \"\" : \"-\";\n\n var result = \"\";\n\n for ( var i = 0; i < coefs.length; i++ ) {\n result += signs[i] + coefs[i];\n }\n\n return result;\n};\n\n\n/**\n * trapezoid\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 137\n */\nPolynomial.prototype.trapezoid = function(min, max, n) {\n if ( isNaN(min) || isNaN(max) || isNaN(n) ) {\n throw new Error(\"Polynomial.trapezoid: parameters must be numbers\");\n }\n\n var range = max - min;\n var TOLERANCE = 1e-7;\n\n if ( n == 1 ) {\n var minValue = this.eval(min);\n var maxValue = this.eval(max);\n\n this._s = 0.5*range*( minValue + maxValue );\n }\n else {\n var it = 1 << (n-2);\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 0; i < it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n this._s = 0.5*(this._s + range*sum/it);\n }\n\n if ( isNaN(this._s) ) {\n throw new Error(\"Polynomial.trapezoid: this._s is NaN\");\n }\n\n return this._s;\n};\n\n\n/**\n * simpson\n *\n * Based on trapzd in \"Numerical Recipes in C, 2nd Edition\", page 139\n */\nPolynomial.prototype.simpson = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.simpson: parameters must be numbers\");\n }\n\n var range = max - min;\n var st = 0.5 * range * ( this.eval(min) + this.eval(max) );\n var t = st;\n var s = 4.0*st/3.0;\n var os = s;\n var ost = st;\n var TOLERANCE = 1e-7;\n\n var it = 1;\n\n for ( var n = 2; n <= 20; n++ ) {\n var delta = range / it;\n var x = min + 0.5*delta;\n var sum = 0;\n\n for ( var i = 1; i <= it; i++ ) {\n sum += this.eval(x);\n x += delta;\n }\n\n t = 0.5 * (t + range * sum / it);\n st = t;\n s = (4.0*st - ost)/3.0;\n\n if ( Math.abs(s-os) < TOLERANCE*Math.abs(os) ) {\n break;\n }\n\n os = s;\n ost = st;\n it <<= 1;\n }\n\n return s;\n};\n\n\n/**\n * romberg\n */\nPolynomial.prototype.romberg = function(min, max) {\n if ( isNaN(min) || isNaN(max) ) {\n throw new Error(\"Polynomial.romberg: parameters must be numbers\");\n }\n\n var MAX = 20;\n var K = 3;\n var TOLERANCE = 1e-6;\n var s = new Array(MAX+1);\n var h = new Array(MAX+1);\n var result = { y: 0, dy: 0 };\n\n h[0] = 1.0;\n\n for ( var j = 1; j <= MAX; j++ ) {\n s[j-1] = this.trapezoid(min, max, j);\n\n if ( j >= K ) {\n result = Polynomial.interpolate(h, s, K, j-K, 0.0);\n if ( Math.abs(result.dy) <= TOLERANCE*result.y) break;\n }\n\n s[j] = s[j-1];\n h[j] = 0.25 * h[j-1];\n }\n\n return result.y;\n};\n\n// getters and setters\n\n/**\n * get degree\n */\nPolynomial.prototype.getDegree = function() {\n return this.coefs.length - 1;\n};\n\n\n/**\n * getDerivative\n */\nPolynomial.prototype.getDerivative = function() {\n var derivative = new Polynomial();\n\n for ( var i = 1; i < this.coefs.length; i++ ) {\n derivative.coefs.push(i*this.coefs[i]);\n }\n\n return derivative;\n};\n\n\n/**\n * getRoots\n */\nPolynomial.prototype.getRoots = function() {\n var result;\n\n this.simplify();\n\n switch ( this.getDegree() ) {\n case 0: result = []; break;\n case 1: result = this.getLinearRoot(); break;\n case 2: result = this.getQuadraticRoots(); break;\n case 3: result = this.getCubicRoots(); break;\n case 4: result = this.getQuarticRoots(); break;\n default:\n result = [];\n }\n\n return result;\n};\n\n\n/**\n * getRootsInInterval\n */\nPolynomial.prototype.getRootsInInterval = function(min, max) {\n var roots = new Array();\n var root;\n\n if ( this.getDegree() == 1 ) {\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // get roots of derivative\n var deriv = this.getDerivative();\n var droots = deriv.getRootsInInterval(min, max);\n\n if ( droots.length > 0 ) {\n // find root on [min, droots[0]]\n root = this.bisection(min, droots[0]);\n\n if ( root != null ) {\n roots.push(root);\n }\n\n // find root on [droots[i],droots[i+1]] for 0 <= i <= count-2\n for ( i = 0; i <= droots.length-2; i++ ) {\n root = this.bisection(droots[i], droots[i+1]);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n\n // find root on [droots[count-1],xmax]\n root = this.bisection(droots[droots.length-1], max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n else {\n // polynomial is monotone on [min,max], has at most one root\n root = this.bisection(min, max);\n\n if ( root != null ) {\n roots.push(root);\n }\n }\n }\n\n return roots;\n};\n\n\n/**\n * getLinearRoot\n */\nPolynomial.prototype.getLinearRoot = function() {\n var result = [];\n var a = this.coefs[1];\n\n if ( a != 0 ) {\n result.push( -this.coefs[0] / a );\n }\n\n return result;\n};\n\n\n/**\n * getQuadraticRoots\n */\nPolynomial.prototype.getQuadraticRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 2 ) {\n var a = this.coefs[2];\n var b = this.coefs[1] / a;\n var c = this.coefs[0] / a;\n var d = b*b - 4*c;\n\n if ( d > 0 ) {\n var e = Math.sqrt(d);\n\n results.push( 0.5 * (-b + e) );\n results.push( 0.5 * (-b - e) );\n }\n else if ( d == 0 ) {\n // really two roots with same value, but we only return one\n results.push( 0.5 * -b );\n }\n }\n\n return results;\n};\n\n\n/**\n * getCubicRoots\n *\n * This code is based on MgcPolynomial.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.geometrictools.com\n */\nPolynomial.prototype.getCubicRoots = function() {\n var results = [];\n\n if ( this.getDegree() == 3 ) {\n var c3 = this.coefs[3];\n var c2 = this.coefs[2] / c3;\n var c1 = this.coefs[1] / c3;\n var c0 = this.coefs[0] / c3;\n\n var a = (3*c1 - c2*c2) / 3;\n var b = (2*c2*c2*c2 - 9*c1*c2 + 27*c0) / 27;\n var offset = c2 / 3;\n var discrim = b*b/4 + a*a*a/27;\n var halfB = b / 2;\n\n var ZEROepsilon = this.zeroErrorEstimate();\n if (Math.abs(discrim) <= ZEROepsilon) {\n discrim = 0;\n }\n\n if ( discrim > 0 ) {\n var e = Math.sqrt(discrim);\n var tmp;\n var root;\n\n tmp = -halfB + e;\n\n if ( tmp >= 0 ) {\n root = Math.pow(tmp, 1/3);\n }\n else {\n root = -Math.pow(-tmp, 1/3);\n }\n\n tmp = -halfB - e;\n\n if ( tmp >= 0 ) {\n root += Math.pow(tmp, 1/3);\n }\n else {\n root -= Math.pow(-tmp, 1/3);\n }\n\n results.push( root - offset );\n }\n else if ( discrim < 0 ) {\n var distance = Math.sqrt(-a/3);\n var angle = Math.atan2( Math.sqrt(-discrim), -halfB) / 3;\n var cos = Math.cos(angle);\n var sin = Math.sin(angle);\n var sqrt3 = Math.sqrt(3);\n\n results.push( 2*distance*cos - offset );\n results.push( -distance * (cos + sqrt3 * sin) - offset);\n results.push( -distance * (cos - sqrt3 * sin) - offset);\n }\n else {\n var tmp;\n\n if ( halfB >= 0 ) {\n tmp = -Math.pow(halfB, 1/3);\n }\n else {\n tmp = Math.pow(-halfB, 1/3);\n }\n\n results.push( 2*tmp - offset );\n // really should return next root twice, but we return only one\n results.push( -tmp - offset );\n }\n }\n\n return results;\n};\n\n\n/**\n * Sign of a number (+1, -1, +0, -0).\n */\nvar sign = function (x) {\n return typeof x === 'number' ? x ? x < 0 ? -1 : 1 : x === x ? x : NaN : NaN;\n};\n\n\n/**\n * Calculates roots of quartic polynomial.
\n * First, derivative roots are found, then used to split quartic polynomial \n * into segments, each containing one root of quartic polynomial.\n * Segments are then passed to newton's method to find roots.\n *\n * @returns {Array} roots\n */\nPolynomial.prototype.getQuarticRoots = function () {\n var results = [];\n\n var n = this.getDegree();\n\n if (n == 4) {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice();\n poly.divide_scalar(poly.coefs[n]);\n\n var ERRF = 1e-15;\n\n if (Math.abs(poly.coefs[0]) < 10 * ERRF * Math.abs(poly.coefs[3])) {\n poly.coefs[0] = 0;\n }\n\n var poly_d = poly.getDerivative();\n var derrt = poly_d.getRoots().sort(function (a, b) { return a - b; });\n var dery = [];\n var nr = derrt.length - 1;\n var i;\n var rb = this.bounds();\n\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n\n var ZEROepsilon = this.zeroErrorEstimate(maxabsX);\n \n for (i = 0; i <= nr; i++) {\n dery.push(poly.eval(derrt[i]));\n }\n\n for (i = 0; i <= nr; i++) {\n if (Math.abs(dery[i]) < ZEROepsilon) {\n dery[i] = 0;\n }\n }\n\n i = 0;\n var dx = Math.max(0.1 * (rb.maxX - rb.minX) / n, ERRF);\n var guesses = [];\n var minmax = [];\n\n if (nr > -1) {\n if (dery[0] != 0) {\n if (sign(dery[0]) != sign(poly.eval(derrt[0] - dx) - dery[0])) {\n guesses.push(derrt[0] - dx);\n minmax.push([rb.minX, derrt[0]]);\n }\n }\n else {\n results.push(derrt[0], derrt[0]);\n i++;\n }\n\n for (; i < nr; i++) {\n if (dery[i + 1] == 0) {\n results.push(derrt[i + 1], derrt[i + 1]);\n i++;\n }\n else if (sign(dery[i]) != sign(dery[i + 1])) {\n guesses.push((derrt[i] + derrt[i + 1]) / 2);\n minmax.push([derrt[i], derrt[i + 1]]);\n }\n }\n if (dery[nr] != 0 && sign(dery[nr]) != sign(poly.eval(derrt[nr] + dx) - dery[nr])) {\n guesses.push(derrt[nr] + dx);\n minmax.push([derrt[nr], rb.maxX]);\n }\n }\n\n var f = function (x) { return poly.eval(x); };\n var df = function (x) { return poly_d.eval(x); };\n\n if (guesses.length > 0) {\n for (i = 0; i < guesses.length; i++) {\n guesses[i] = Polynomial.newton_secant_bisection(guesses[i], f, df, 32, minmax[i][0], minmax[i][1]);\n }\n }\n\n results = results.concat(guesses);\n }\n\n return results;\n};\n\n\n/**\n * Estimate what is the maximum polynomial evaluation error value under which polynomial evaluation could be in fact 0.\n * \n * @returns {Number} \n */\nPolynomial.prototype.zeroErrorEstimate = function (maxabsX) {\n var poly = this;\n var ERRF = 1e-15;\n\n if (typeof maxabsX === 'undefined') {\n var rb = poly.bounds();\n maxabsX = Math.max(Math.abs(rb.minX), Math.abs(rb.maxX));\n }\n\n if (maxabsX < 0.001) {\n return 2*Math.abs(poly.eval(ERRF));\n }\n\n var n = poly.coefs.length - 1;\n var an = poly.coefs[n];\n\n return 10 * ERRF * poly.coefs.reduce(function (m, v, i) {\n var nm = v / an * Math.pow(maxabsX, i);\n return nm > m ? nm : m;\n }, 0);\n}\n\n\n/**\n * Calculates upper Real roots bounds.
\n * Real roots are in interval [negX, posX]. Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_UpperReal_Fujiwara = function () {\n var a = this.coefs;\n var n = a.length - 1;\n var an = a[n];\n\n if (an != 1) {\n a = this.coefs.map(function (v) {\n return v / an;\n });\n }\n\n var b = a.map(function (v, i) {\n return (i < n)\n ? Math.pow(Math.abs((i == 0) ? v / 2 : v), 1 / (n - i))\n : v;\n });\n\n var coefSelectionFunc;\n var find2Max = function (acc, bi, i) {\n if (coefSelectionFunc(i)) {\n if (acc.max < bi) {\n acc.nearmax = acc.max;\n acc.max = bi;\n }\n else if (acc.nearmax < bi) {\n acc.nearmax = bi;\n }\n }\n return acc;\n };\n\n coefSelectionFunc = function (i) { return i < n && a[i] < 0; };\n var max_nearmax_pos = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n coefSelectionFunc = function (i) { return i < n && ((n % 2 == i % 2) ? a[i] < 0 : a[i] > 0); };\n var max_nearmax_neg = b.reduce(find2Max, { max: 0, nearmax: 0 });\n\n return {\n negX: -2 * max_nearmax_neg.max,\n posX: 2 * max_nearmax_pos.max\n };\n};\n\n\n/** \n * Calculates lower Real roots bounds.
\n * There are no Real roots in interval . Determined by Fujiwara method.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ negX: Number, posX: Number }}\n */\nPolynomial.prototype.bounds_LowerReal_Fujiwara = function () {\n var poly = new Polynomial();\n\n poly.coefs = this.coefs.slice().reverse();\n\n var res = poly.bounds_UpperReal_Fujiwara();\n\n res.negX = 1 / res.negX;\n res.posX = 1 / res.posX;\n\n return res;\n};\n\n\n/** \n * Calculates left and right Real roots bounds.
\n * Real roots are in interval [minX, maxX]. Combines Fujiwara lower and upper bounds to get minimal interval.\n * @see {@link http://en.wikipedia.org/wiki/Properties_of_polynomial_roots}\n *\n * @returns {{ minX: Number, maxX: Number }}\n*/\nPolynomial.prototype.bounds = function () {\n var urb = this.bounds_UpperReal_Fujiwara();\n var rb = { minX: urb.negX, maxX: urb.posX };\n\n if (urb.negX === 0 && urb.posX === 0) {\n return rb;\n }\n\n if (urb.negX === 0) {\n rb.minX = this.bounds_LowerReal_Fujiwara().posX;\n }\n else if (urb.posX === 0) {\n rb.maxX = this.bounds_LowerReal_Fujiwara().negX;\n }\n\n if (rb.minX > rb.maxX) {\n //console.log('Polynomial.prototype.bounds: poly has no real roots? or floating point error?');\n rb.minX = rb.maxX = 0;\n }\n\n return rb;\n // TODO: if sure that there are no complex roots \n // (maybe by using Sturm's theorem) use:\n // return this.bounds_Real_Laguerre();\n};\n\n\n/**\n * Newton's (Newton-Raphson) method for finding Real roots on univariate function.
\n * When using bounds, algorithm falls back to secant if newton goes out of range.\n * Bisection is fallback for secant when determined secant is not efficient enough.\n * @see {@link http://en.wikipedia.org/wiki/Newton%27s_method}\n * @see {@link http://en.wikipedia.org/wiki/Secant_method}\n * @see {@link http://en.wikipedia.org/wiki/Bisection_method}\n *\n * @param {Number} x0 - Inital root guess\n * @param {function(x)} f - Function which root we are trying to find\n * @param {function(x)} df - Derivative of function f\n * @param {Number} max_iterations - Maximum number of algorithm iterations\n * @param {Number} [min_x] - Left bound value\n * @param {Number} [max_x] - Right bound value\n * @returns {Number} - root\n */\nPolynomial.newton_secant_bisection = function (x0, f, df, max_iterations, min, max) {\n var x, prev_dfx = 0, dfx, prev_x_ef_correction = 0, x_correction, x_new;\n var v, y_atmin, y_atmax;\n\n x = x0;\n\n var ACCURACY = 14;\n var min_correction_factor = Math.pow(10, -ACCURACY);\n var isBounded = (typeof min === 'number' && typeof max === 'number');\n\n if (isBounded) {\n if (min > max) {\n throw new Error(\"newton root finding: min must be greater than max\");\n }\n\n y_atmin = f(min);\n y_atmax = f(max);\n\n if (sign(y_atmin) == sign(y_atmax)) {\n throw new Error(\"newton root finding: y values of bounds must be of opposite sign\");\n }\n }\n\n var isEnoughCorrection = function () {\n // stop if correction is too small or if correction is in simple loop\n return (Math.abs(x_correction) <= min_correction_factor * Math.abs(x))\n || (prev_x_ef_correction == (x - x_correction) - x);\n };\n\n var i;\n\n for (i = 0; i < max_iterations; i++) {\n dfx = df(x);\n\n if (dfx == 0) {\n if (prev_dfx == 0) {\n // error\n throw new Error(\"newton root finding: df(x) is zero\");\n }\n else {\n // use previous derivation value\n dfx = prev_dfx;\n }\n // or move x a little?\n //dfx = df(x != 0 ? x + x * 1e-15 : 1e-15);\n }\n\n prev_dfx = dfx;\n y = f(x);\n x_correction = y / dfx;\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n\n if (isBounded) {\n if (sign(y) == sign(y_atmax)) {\n max = x;\n y_atmax = y;\n }\n else if (sign(y) == sign(y_atmin)) {\n min = x;\n y_atmin = y;\n }\n else {\n x = x_new;\n break;\n }\n\n if ((x_new < min) || (x_new > max)) {\n if (sign(y_atmin) == sign(y_atmax)) {\n break;\n }\n\n var RATIO_LIMIT = 50;\n var AIMED_BISECT_OFFSET = 0.25; // [0, 0.5)\n var dy = y_atmax - y_atmin;\n var dx = max - min;\n\n if (dy == 0) {\n x_correction = x - (min + dx * 0.5);\n }\n else if (Math.abs(dy / Math.min(y_atmin, y_atmax)) > RATIO_LIMIT) {\n x_correction = x - (min + dx * (0.5 + (Math.abs(y_atmin) < Math.abs(y_atmax) ? -AIMED_BISECT_OFFSET : AIMED_BISECT_OFFSET)));\n }\n else {\n x_correction = x - (min - y_atmin / dy * dx);\n }\n x_new = x - x_correction;\n\n if (isEnoughCorrection()) {\n break;\n }\n }\n }\n\n prev_x_ef_correction = x - x_new;\n x = x_new;\n }\n\n return x;\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = Polynomial;\n}\n","/**\n *\n * SqrtPolynomial.js\n *\n * copyright 2003, 2013 Kevin Lindsey\n *\n */\n\nif (typeof module !== \"undefined\") {\n var Polynomial = require(\"./Polynomial\");\n}\n\n/**\n * class variables\n */\nSqrtPolynomial.VERSION = 1.0;\n\n// setup inheritance\nSqrtPolynomial.prototype = new Polynomial();\nSqrtPolynomial.prototype.constructor = SqrtPolynomial;\nSqrtPolynomial.superclass = Polynomial.prototype;\n\n\n/**\n * SqrtPolynomial\n */\nfunction SqrtPolynomial() {\n this.init( arguments );\n}\n\n\n/**\n * eval\n *\n * @param {Number} x\n * @returns {Number}\n */\nSqrtPolynomial.prototype.eval = function(x) {\n var TOLERANCE = 1e-7;\n var result = SqrtPolynomial.superclass.eval.call(this, x);\n\n // NOTE: May need to change the following. I added these to capture\n // some really small negative values that were being generated by one\n // of my Bezier arcLength functions\n if ( Math.abs(result) < TOLERANCE ) result = 0;\n if ( result < 0 )\n throw new Error(\"SqrtPolynomial.eval: cannot take square root of negative number\");\n\n return Math.sqrt(result);\n};\n\nSqrtPolynomial.prototype.toString = function() {\n var result = SqrtPolynomial.superclass.toString.call(this);\n\n return \"sqrt(\" + result + \")\";\n};\n\nif (typeof module !== \"undefined\") {\n module.exports = SqrtPolynomial;\n}\n","// expose classes\n\nexports.Polynomial = require('./lib/Polynomial');\nexports.SqrtPolynomial = require('./lib/SqrtPolynomial');\n","/* eslint-disable camelcase, eqeqeq, no-labels, space-infix-ops */\n/**\n *\n * Intersection.js\n *\n * copyright 2002, 2013 Kevin Lindsey\n */\n\nimport {Point2D, Vector2D} from \"kld-affine\";\nimport {Polynomial} from \"kld-polynomial\";\n\n/**\n * @memberof module:kld-intersections.Intersection~\n * @param {*} o\n * @returns {boolean}\n */\nfunction isNullish(o) {\n return o === null || o === undefined;\n}\n\n/**\n * closePolygon\n * @memberof module:kld-intersections.Intersection~\n * @param {Array} points\n * @returns {Array}\n */\nfunction closePolygon(points) {\n const copy = points.slice();\n\n copy.push(points[0]);\n\n return copy;\n}\n\n\n/**\n * Intersection\n * @memberof module:kld-intersections\n */\nclass Intersection {\n /**\n * @param {string} status\n * @returns {module:kld-intersections.Intersection}\n */\n constructor(status) {\n this.init(status);\n }\n\n\n /**\n * init\n *\n * @param {string} status\n * @returns {module:kld-intersections.Intersection}\n */\n init(status) {\n this.status = status;\n this.points = [];\n }\n\n\n /**\n * appendPoint\n *\n * @param {module:kld-intersections.Point2D} point\n */\n appendPoint(point) {\n this.points.push(point);\n }\n\n\n /**\n * appendPoints\n *\n * @param {Array} points\n */\n appendPoints(points) {\n this.points = this.points.concat(points);\n }\n}\n\n// static methods\n\n/**\n * intersect\n *\n * @param {module:kld-intersections.IntersectionArgs} shape1\n * @param {module:kld-intersections.IntersectionArgs} shape2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersect = function(shape1, shape2) {\n let result;\n\n if (!isNullish(shape1) && !isNullish(shape2)) {\n if (shape1.name === \"Path\") {\n result = Intersection.intersectPathShape(shape1, shape2);\n }\n else if (shape2.name === \"Path\") {\n result = Intersection.intersectPathShape(shape2, shape1);\n }\n else {\n let method;\n let args;\n\n if (shape1.name < shape2.name) {\n method = \"intersect\" + shape1.name + shape2.name;\n args = shape1.args.concat(shape2.args);\n }\n else {\n method = \"intersect\" + shape2.name + shape1.name;\n args = shape2.args.concat(shape1.args);\n }\n\n if (!(method in Intersection)) {\n throw new Error(\"Intersection not available: \" + method);\n }\n\n result = Intersection[method].apply(null, args);\n }\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n\n return result;\n};\n\n\n/**\n * intersectPathShape\n *\n * @param {module:kld-intersections.IntersectionArgs} path\n * @param {module:kld-intersections.IntersectionArgs} shape\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPathShape = function(path, shape) {\n const result = new Intersection(\"No Intersection\");\n\n for (const segment of path.args) {\n const inter = Intersection.intersect(segment, shape);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier2\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) {\n let a, b;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b2.multiply(-2);\n const c22 = b1.add(a.add(b3));\n\n a = b1.multiply(-2);\n b = b2.multiply(2);\n const c21 = a.add(b);\n\n const c20 = new Point2D(b1.x, b1.y);\n\n // bezout\n a = c12.x*c11.y - c11.x*c12.y;\n b = c22.x*c11.y - c11.x*c22.y;\n const c = c21.x*c11.y - c11.x*c21.y;\n const d = c11.x*(c10.y - c20.y) + c11.y*(-c10.x + c20.x);\n const e = c22.x*c12.y - c12.x*c22.y;\n const f = c21.x*c12.y - c12.x*c21.y;\n const g = c12.x*(c10.y - c20.y) + c12.y*(-c10.x + c20.x);\n\n // determinant\n const poly = new Polynomial(\n -e*e,\n -2*e*f,\n a*b - f*f - 2*e*g,\n a*c - 2*f*g,\n a*d - g*g\n );\n\n const roots = poly.getRoots();\n\n for (const s of roots) {\n if (0 <= s && s <= 1) {\n const xp = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(c22.multiply(s*s).add(c21.multiply(s).add(c20)));\n break checkRoots;\n }\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Bezier3\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @param {module:kld-intersections.Point2D} b4\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) {\n let a, b, c, d;\n const result = new Intersection(\"No Intersection\");\n\n a = a2.multiply(-2);\n const c12 = a1.add(a.add(a3));\n\n a = a1.multiply(-2);\n b = a2.multiply(2);\n const c11 = a.add(b);\n\n const c10 = new Point2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n const c10x2 = c10.x*c10.x;\n const c10y2 = c10.y*c10.y;\n const c11x2 = c11.x*c11.x;\n const c11y2 = c11.y*c11.y;\n const c12x2 = c12.x*c12.x;\n const c12y2 = c12.y*c12.y;\n const c20x2 = c20.x*c20.x;\n const c20y2 = c20.y*c20.y;\n const c21x2 = c21.x*c21.x;\n const c21y2 = c21.y*c21.y;\n const c22x2 = c22.x*c22.x;\n const c22y2 = c22.y*c22.y;\n const c23x2 = c23.x*c23.x;\n const c23y2 = c23.y*c23.y;\n\n const poly = new Polynomial(\n -2*c12.x*c12.y*c23.x*c23.y + c12x2*c23y2 + c12y2*c23x2,\n -2*c12.x*c12.y*c22.x*c23.y - 2*c12.x*c12.y*c22.y*c23.x + 2*c12y2*c22.x*c23.x +\n 2*c12x2*c22.y*c23.y,\n -2*c12.x*c21.x*c12.y*c23.y - 2*c12.x*c12.y*c21.y*c23.x - 2*c12.x*c12.y*c22.x*c22.y +\n 2*c21.x*c12y2*c23.x + c12y2*c22x2 + c12x2*(2*c21.y*c23.y + c22y2),\n 2*c10.x*c12.x*c12.y*c23.y + 2*c10.y*c12.x*c12.y*c23.x + c11.x*c11.y*c12.x*c23.y +\n c11.x*c11.y*c12.y*c23.x - 2*c20.x*c12.x*c12.y*c23.y - 2*c12.x*c20.y*c12.y*c23.x -\n 2*c12.x*c21.x*c12.y*c22.y - 2*c12.x*c12.y*c21.y*c22.x - 2*c10.x*c12y2*c23.x -\n 2*c10.y*c12x2*c23.y + 2*c20.x*c12y2*c23.x + 2*c21.x*c12y2*c22.x -\n c11y2*c12.x*c23.x - c11x2*c12.y*c23.y + c12x2*(2*c20.y*c23.y + 2*c21.y*c22.y),\n 2*c10.x*c12.x*c12.y*c22.y + 2*c10.y*c12.x*c12.y*c22.x + c11.x*c11.y*c12.x*c22.y +\n c11.x*c11.y*c12.y*c22.x - 2*c20.x*c12.x*c12.y*c22.y - 2*c12.x*c20.y*c12.y*c22.x -\n 2*c12.x*c21.x*c12.y*c21.y - 2*c10.x*c12y2*c22.x - 2*c10.y*c12x2*c22.y +\n 2*c20.x*c12y2*c22.x - c11y2*c12.x*c22.x - c11x2*c12.y*c22.y + c21x2*c12y2 +\n c12x2*(2*c20.y*c22.y + c21y2),\n 2*c10.x*c12.x*c12.y*c21.y + 2*c10.y*c12.x*c21.x*c12.y + c11.x*c11.y*c12.x*c21.y +\n c11.x*c11.y*c21.x*c12.y - 2*c20.x*c12.x*c12.y*c21.y - 2*c12.x*c20.y*c21.x*c12.y -\n 2*c10.x*c21.x*c12y2 - 2*c10.y*c12x2*c21.y + 2*c20.x*c21.x*c12y2 -\n c11y2*c12.x*c21.x - c11x2*c12.y*c21.y + 2*c12x2*c20.y*c21.y,\n -2*c10.x*c10.y*c12.x*c12.y - c10.x*c11.x*c11.y*c12.y - c10.y*c11.x*c11.y*c12.x +\n 2*c10.x*c12.x*c20.y*c12.y + 2*c10.y*c20.x*c12.x*c12.y + c11.x*c20.x*c11.y*c12.y +\n c11.x*c11.y*c12.x*c20.y - 2*c20.x*c12.x*c20.y*c12.y - 2*c10.x*c20.x*c12y2 +\n c10.x*c11y2*c12.x + c10.y*c11x2*c12.y - 2*c10.y*c12x2*c20.y -\n c20.x*c11y2*c12.x - c11x2*c20.y*c12.y + c10x2*c12y2 + c10y2*c12x2 +\n c20x2*c12y2 + c12x2*c20y2\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xRoots = new Polynomial(\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n ).getRoots();\n const yRoots = new Polynomial(\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n ).getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Circle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Circle = function(p1, p2, p3, c, r) {\n return Intersection.intersectBezier2Ellipse(p1, p2, p3, c, r, r);\n};\n\n\n/**\n * intersectBezier2Ellipse\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) {\n let a; // temporary variables\n // c2, c1, c0; // coefficients of quadratic\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const roots = new Polynomial(\n ryry*c2.x*c2.x + rxrx*c2.y*c2.y,\n 2*(ryry*c2.x*c1.x + rxrx*c2.y*c1.y),\n ryry*(2*c2.x*c0.x + c1.x*c1.x) + rxrx*(2*c2.y*c0.y+c1.y*c1.y) -\n 2*(ryry*ec.x*c2.x + rxrx*ec.y*c2.y),\n 2*(ryry*c1.x*(c0.x-ec.x) + rxrx*c1.y*(c0.y-ec.y)),\n ryry*(c0.x*c0.x+ec.x*ec.x) + rxrx*(c0.y*c0.y + ec.y*ec.y) -\n 2*(ryry*ec.x*c0.x + rxrx*ec.y*c0.y) - rxrx*ryry\n ).getRoots();\n\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n result.points.push(c2.multiply(t*t).add(c1.multiply(t).add(c0)));\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Line\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) {\n let a; // temporary variables\n // let c2, c1, c0; // coefficients of quadratic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n a = p2.multiply(-2);\n const c2 = p1.add(a.add(p3));\n\n a = p1.multiply(-2);\n const b = p2.multiply(2);\n const c1 = a.add(b);\n\n const c0 = new Point2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // Transform cubic coefficients to line's coordinate system and find roots\n // of cubic\n const roots = new Polynomial(\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p4 = p1.lerp(p2, t);\n const p5 = p2.lerp(p3, t);\n\n const p6 = p4.lerp(p5, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p6\n if (a1.x == a2.x) {\n if (min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p6.x && p6.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n else if (min.x <= p6.x && p6.x <= max.x && min.y <= p6.y && p6.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p6);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Polygon\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Polygon = function(p1, p2, p3, points) {\n return Intersection.intersectBezier2Polyline(p1, p2, p3, closePolygon(points));\n};\n\n\n/**\n * intersectBezier2Polyline\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Polyline = function(p1, p2, p3, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier2Line(p1, p2, p3, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier2Rectangle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier2Line(p1, p2, p3, min, topRight);\n const inter2 = Intersection.intersectBezier2Line(p1, p2, p3, topRight, max);\n const inter3 = Intersection.intersectBezier2Line(p1, p2, p3, max, bottomLeft);\n const inter4 = Intersection.intersectBezier2Line(p1, p2, p3, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Bezier3\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} a3\n * @param {module:kld-intersections.Point2D} a4\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @param {module:kld-intersections.Point2D} b3\n * @param {module:kld-intersections.Point2D} b4\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) {\n let a, b, c, d; // temporary variables\n // c13, c12, c11, c10; // coefficients of cubic\n // c23, c22, c21, c20; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = a1.multiply(-1);\n b = a2.multiply(3);\n c = a3.multiply(-3);\n d = a.add(b.add(c.add(a4)));\n const c13 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(3);\n b = a2.multiply(-6);\n c = a3.multiply(3);\n d = a.add(b.add(c));\n const c12 = new Vector2D(d.x, d.y);\n\n a = a1.multiply(-3);\n b = a2.multiply(3);\n c = a.add(b);\n const c11 = new Vector2D(c.x, c.y);\n\n const c10 = new Vector2D(a1.x, a1.y);\n\n a = b1.multiply(-1);\n b = b2.multiply(3);\n c = b3.multiply(-3);\n d = a.add(b.add(c.add(b4)));\n const c23 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(3);\n b = b2.multiply(-6);\n c = b3.multiply(3);\n d = a.add(b.add(c));\n const c22 = new Vector2D(d.x, d.y);\n\n a = b1.multiply(-3);\n b = b2.multiply(3);\n c = a.add(b);\n const c21 = new Vector2D(c.x, c.y);\n\n const c20 = new Vector2D(b1.x, b1.y);\n\n // bezout\n a = c13.x * c12.y - c12.x * c13.y;\n b = c13.x * c11.y - c11.x * c13.y;\n const c0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const c1 = c21.x * c13.y - c13.x * c21.y;\n const c2 = c22.x * c13.y - c13.x * c22.y;\n const c3 = c23.x * c13.y - c13.x * c23.y;\n d = c13.x * c11.y - c11.x * c13.y;\n const e0 = c13.x * c10.y + c12.x * c11.y - c11.x * c12.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const e1 = c21.x * c13.y - c13.x * c21.y;\n const e2 = c22.x * c13.y - c13.x * c22.y;\n const e3 = c23.x * c13.y - c13.x * c23.y;\n const f0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const f1 = c21.x * c12.y - c12.x * c21.y;\n const f2 = c22.x * c12.y - c12.x * c22.y;\n const f3 = c23.x * c12.y - c12.x * c23.y;\n const g0 = c13.x * c10.y - c10.x * c13.y + c20.x * c13.y - c13.x * c20.y;\n const g1 = c21.x * c13.y - c13.x * c21.y;\n const g2 = c22.x * c13.y - c13.x * c22.y;\n const g3 = c23.x * c13.y - c13.x * c23.y;\n const h0 = c12.x * c10.y - c10.x * c12.y + c20.x * c12.y - c12.x * c20.y;\n const h1 = c21.x * c12.y - c12.x * c21.y;\n const h2 = c22.x * c12.y - c12.x * c22.y;\n const h3 = c23.x * c12.y - c12.x * c23.y;\n const i0 = c11.x * c10.y - c10.x * c11.y + c20.x * c11.y - c11.x * c20.y;\n const i1 = c21.x * c11.y - c11.x * c21.y;\n const i2 = c22.x * c11.y - c11.x * c22.y;\n const i3 = c23.x * c11.y - c11.x * c23.y;\n\n // determinant\n const poly = new Polynomial(\n -c3 * e3 * g3,\n -c3 * e3 * g2 - c3 * e2 * g3 - c2 * e3 * g3,\n -c3 * e3 * g1 - c3 * e2 * g2 - c2 * e3 * g2 - c3 * e1 * g3 - c2 * e2 * g3 - c1 * e3 * g3,\n -c3 * e3 * g0 - c3 * e2 * g1 - c2 * e3 * g1 - c3 * e1 * g2 - c2 * e2 * g2 - c1 * e3 * g2 - c3 * e0 * g3 - c2 * e1 * g3 - c1 * e2 * g3 - c0 * e3 * g3 + b * f3 * g3 + c3 * d * h3 - a * f3 * h3 + a * e3 * i3,\n -c3 * e2 * g0 - c2 * e3 * g0 - c3 * e1 * g1 - c2 * e2 * g1 - c1 * e3 * g1 - c3 * e0 * g2 - c2 * e1 * g2 - c1 * e2 * g2 - c0 * e3 * g2 + b * f3 * g2 - c2 * e0 * g3 - c1 * e1 * g3 - c0 * e2 * g3 + b * f2 * g3 + c3 * d * h2 - a * f3 * h2 + c2 * d * h3 - a * f2 * h3 + a * e3 * i2 + a * e2 * i3,\n -c3 * e1 * g0 - c2 * e2 * g0 - c1 * e3 * g0 - c3 * e0 * g1 - c2 * e1 * g1 - c1 * e2 * g1 - c0 * e3 * g1 + b * f3 * g1 - c2 * e0 * g2 - c1 * e1 * g2 - c0 * e2 * g2 + b * f2 * g2 - c1 * e0 * g3 - c0 * e1 * g3 + b * f1 * g3 + c3 * d * h1 - a * f3 * h1 + c2 * d * h2 - a * f2 * h2 + c1 * d * h3 - a * f1 * h3 + a * e3 * i1 + a * e2 * i2 + a * e1 * i3,\n -c3 * e0 * g0 - c2 * e1 * g0 - c1 * e2 * g0 - c0 * e3 * g0 + b * f3 * g0 - c2 * e0 * g1 - c1 * e1 * g1 - c0 * e2 * g1 + b * f2 * g1 - c1 * e0 * g2 - c0 * e1 * g2 + b * f1 * g2 - c0 * e0 * g3 + b * f0 * g3 + c3 * d * h0 - a * f3 * h0 + c2 * d * h1 - a * f2 * h1 + c1 * d * h2 - a * f1 * h2 + c0 * d * h3 - a * f0 * h3 + a * e3 * i0 + a * e2 * i1 + a * e1 * i2 - b * d * i3 + a * e0 * i3,\n -c2 * e0 * g0 - c1 * e1 * g0 - c0 * e2 * g0 + b * f2 * g0 - c1 * e0 * g1 - c0 * e1 * g1 + b * f1 * g1 - c0 * e0 * g2 + b * f0 * g2 + c2 * d * h0 - a * f2 * h0 + c1 * d * h1 - a * f1 * h1 + c0 * d * h2 - a * f0 * h2 + a * e2 * i0 + a * e1 * i1 - b * d * i2 + a * e0 * i2,\n -c1 * e0 * g0 - c0 * e1 * g0 + b * f1 * g0 - c0 * e0 * g1 + b * f0 * g1 + c1 * d * h0 - a * f1 * h0 + c0 * d * h1 - a * f0 * h1 + a * e1 * i0 - b * d * i1 + a * e0 * i1,\n -c0 * e0 * g0 + b * f0 * g0 + c0 * d * h0 - a * f0 * h0 - b * d * i0 + a * e0 * i0\n );\n poly.simplify();\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const s of roots) {\n const xp = new Polynomial(\n c13.x,\n c12.x,\n c11.x,\n c10.x - c20.x - s*c21.x - s*s*c22.x - s*s*s*c23.x\n );\n xp.simplify();\n const xRoots = xp.getRoots();\n const yp = new Polynomial(\n c13.y,\n c12.y,\n c11.y,\n c10.y - c20.y - s*c21.y - s*s*c22.y - s*s*s*c23.y\n );\n yp.simplify();\n const yRoots = yp.getRoots();\n\n if (xRoots.length > 0 && yRoots.length > 0) {\n const TOLERANCE = 1e-4;\n\n checkRoots:\n for (const xRoot of xRoots) {\n if (0 <= xRoot && xRoot <= 1) {\n for (let k = 0; k < yRoots.length; k++) {\n if (Math.abs(xRoot - yRoots[k]) < TOLERANCE) {\n result.points.push(\n c23.multiply(s*s*s).add(c22.multiply(s*s).add(c21.multiply(s).add(c20)))\n );\n break checkRoots;\n }\n }\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Circle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) {\n return Intersection.intersectBezier3Ellipse(p1, p2, p3, p4, c, r, r);\n};\n\n\n/**\n * intersectBezier3Ellipse\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n const result = new Intersection(\"No Intersection\");\n\n // Calculate the coefficients of cubic polynomial\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n const rxrx = rx*rx;\n const ryry = ry*ry;\n const poly = new Polynomial(\n c3.x*c3.x*ryry + c3.y*c3.y*rxrx,\n 2*(c3.x*c2.x*ryry + c3.y*c2.y*rxrx),\n 2*(c3.x*c1.x*ryry + c3.y*c1.y*rxrx) + c2.x*c2.x*ryry + c2.y*c2.y*rxrx,\n 2*c3.x*ryry*(c0.x - ec.x) + 2*c3.y*rxrx*(c0.y - ec.y) +\n 2*(c2.x*c1.x*ryry + c2.y*c1.y*rxrx),\n 2*c2.x*ryry*(c0.x - ec.x) + 2*c2.y*rxrx*(c0.y - ec.y) +\n c1.x*c1.x*ryry + c1.y*c1.y*rxrx,\n 2*c1.x*ryry*(c0.x - ec.x) + 2*c1.y*rxrx*(c0.y - ec.y),\n c0.x*c0.x*ryry - 2*c0.y*ec.y*rxrx - 2*c0.x*ec.x*ryry +\n c0.y*c0.y*rxrx + ec.x*ec.x*ryry + ec.y*ec.y*rxrx - rxrx*ryry\n );\n const roots = poly.getRootsInInterval(0, 1);\n\n for (const t of roots) {\n result.points.push(\n c3.multiply(t*t*t).add(c2.multiply(t*t).add(c1.multiply(t).add(c0)))\n );\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Line\n *\n * Many thanks to Dan Sunday at SoftSurfer.com. He gave me a very thorough\n * sketch of the algorithm used here. Without his help, I'm not sure when I\n * would have figured out this intersection problem.\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) {\n let a, b, c, d; // temporary variables\n // c3, c2, c1, c0; // coefficients of cubic\n // cl; // c coefficient for normal form of line\n // n; // normal for normal form of line\n const min = a1.min(a2); // used to determine if point is on line segment\n const max = a1.max(a2); // used to determine if point is on line segment\n const result = new Intersection(\"No Intersection\");\n\n // Start with Bezier using Bernstein polynomials for weighting functions:\n // (1-t^3)P1 + 3t(1-t)^2P2 + 3t^2(1-t)P3 + t^3P4\n //\n // Expand and collect terms to form linear combinations of original Bezier\n // controls. This ends up with a vector cubic in t:\n // (-P1+3P2-3P3+P4)t^3 + (3P1-6P2+3P3)t^2 + (-3P1+3P2)t + P1\n // /\\ /\\ /\\ /\\\n // || || || ||\n // c3 c2 c1 c0\n\n // Calculate the coefficients\n a = p1.multiply(-1);\n b = p2.multiply(3);\n c = p3.multiply(-3);\n d = a.add(b.add(c.add(p4)));\n const c3 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(3);\n b = p2.multiply(-6);\n c = p3.multiply(3);\n d = a.add(b.add(c));\n const c2 = new Vector2D(d.x, d.y);\n\n a = p1.multiply(-3);\n b = p2.multiply(3);\n c = a.add(b);\n const c1 = new Vector2D(c.x, c.y);\n\n const c0 = new Vector2D(p1.x, p1.y);\n\n // Convert line to normal form: ax + by + c = 0\n // Find normal to line: negative inverse of original line's slope\n const n = new Vector2D(a1.y - a2.y, a2.x - a1.x);\n\n // Determine new c coefficient\n const cl = a1.x*a2.y - a2.x*a1.y;\n\n // ?Rotate each cubic coefficient using line for new coordinate system?\n // Find roots of rotated cubic\n const roots = new Polynomial(\n n.dot(c3),\n n.dot(c2),\n n.dot(c1),\n n.dot(c0) + cl\n ).getRoots();\n\n // Any roots in closed interval [0,1] are intersections on Bezier, but\n // might not be on the line segment.\n // Find intersections and calculate point coordinates\n for (const t of roots) {\n if (0 <= t && t <= 1) {\n // We're within the Bezier curve\n // Find point on Bezier\n const p5 = p1.lerp(p2, t);\n const p6 = p2.lerp(p3, t);\n const p7 = p3.lerp(p4, t);\n\n const p8 = p5.lerp(p6, t);\n const p9 = p6.lerp(p7, t);\n\n const p10 = p8.lerp(p9, t);\n\n // See if point is on line segment\n // Had to make special cases for vertical and horizontal lines due\n // to slight errors in calculation of p10\n if (a1.x == a2.x) {\n if (min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (a1.y == a2.y) {\n if (min.x <= p10.x && p10.x <= max.x) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n else if (min.x <= p10.x && p10.x <= max.x && min.y <= p10.y && p10.y <= max.y) {\n result.status = \"Intersection\";\n result.appendPoint(p10);\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Polygon\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) {\n return this.intersectBezier3Polyline(p1, p2, p3, p4, closePolygon(points));\n};\n\n\n/**\n * intersectBezier3Polyline\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n const inter = Intersection.intersectBezier3Line(p1, p2, p3, p4, a1, a2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectBezier3Rectangle\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectBezier3Line(p1, p2, p3, p4, min, topRight);\n const inter2 = Intersection.intersectBezier3Line(p1, p2, p3, p4, topRight, max);\n const inter3 = Intersection.intersectBezier3Line(p1, p2, p3, p4, max, bottomLeft);\n const inter4 = Intersection.intersectBezier3Line(p1, p2, p3, p4, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleCircle\n *\n * @param {module:kld-intersections.Point2D} c1\n * @param {number} r1\n * @param {module:kld-intersections.Point2D} c2\n * @param {number} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleCircle = function(c1, r1, c2, r2) {\n let result;\n\n // Determine minimum and maximum radii where circles can intersect\n const r_max = r1 + r2;\n const r_min = Math.abs(r1 - r2);\n\n // Determine actual distance between circle circles\n const c_dist = c1.distanceFrom(c2);\n\n if (c_dist > r_max) {\n result = new Intersection(\"Outside\");\n }\n else if (c_dist < r_min) {\n result = new Intersection(\"Inside\");\n }\n else {\n result = new Intersection(\"Intersection\");\n\n const a = (r1*r1 - r2*r2 + c_dist*c_dist) / (2*c_dist);\n const h = Math.sqrt(r1*r1 - a*a);\n const p = c1.lerp(c2, a/c_dist);\n const b = h / c_dist;\n\n result.points.push(\n new Point2D(\n p.x - b * (c2.y - c1.y),\n p.y + b * (c2.x - c1.x)\n )\n );\n result.points.push(\n new Point2D(\n p.x + b * (c2.y - c1.y),\n p.y - b * (c2.x - c1.x)\n )\n );\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleEllipse\n *\n * @param {module:kld-intersections.Point2D} cc\n * @param {number} r\n * @param {module:kld-intersections.Point2D} ec\n * @param {number} rx\n * @param {number} ry\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) {\n return Intersection.intersectEllipseEllipse(cc, r, r, ec, rx, ry);\n};\n\n\n/**\n * intersectCircleLine\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleLine = function(c, r, a1, a2) {\n let result;\n const a = (a2.x - a1.x) * (a2.x - a1.x) +\n (a2.y - a1.y) * (a2.y - a1.y);\n const b = 2 * ((a2.x - a1.x) * (a1.x - c.x) +\n (a2.y - a1.y) * (a1.y - c.y));\n const cc = c.x*c.x + c.y*c.y + a1.x*a1.x + a1.y*a1.y -\n 2 * (c.x * a1.x + c.y * a1.y) - r*r;\n const deter = b*b - 4*a*cc;\n\n if (deter < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (deter == 0) {\n result = new Intersection(\"Tangent\");\n // NOTE: should calculate this point\n }\n else {\n const e = Math.sqrt(deter);\n const u1 = (-b + e) / (2*a);\n const u2 = (-b - e) / (2*a);\n\n if ((u1 < 0 || u1 > 1) && (u2 < 0 || u2 > 1)) {\n if ((u1 < 0 && u2 < 0) || (u1 > 1 && u2 > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n\n if (0 <= u1 && u1 <= 1) {\n result.points.push(a1.lerp(a2, u1));\n }\n\n if (0 <= u2 && u2 <= 1) {\n result.points.push(a1.lerp(a2, u2));\n }\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectCirclePolygon\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCirclePolygon = function(c, r, points) {\n return this.intersectCirclePolyline(c, r, closePolygon(points));\n};\n\n\n/**\n * intersectCirclePolyline\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCirclePolyline = function(c, r, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n let inter;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points[i];\n const a2 = points[i + 1];\n\n inter = Intersection.intersectCircleLine(c, r, a1, a2);\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectCircleRectangle\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} r\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectCircleRectangle = function(c, r, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectCircleLine(c, r, min, topRight);\n const inter2 = Intersection.intersectCircleLine(c, r, topRight, max);\n const inter3 = Intersection.intersectCircleLine(c, r, max, bottomLeft);\n const inter4 = Intersection.intersectCircleLine(c, r, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n else {\n result.status = inter1.status;\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseEllipse\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {module:kld-intersections.Point2D} c1\n * @param {number} rx1\n * @param {number} ry1\n * @param {module:kld-intersections.Point2D} c2\n * @param {number} rx2\n * @param {number} ry2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) {\n const a = [\n ry1*ry1, 0, rx1*rx1, -2*ry1*ry1*c1.x, -2*rx1*rx1*c1.y,\n ry1*ry1*c1.x*c1.x + rx1*rx1*c1.y*c1.y - rx1*rx1*ry1*ry1\n ];\n const b = [\n ry2*ry2, 0, rx2*rx2, -2*ry2*ry2*c2.x, -2*rx2*rx2*c2.y,\n ry2*ry2*c2.x*c2.x + rx2*rx2*c2.y*c2.y - rx2*rx2*ry2*ry2\n ];\n\n const yPoly = Intersection.bezout(a, b);\n const yRoots = yPoly.getRoots();\n const epsilon = 1e-3;\n const norm0 = (a[0]*a[0] + 2*a[1]*a[1] + a[2]*a[2]) * epsilon;\n const norm1 = (b[0]*b[0] + 2*b[1]*b[1] + b[2]*b[2]) * epsilon;\n const result = new Intersection(\"No Intersection\");\n\n for (let y = 0; y < yRoots.length; y++) {\n const xPoly = new Polynomial(\n a[0],\n a[3] + yRoots[y] * a[1],\n a[5] + yRoots[y] * (a[4] + yRoots[y]*a[2])\n );\n const xRoots = xPoly.getRoots();\n\n for (let x = 0; x < xRoots.length; x++) {\n let tst =\n (a[0]*xRoots[x] + a[1]*yRoots[y] + a[3]) * xRoots[x] +\n (a[2]*yRoots[y] + a[4]) * yRoots[y] + a[5];\n if (Math.abs(tst) < norm0) {\n tst =\n (b[0]*xRoots[x] + b[1]*yRoots[y] + b[3]) * xRoots[x] +\n (b[2]*yRoots[y] + b[4]) * yRoots[y] + b[5];\n if (Math.abs(tst) < norm1) {\n result.appendPoint(new Point2D(xRoots[x], yRoots[y]));\n }\n }\n }\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseLine\n *\n * NOTE: Rotation will need to be added to this function\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseLine = function(c, rx, ry, a1, a2) {\n let result;\n const orign = new Vector2D(a1.x, a1.y);\n const dir = Vector2D.fromPoints(a1, a2);\n const center = new Vector2D(c.x, c.y);\n const diff = orign.subtract(center);\n const mDir = new Vector2D(dir.x/(rx*rx), dir.y/(ry*ry));\n const mDiff = new Vector2D(diff.x/(rx*rx), diff.y/(ry*ry));\n\n const a = dir.dot(mDir);\n const b = dir.dot(mDiff);\n c = diff.dot(mDiff) - 1.0;\n const d = b*b - a*c;\n\n if (d < 0) {\n result = new Intersection(\"Outside\");\n }\n else if (d > 0) {\n const root = Math.sqrt(d); // eslint-disable-line no-shadow\n const t_a = (-b - root) / a;\n const t_b = (-b + root) / a;\n\n if ((t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b)) {\n if ((t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1)) {\n result = new Intersection(\"Outside\");\n }\n else {\n result = new Intersection(\"Inside\");\n }\n }\n else {\n result = new Intersection(\"Intersection\");\n if (0 <= t_a && t_a <= 1) {\n result.appendPoint(a1.lerp(a2, t_a));\n }\n if (0 <= t_b && t_b <= 1) {\n result.appendPoint(a1.lerp(a2, t_b));\n }\n }\n }\n else {\n const t = -b/a;\n\n if (0 <= t && t <= 1) {\n result = new Intersection(\"Intersection\");\n result.appendPoint(a1.lerp(a2, t));\n }\n else {\n result = new Intersection(\"Outside\");\n }\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipsePolygon\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipsePolygon = function(c, rx, ry, points) {\n return this.intersectEllipsePolyline(c, rx, ry, closePolygon(points));\n};\n\n\n/**\n * intersectEllipsePolyline\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipsePolyline = function(c, rx, ry, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectEllipseLine(c, rx, ry, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectEllipseRectangle\n *\n * @param {module:kld-intersections.Point2D} c\n * @param {number} rx\n * @param {number} ry\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectEllipseLine(c, rx, ry, min, topRight);\n const inter2 = Intersection.intersectEllipseLine(c, rx, ry, topRight, max);\n const inter3 = Intersection.intersectEllipseLine(c, rx, ry, max, bottomLeft);\n const inter4 = Intersection.intersectEllipseLine(c, rx, ry, bottomLeft, min);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineLine\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLineLine = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n const ub = ub_t / u_b;\n\n if (0 <= ua && ua <= 1 && 0 <= ub && ub <= 1) {\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else {\n result = new Intersection(\"No Intersection\");\n }\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * intersectLinePolygon\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLinePolygon = function(a1, a2, points) {\n return this.intersectLinePolyline(a1, a2, closePolygon(points));\n};\n\n\n/**\n * intersectLinePolyline\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {Array} points\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLinePolyline = function(a1, a2, points) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points;\n\n for (let i = 0; i < len - 1; i++) {\n const b1 = points[i];\n const b2 = points[i + 1];\n const inter = Intersection.intersectLineLine(a1, a2, b1, b2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectLineRectangle\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectLineRectangle = function(a1, a2, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineLine(min, topRight, a1, a2);\n const inter2 = Intersection.intersectLineLine(topRight, max, a1, a2);\n const inter3 = Intersection.intersectLineLine(max, bottomLeft, a1, a2);\n const inter4 = Intersection.intersectLineLine(bottomLeft, min, a1, a2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolygonPolygon\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonPolygon = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), closePolygon(points2));\n};\n\n\n/**\n * intersectPolygonPolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonPolyline = function(points1, points2) {\n return this.intersectPolylinePolyline(closePolygon(points1), points2);\n};\n\n\n/**\n * intersectPolygonRectangle\n *\n * @param {Array} points\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolygonRectangle = function(points, r1, r2) {\n return this.intersectPolylineRectangle(closePolygon(points), r1, r2);\n};\n\n\n/**\n * intersectPolylinePolyline\n *\n * @param {Array} points1\n * @param {Array} points2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolylinePolyline = function(points1, points2) {\n const result = new Intersection(\"No Intersection\");\n const {length: len} = points1;\n\n for (let i = 0; i < len - 1; i++) {\n const a1 = points1[i];\n const a2 = points1[i + 1];\n const inter = Intersection.intersectLinePolyline(a1, a2, points2);\n\n result.appendPoints(inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectPolylineRectangle\n *\n * @param {Array} points\n * @param {module:kld-intersections.Point2D} r1\n * @param {module:kld-intersections.Point2D} r2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectPolylineRectangle = function(points, r1, r2) {\n const min = r1.min(r2);\n const max = r1.max(r2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLinePolyline(min, topRight, points);\n const inter2 = Intersection.intersectLinePolyline(topRight, max, points);\n const inter3 = Intersection.intersectLinePolyline(max, bottomLeft, points);\n const inter4 = Intersection.intersectLinePolyline(bottomLeft, min, points);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRectangleRectangle\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectRectangleRectangle = function(a1, a2, b1, b2) {\n const min = a1.min(a2);\n const max = a1.max(a2);\n const topRight = new Point2D(max.x, min.y);\n const bottomLeft = new Point2D(min.x, max.y);\n\n const inter1 = Intersection.intersectLineRectangle(min, topRight, b1, b2);\n const inter2 = Intersection.intersectLineRectangle(topRight, max, b1, b2);\n const inter3 = Intersection.intersectLineRectangle(max, bottomLeft, b1, b2);\n const inter4 = Intersection.intersectLineRectangle(bottomLeft, min, b1, b2);\n\n const result = new Intersection(\"No Intersection\");\n\n result.appendPoints(inter1.points);\n result.appendPoints(inter2.points);\n result.appendPoints(inter3.points);\n result.appendPoints(inter4.points);\n\n if (result.points.length > 0) {\n result.status = \"Intersection\";\n }\n\n return result;\n};\n\n\n/**\n * intersectRayRay\n *\n * @param {module:kld-intersections.Point2D} a1\n * @param {module:kld-intersections.Point2D} a2\n * @param {module:kld-intersections.Point2D} b1\n * @param {module:kld-intersections.Point2D} b2\n * @returns {module:kld-intersections.Intersection}\n */\nIntersection.intersectRayRay = function(a1, a2, b1, b2) {\n let result;\n\n const ua_t = (b2.x - b1.x) * (a1.y - b1.y) - (b2.y - b1.y) * (a1.x - b1.x);\n const ub_t = (a2.x - a1.x) * (a1.y - b1.y) - (a2.y - a1.y) * (a1.x - b1.x);\n const u_b = (b2.y - b1.y) * (a2.x - a1.x) - (b2.x - b1.x) * (a2.y - a1.y);\n\n if (u_b != 0) {\n const ua = ua_t / u_b;\n\n result = new Intersection(\"Intersection\");\n result.points.push(\n new Point2D(\n a1.x + ua * (a2.x - a1.x),\n a1.y + ua * (a2.y - a1.y)\n )\n );\n }\n else if (ua_t == 0 || ub_t == 0) {\n result = new Intersection(\"Coincident\");\n }\n else {\n result = new Intersection(\"Parallel\");\n }\n\n return result;\n};\n\n\n/**\n * bezout\n *\n * This code is based on MgcIntr2DElpElp.cpp written by David Eberly. His\n * code along with many other excellent examples are avaiable at his site:\n * http://www.magic-software.com\n *\n * @param {Array} e1\n * @param {Array} e2\n * @returns {external:Polynomial}\n */\nIntersection.bezout = function(e1, e2) {\n const AB = e1[0]*e2[1] - e2[0]*e1[1];\n const AC = e1[0]*e2[2] - e2[0]*e1[2];\n const AD = e1[0]*e2[3] - e2[0]*e1[3];\n const AE = e1[0]*e2[4] - e2[0]*e1[4];\n const AF = e1[0]*e2[5] - e2[0]*e1[5];\n const BC = e1[1]*e2[2] - e2[1]*e1[2];\n const BE = e1[1]*e2[4] - e2[1]*e1[4];\n const BF = e1[1]*e2[5] - e2[1]*e1[5];\n const CD = e1[2]*e2[3] - e2[2]*e1[3];\n const DE = e1[3]*e2[4] - e2[3]*e1[4];\n const DF = e1[3]*e2[5] - e2[3]*e1[5];\n const BFpDE = BF + DE;\n const BEmCD = BE - CD;\n\n return new Polynomial(\n AB*BC - AC*AC,\n AB*BEmCD + AD*BC - 2*AC*AE,\n AB*BFpDE + AD*BEmCD - AE*AE - 2*AC*AF,\n AB*DF + AD*BFpDE - 2*AE*AF,\n AD*DF - AF*AF\n );\n};\n\nexport default Intersection;\n","/**\n *\n * IntersectionArgs.js\n *\n * @copyright 2002, 2017 Kevin Lindsey\n *\n */\n\n/**\n * IntersectionArgs\n * @memberof module:kld-intersections\n */\nclass IntersectionArgs {\n /**\n * @param {string} name\n * @param {Array} args\n * @returns {module:kld-intersections.IntersectionArgs}\n */\n constructor(name, args) {\n this.init(name, args);\n }\n /**\n * init\n *\n * @param {string} name\n * @param {Array} args\n */\n init(name, args) {\n this.name = name;\n this.args = args;\n }\n}\n\nexport default IntersectionArgs;\n","/**\n * Shapes\n *\n * @copyright 2017, Kevin Lindsey\n * @module Shapes\n */\n\nimport {Point2D} from \"kld-affine\";\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\n/**\n * @namespace\n */\nconst Shapes = {};\n\n/**\n * quadraticBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) {\n return new IntersectionArgs(\"Bezier2\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y)\n ]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @param {number} p3x\n * @param {number} p3y\n * @param {number} p4x\n * @param {number} p4y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) {\n return new IntersectionArgs(\"Bezier3\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y),\n new Point2D(p3x, p3y),\n new Point2D(p4x, p4y)\n ]);\n};\n\n\n/**\n * circle\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radius\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.circle = function(centerX, centerY, radius) {\n return new IntersectionArgs(\"Circle\", [\n new Point2D(centerX, centerY),\n radius\n ]);\n};\n\n\n/**\n * ellipse\n *\n * @param {number} centerX\n * @param {number} centerY\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.ellipse = function(centerX, centerY, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [\n new Point2D(centerX, centerY),\n radiusX,\n radiusY\n ]);\n};\n\n\n/**\n * line\n *\n * @param {number} p1x\n * @param {number} p1y\n * @param {number} p2x\n * @param {number} p2y\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.line = function(p1x, p1y, p2x, p2y) {\n return new IntersectionArgs(\"Line\", [\n new Point2D(p1x, p1y),\n new Point2D(p2x, p2y)\n ]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", segments);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} coords\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.polygon = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} coords\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.polyline = function(coords) {\n const points = [];\n\n for (let i = 0; i < coords.length; i += 2) {\n points.push(new Point2D(coords[i], coords[i + 1]));\n }\n\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {number} x\n * @param {number} y\n * @param {number} width\n * @param {number} height\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nShapes.rectangle = function(x, y, width, height) {\n return new IntersectionArgs(\"Rectangle\", [\n new Point2D(x, y),\n new Point2D(x + width, y + height)\n ]);\n};\n\n\nexport default Shapes;\n","/**\n * AffineShapes\n *\n * @copyright 2017, Kevin Lindsey\n * @module AffineShapes\n */\n\nimport IntersectionArgs from \"./IntersectionArgs.js\";\n\n/**\n * @namespace\n */\nconst AffineShapes = {};\n\n/**\n * quadraticBezier\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.quadraticBezier = function(p1, p2, p3) {\n return new IntersectionArgs(\"Bezier2\", [p1, p2, p3]);\n};\n\n\n/**\n * cubicBezier\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @param {module:kld-intersections.Point2D} p3\n * @param {module:kld-intersections.Point2D} p4\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.cubicBezier = function(p1, p2, p3, p4) {\n return new IntersectionArgs(\"Bezier3\", [p1, p2, p3, p4]);\n};\n\n\n/**\n * circle\n *\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radius\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.circle = function(center, radius) {\n return new IntersectionArgs(\"Circle\", [center, radius]);\n};\n\n\n/**\n * ellipse\n *\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.ellipse = function(center, radiusX, radiusY) {\n return new IntersectionArgs(\"Ellipse\", [center, radiusX, radiusY]);\n};\n\n\n/**\n * line\n *\n * @param {module:kld-intersections.Point2D} p1\n * @param {module:kld-intersections.Point2D} p2\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.line = function(p1, p2) {\n return new IntersectionArgs(\"Line\", [p1, p2]);\n};\n\n\n/**\n * path\n *\n * @param {Array} segments\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.path = function(segments) {\n return new IntersectionArgs(\"Path\", [segments]);\n};\n\n\n/**\n * polygon\n *\n * @param {Array} points\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.polygon = function(points) {\n return new IntersectionArgs(\"Polygon\", [points]);\n};\n\n\n/**\n * polyline\n *\n * @param {Array} points\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.polyline = function(points) {\n return new IntersectionArgs(\"Polyline\", [points]);\n};\n\n\n/**\n * rectangle\n *\n * @param {module:kld-intersections.Point2D} topLeft\n * @param {module:kld-intersections.Vector2D} size\n * @returns {module:kld-intersections.IntersectionArgs}\n */\nAffineShapes.rectangle = function(topLeft, size) {\n return new IntersectionArgs(\"Rectangle\", [topLeft, topLeft.add(size)]);\n};\n\n\nexport default AffineShapes;\n","/**\n *\n * IntersectionQuery.js\n *\n * @copyright 2017 Kevin Lindsey\n * @module IntersectionQuery\n */\n\nimport {Vector2D} from \"kld-affine\";\n\n/**\n * @namespace\n */\nconst IntersectionQuery = {};\n\n\n/**\n * pointInCircle\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radius\n * @returns {boolean}\n */\nIntersectionQuery.pointInCircle = function(point, center, radius) {\n const v = Vector2D.fromPoints(center, point);\n\n return v.length() <= radius;\n};\n\n\n/**\n * pointInEllipse\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} center\n * @param {number} radiusX\n * @param {number} radiusY\n * @returns {boolean}\n */\nIntersectionQuery.pointInEllipse = function(point, center, radiusX, radiusY) {\n const len = point.subtract(center);\n\n return (len.x * len.x) / (radiusX * radiusX) + (len.y * len.y) / (radiusY * radiusY) <= 1;\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolyline = function(point, points) {\n const {length: len} = points;\n let counter = 0;\n let xInter;\n\n let p1 = points[0];\n\n for (let i = 1; i <= len; i++) {\n const p2 = points[i % len];\n const minY = Math.min(p1.y, p2.y);\n const maxY = Math.max(p1.y, p2.y);\n const maxX = Math.max(p1.x, p2.x);\n\n if (p1.y !== p2.y && minY < point.y && point.y <= maxY && point.x <= maxX) {\n xInter = (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;\n\n if (p1.x === p2.x || point.x <= xInter) {\n counter++;\n }\n }\n\n p1 = p2;\n }\n\n return (counter % 2 === 1);\n};\n\n\n/**\n * pointInPolyline\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {Array} points\n */\nIntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline;\n\n\n/**\n * pointInRectangle\n *\n * @param {module:kld-intersections.Point2D} point\n * @param {module:kld-intersections.Point2D} topLeft\n * @param {module:kld-intersections.Point2D} bottomRight\n * @returns {boolean}\n */\nIntersectionQuery.pointInRectangle = function(point, topLeft, bottomRight) {\n return (\n topLeft.x <= point.x && point.x < bottomRight.x &&\n topLeft.y <= point.y && point.y < bottomRight.y\n );\n};\n\n\nexport default IntersectionQuery;\n"],"names":["Point2D","x","y","Object","defineProperties","this","value","undefined","writable","enumerable","configurable","prototype","clone","constructor","add","that","subtract","multiply","scalar","divide","equals","precisionEquals","precision","Math","abs","lerp","t","omt","distanceFrom","dx","dy","sqrt","min","max","transform","matrix","a","c","e","b","d","f","toString","module","Vector2D","fromPoints","p1","p2","length","magnitude","dot","cross","determinant","unit","angleBetween","cos","radians","acos","perp","perpendicular","project","percent","setReadonlyProperty","object","property","defineProperty","Matrix2D","IDENTITY","translation","tx","ty","scaling","scale","scalingAt","center","nonUniformScaling","scaleX","scaleY","nonUniformScalingAt","rotation","s","sin","rotationAt","rotationFromVector","vector","xFlip","yFlip","xSkew","tan","ySkew","isIdentity","inverse","det1","idet","det2","det3","translate","scaleAt","scaleNonUniform","scaleNonUniformAt","rotate","rotateAt","cx","cy","rotateFromVector","flipX","flipY","skewX","skewY","isInvertible","getScale","getDecomposition","E","F","G","H","Q","R","a1","atan2","a2","theta","phi","rotation0","join","require","Polynomial","init","arguments","TOLERANCE","ACCURACY","interpolate","xs","ys","n","offset","Array","Error","isNaN","ns","diff","i","dift","m","ho","hp","w","den","coefs","push","_variable","_s","eval","result","d1","getDegree","d2","dmax","v1","v2","j","divide_scalar","simplify","pop","bisection","minValue","maxValue","tmp1","log","tmp2","LN10","iters","ceil","LN2","signs","round","sign","trapezoid","range","it","delta","sum","simpson","st","os","ost","romberg","MAX","h","getDerivative","derivative","getRoots","getLinearRoot","getQuadraticRoots","getCubicRoots","getQuarticRoots","getRootsInInterval","root","roots","droots","results","c3","c2","c1","discrim","halfB","ZEROepsilon","zeroErrorEstimate","tmp","pow","distance","angle","sqrt3","NaN","poly","slice","poly_d","derrt","sort","dery","nr","rb","bounds","maxabsX","minX","maxX","guesses","minmax","df","newton_secant_bisection","concat","an","reduce","v","nm","bounds_UpperReal_Fujiwara","map","coefSelectionFunc","find2Max","acc","bi","nearmax","max_nearmax_pos","negX","posX","bounds_LowerReal_Fujiwara","reverse","res","urb","x0","max_iterations","dfx","x_correction","x_new","y_atmin","y_atmax","prev_dfx","prev_x_ef_correction","min_correction_factor","isBounded","isEnoughCorrection","SqrtPolynomial","VERSION","superclass","call","isNullish","o","closePolygon","points","copy","Intersection","status","point","intersect","shape1","shape2","name","intersectPathShape","method","args","apply","path","shape","segment","inter","appendPoints","intersectBezier2Bezier2","a3","b1","b2","b3","c12","c11","c10","c22","c21","c20","g","xp","xRoots","yp","yRoots","checkRoots","xRoot","k","intersectBezier2Bezier3","b4","c23","c10x2","c10y2","c11x2","c11y2","c12x2","c12y2","c20x2","c20y2","c21x2","c21y2","c22x2","c22y2","c23x2","c23y2","intersectBezier2Circle","p3","r","intersectBezier2Ellipse","ec","rx","ry","c0","rxrx","ryry","intersectBezier2Line","cl","p4","p5","p6","appendPoint","intersectBezier2Polygon","intersectBezier2Polyline","len","intersectBezier2Rectangle","r1","r2","topRight","bottomLeft","inter1","inter2","inter3","inter4","intersectBezier3Bezier3","a4","c13","e0","e1","e2","e3","f0","f1","f2","f3","g0","g1","g2","g3","h0","h1","h2","h3","i0","i1","i2","i3","intersectBezier3Circle","intersectBezier3Ellipse","intersectBezier3Line","p7","p8","p9","p10","intersectBezier3Polygon","intersectBezier3Polyline","intersectBezier3Rectangle","intersectCircleCircle","r_max","r_min","c_dist","p","intersectCircleEllipse","cc","intersectEllipseEllipse","intersectCircleLine","deter","u1","u2","intersectCirclePolygon","intersectCirclePolyline","intersectCircleRectangle","rx1","ry1","rx2","ry2","bezout","norm0","norm1","tst","intersectEllipseLine","orign","dir","mDir","mDiff","t_a","t_b","intersectEllipsePolygon","intersectEllipsePolyline","intersectEllipseRectangle","intersectLineLine","ua_t","ub_t","u_b","ua","ub","intersectLinePolygon","intersectLinePolyline","intersectLineRectangle","intersectPolygonPolygon","points1","points2","intersectPolylinePolyline","intersectPolygonPolyline","intersectPolygonRectangle","intersectPolylineRectangle","intersectRectangleRectangle","intersectRayRay","AB","AC","AD","AE","AF","BC","BE","BF","CD","DE","DF","BFpDE","BEmCD","IntersectionArgs","Shapes","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","centerX","centerY","radius","radiusX","radiusY","segments","coords","width","height","AffineShapes","topLeft","size","IntersectionQuery","xInter","counter","minY","maxY","pointInPolygon","pointInPolyline","pointInRectangle","bottomRight"],"mappings":"2lBAeA,SAASA,EAAQC,EAAGC,GAChBC,OAAOC,iBAAiBC,KAAM,GACrB,CACDC,WAAaC,IAANN,EAAkBA,EAAI,EAC7BO,UAAU,EACVC,YAAY,EACZC,cAAc,KAEb,CACDJ,WAAaC,IAANL,EAAkBA,EAAI,EAC7BM,UAAU,EACVC,YAAY,EACZC,cAAc,KAU1BV,EAAQW,UAAUC,MAAQ,kBACf,IAAIP,KAAKQ,YAAYR,KAAKJ,EAAGI,KAAKH,IAS7CF,EAAQW,UAAUG,IAAM,SAASC,UACtB,IAAIV,KAAKQ,YAAYR,KAAKJ,EAAEc,EAAKd,EAAGI,KAAKH,EAAEa,EAAKb,IAS3DF,EAAQW,UAAUK,SAAW,SAASD,UAC3B,IAAIV,KAAKQ,YAAYR,KAAKJ,EAAEc,EAAKd,EAAGI,KAAKH,EAAEa,EAAKb,IAS3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AAM8C,EAAG9C,GAAK+Q,EAAM/Q,GAAKqd,IAC5BC,KAIRza,EAAKC,SAGDwa,EAAU,GAAM,IAU5BF,EAAkBK,eAAiBL,EAAkBM,gBAWrDN,EAAkBO,iBAAmB,SAAS5M,EAAOmM,EAASU,UAEtDV,EAAQld,GAAK+Q,EAAM/Q,GAAK+Q,EAAM/Q,EAAI4d,EAAY5d,GAC9Ckd,EAAQjd,GAAK8Q,EAAM9Q,GAAK8Q,EAAM9Q,EAAI2d,EAAY3d"} \ No newline at end of file diff --git a/index.js b/index.js index 8e7bf4e..4ce7aba 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,66 @@ +/** + * @module kld-intersections + */ // expose module classes + export {default as Intersection} from "./lib/Intersection.js"; + export {default as IntersectionArgs} from "./lib/IntersectionArgs.js"; + +/** + * @namespace Shapes + * @implements {module:Shapes~Shapes} + */ export {default as Shapes} from "./lib/Shapes.js"; + +/** + * @namespace AffineShapes + * @implements {module:AffineShapes~AffineShapes} + */ export {default as AffineShapes} from "./lib/AffineShapes.js"; + +/** + * @namespace IntersectionQuery + * @implements {module:IntersectionQuery~IntersectionQuery} + */ export {default as IntersectionQuery} from "./lib/IntersectionQuery.js"; -// expose affine module classes -export {Point2D, Vector2D, Matrix2D} from "kld-affine"; +// Expose affine module classes + +/** +* @external Point2D +*/ + +/** +* @external Vector2D +*/ + +/** +* @external Matrix2D +*/ + +/** + * @class Point2D + * @memberof module:kld-intersections + * @implements {external:Point2D} + */ +export {Point2D} from "kld-affine"; + +/** + * @class Vector2D + * @memberof module:kld-intersections + * @implements {external:Vector2D} + */ +export {Vector2D} from "kld-affine"; + +/** + * @class Matrix2D + * @memberof module:kld-intersections + * @implements {external:Matrix2D} + */ +export {Matrix2D} from "kld-affine"; + + +/** +* @external Polynomial +*/ diff --git a/lib/AffineShapes.js b/lib/AffineShapes.js index b6cb8e9..67ef25f 100644 --- a/lib/AffineShapes.js +++ b/lib/AffineShapes.js @@ -2,19 +2,22 @@ * AffineShapes * * @copyright 2017, Kevin Lindsey + * @module AffineShapes */ import IntersectionArgs from "./IntersectionArgs.js"; +/** + * @namespace + */ const AffineShapes = {}; /** * quadraticBezier - * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.quadraticBezier = function(p1, p2, p3) { return new IntersectionArgs("Bezier2", [p1, p2, p3]); @@ -24,11 +27,11 @@ AffineShapes.quadraticBezier = function(p1, p2, p3) { /** * cubicBezier * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.cubicBezier = function(p1, p2, p3, p4) { return new IntersectionArgs("Bezier3", [p1, p2, p3, p4]); @@ -38,9 +41,9 @@ AffineShapes.cubicBezier = function(p1, p2, p3, p4) { /** * circle * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.circle = function(center, radius) { return new IntersectionArgs("Circle", [center, radius]); @@ -50,10 +53,10 @@ AffineShapes.circle = function(center, radius) { /** * ellipse * - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.ellipse = function(center, radiusX, radiusY) { return new IntersectionArgs("Ellipse", [center, radiusX, radiusY]); @@ -63,9 +66,9 @@ AffineShapes.ellipse = function(center, radiusX, radiusY) { /** * line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.line = function(p1, p2) { return new IntersectionArgs("Line", [p1, p2]); @@ -75,8 +78,8 @@ AffineShapes.line = function(p1, p2) { /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.path = function(segments) { return new IntersectionArgs("Path", [segments]); @@ -86,8 +89,8 @@ AffineShapes.path = function(segments) { /** * polygon * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.polygon = function(points) { return new IntersectionArgs("Polygon", [points]); @@ -97,8 +100,8 @@ AffineShapes.polygon = function(points) { /** * polyline * - * @param {Array} points - * @returns {IntersectionArgs} + * @param {Array} points + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.polyline = function(points) { return new IntersectionArgs("Polyline", [points]); @@ -108,9 +111,9 @@ AffineShapes.polyline = function(points) { /** * rectangle * - * @param {Point2D} topLeft - * @param {Vector2D} size - * @returns {IntersectionArgs} + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Vector2D} size + * @returns {module:kld-intersections.IntersectionArgs} */ AffineShapes.rectangle = function(topLeft, size) { return new IntersectionArgs("Rectangle", [topLeft, topLeft.add(size)]); diff --git a/lib/Intersection.js b/lib/Intersection.js index a11db67..cd86f2c 100644 --- a/lib/Intersection.js +++ b/lib/Intersection.js @@ -4,14 +4,13 @@ * Intersection.js * * copyright 2002, 2013 Kevin Lindsey - * */ import {Point2D, Vector2D} from "kld-affine"; import {Polynomial} from "kld-polynomial"; /** - * + * @memberof module:kld-intersections.Intersection~ * @param {*} o * @returns {boolean} */ @@ -21,9 +20,9 @@ function isNullish(o) { /** * closePolygon - * - * @param {Array} points - * @returns {Array} + * @memberof module:kld-intersections.Intersection~ + * @param {Array} points + * @returns {Array} */ function closePolygon(points) { const copy = points.slice(); @@ -35,11 +34,13 @@ function closePolygon(points) { /** - * Intersection + * Intersection + * @memberof module:kld-intersections */ class Intersection { /** * @param {string} status + * @returns {module:kld-intersections.Intersection} */ constructor(status) { this.init(status); @@ -50,7 +51,7 @@ class Intersection { * init * * @param {string} status - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ init(status) { this.status = status; @@ -61,7 +62,7 @@ class Intersection { /** * appendPoint * - * @param {Point2D} point + * @param {module:kld-intersections.Point2D} point */ appendPoint(point) { this.points.push(point); @@ -71,7 +72,7 @@ class Intersection { /** * appendPoints * - * @param {Array} points + * @param {Array} points */ appendPoints(points) { this.points = this.points.concat(points); @@ -83,9 +84,9 @@ class Intersection { /** * intersect * - * @param {IntersectionArgs} shape1 - * @param {IntersectionArgs} shape2 - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} shape1 + * @param {module:kld-intersections.IntersectionArgs} shape2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersect = function(shape1, shape2) { let result; @@ -128,9 +129,9 @@ Intersection.intersect = function(shape1, shape2) { /** * intersectPathShape * - * @param {IntersectionArgs} path - * @param {IntersectionArgs} shape - * @returns {Intersection} + * @param {module:kld-intersections.IntersectionArgs} path + * @param {module:kld-intersections.IntersectionArgs} shape + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPathShape = function(path, shape) { const result = new Intersection("No Intersection"); @@ -152,13 +153,13 @@ Intersection.intersectPathShape = function(path, shape) { /** * intersectBezier2Bezier2 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) { let a, b; @@ -248,14 +249,14 @@ Intersection.intersectBezier2Bezier2 = function(a1, a2, a3, b1, b2, b3) { /** * intersectBezier2Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) { let a, b, c, d; @@ -375,12 +376,12 @@ Intersection.intersectBezier2Bezier3 = function(a1, a2, a3, b1, b2, b3, b4) { /** * intersectBezier2Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Circle = function(p1, p2, p3, c, r) { return Intersection.intersectBezier2Ellipse(p1, p2, p3, c, r, r); @@ -390,13 +391,13 @@ Intersection.intersectBezier2Circle = function(p1, p2, p3, c, r) { /** * intersectBezier2Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) { let a; // temporary variables @@ -441,12 +442,12 @@ Intersection.intersectBezier2Ellipse = function(p1, p2, p3, ec, rx, ry) { /** * intersectBezier2Line * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) { let a; // temporary variables @@ -522,11 +523,11 @@ Intersection.intersectBezier2Line = function(p1, p2, p3, a1, a2) { /** * intersectBezier2Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Polygon = function(p1, p2, p3, points) { return Intersection.intersectBezier2Polyline(p1, p2, p3, closePolygon(points)); @@ -536,11 +537,11 @@ Intersection.intersectBezier2Polygon = function(p1, p2, p3, points) { /** * intersectBezier2Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Polyline = function(p1, p2, p3, points) { const result = new Intersection("No Intersection"); @@ -565,12 +566,12 @@ Intersection.intersectBezier2Polyline = function(p1, p2, p3, points) { /** * intersectBezier2Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) { const min = r1.min(r2); @@ -601,15 +602,15 @@ Intersection.intersectBezier2Rectangle = function(p1, p2, p3, r1, r2) { /** * intersectBezier3Bezier3 * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} a3 - * @param {Point2D} a4 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @param {Point2D} b3 - * @param {Point2D} b4 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} a3 + * @param {module:kld-intersections.Point2D} a4 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @param {module:kld-intersections.Point2D} b3 + * @param {module:kld-intersections.Point2D} b4 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) { let a, b, c, d; // temporary variables @@ -749,13 +750,13 @@ Intersection.intersectBezier3Bezier3 = function(a1, a2, a3, a4, b1, b2, b3, b4) /** * intersectBezier3Circle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) { return Intersection.intersectBezier3Ellipse(p1, p2, p3, p4, c, r, r); @@ -765,14 +766,14 @@ Intersection.intersectBezier3Circle = function(p1, p2, p3, p4, c, r) { /** * intersectBezier3Ellipse * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) { let a, b, c, d; // temporary variables @@ -836,13 +837,13 @@ Intersection.intersectBezier3Ellipse = function(p1, p2, p3, p4, ec, rx, ry) { * sketch of the algorithm used here. Without his help, I'm not sure when I * would have figured out this intersection problem. * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) { let a, b, c, d; // temporary variables @@ -944,12 +945,12 @@ Intersection.intersectBezier3Line = function(p1, p2, p3, p4, a1, a2) { /** * intersectBezier3Polygon * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) { return this.intersectBezier3Polyline(p1, p2, p3, p4, closePolygon(points)); @@ -959,12 +960,12 @@ Intersection.intersectBezier3Polygon = function(p1, p2, p3, p4, points) { /** * intersectBezier3Polyline * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) { const result = new Intersection("No Intersection"); @@ -989,13 +990,13 @@ Intersection.intersectBezier3Polyline = function(p1, p2, p3, p4, points) { /** * intersectBezier3Rectangle * - * @param {Point2D} p1 - * @param {Point2D} p2 - * @param {Point2D} p3 - * @param {Point2D} p4 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} p1 + * @param {module:kld-intersections.Point2D} p2 + * @param {module:kld-intersections.Point2D} p3 + * @param {module:kld-intersections.Point2D} p4 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) { const min = r1.min(r2); @@ -1026,11 +1027,11 @@ Intersection.intersectBezier3Rectangle = function(p1, p2, p3, p4, r1, r2) { /** * intersectCircleCircle * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} r1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} r2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCircleCircle = function(c1, r1, c2, r2) { let result; @@ -1077,12 +1078,12 @@ Intersection.intersectCircleCircle = function(c1, r1, c2, r2) { /** * intersectCircleEllipse * - * @param {Point2D} cc + * @param {module:kld-intersections.Point2D} cc * @param {number} r - * @param {Point2D} ec + * @param {module:kld-intersections.Point2D} ec * @param {number} rx * @param {number} ry - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) { return Intersection.intersectEllipseEllipse(cc, r, r, ec, rx, ry); @@ -1092,11 +1093,11 @@ Intersection.intersectCircleEllipse = function(cc, r, ec, rx, ry) { /** * intersectCircleLine * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCircleLine = function(c, r, a1, a2) { let result; @@ -1148,10 +1149,10 @@ Intersection.intersectCircleLine = function(c, r, a1, a2) { /** * intersectCirclePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCirclePolygon = function(c, r, points) { return this.intersectCirclePolyline(c, r, closePolygon(points)); @@ -1161,10 +1162,10 @@ Intersection.intersectCirclePolygon = function(c, r, points) { /** * intersectCirclePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCirclePolyline = function(c, r, points) { const result = new Intersection("No Intersection"); @@ -1193,11 +1194,11 @@ Intersection.intersectCirclePolyline = function(c, r, points) { /** * intersectCircleRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} r - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectCircleRectangle = function(c, r, r1, r2) { const min = r1.min(r2); @@ -1237,13 +1238,13 @@ Intersection.intersectCircleRectangle = function(c, r, r1, r2) { * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c1 + * @param {module:kld-intersections.Point2D} c1 * @param {number} rx1 * @param {number} ry1 - * @param {Point2D} c2 + * @param {module:kld-intersections.Point2D} c2 * @param {number} rx2 * @param {number} ry2 - * @returns {Intersection} + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) { const a = [ @@ -1298,12 +1299,12 @@ Intersection.intersectEllipseEllipse = function(c1, rx1, ry1, c2, rx2, ry2) { * * NOTE: Rotation will need to be added to this function * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} a1 - * @param {Point2D} a2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectEllipseLine = function(c, rx, ry, a1, a2) { let result; @@ -1364,11 +1365,11 @@ Intersection.intersectEllipseLine = function(c, rx, ry, a1, a2) { /** * intersectEllipsePolygon * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectEllipsePolygon = function(c, rx, ry, points) { return this.intersectEllipsePolyline(c, rx, ry, closePolygon(points)); @@ -1378,11 +1379,11 @@ Intersection.intersectEllipsePolygon = function(c, rx, ry, points) { /** * intersectEllipsePolyline * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Array} points - * @returns {Intersection} + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectEllipsePolyline = function(c, rx, ry, points) { const result = new Intersection("No Intersection"); @@ -1407,12 +1408,12 @@ Intersection.intersectEllipsePolyline = function(c, rx, ry, points) { /** * intersectEllipseRectangle * - * @param {Point2D} c + * @param {module:kld-intersections.Point2D} c * @param {number} rx * @param {number} ry - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) { const min = r1.min(r2); @@ -1443,11 +1444,11 @@ Intersection.intersectEllipseRectangle = function(c, rx, ry, r1, r2) { /** * intersectLineLine * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectLineLine = function(a1, a2, b1, b2) { let result; @@ -1487,10 +1488,10 @@ Intersection.intersectLineLine = function(a1, a2, b1, b2) { /** * intersectLinePolygon * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectLinePolygon = function(a1, a2, points) { return this.intersectLinePolyline(a1, a2, closePolygon(points)); @@ -1500,10 +1501,10 @@ Intersection.intersectLinePolygon = function(a1, a2, points) { /** * intersectLinePolyline * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Array} points - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {Array} points + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectLinePolyline = function(a1, a2, points) { const result = new Intersection("No Intersection"); @@ -1528,11 +1529,11 @@ Intersection.intersectLinePolyline = function(a1, a2, points) { /** * intersectLineRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectLineRectangle = function(a1, a2, r1, r2) { const min = r1.min(r2); @@ -1563,9 +1564,9 @@ Intersection.intersectLineRectangle = function(a1, a2, r1, r2) { /** * intersectPolygonPolygon * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPolygonPolygon = function(points1, points2) { return this.intersectPolylinePolyline(closePolygon(points1), closePolygon(points2)); @@ -1575,9 +1576,9 @@ Intersection.intersectPolygonPolygon = function(points1, points2) { /** * intersectPolygonPolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPolygonPolyline = function(points1, points2) { return this.intersectPolylinePolyline(closePolygon(points1), points2); @@ -1587,10 +1588,10 @@ Intersection.intersectPolygonPolyline = function(points1, points2) { /** * intersectPolygonRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPolygonRectangle = function(points, r1, r2) { return this.intersectPolylineRectangle(closePolygon(points), r1, r2); @@ -1600,9 +1601,9 @@ Intersection.intersectPolygonRectangle = function(points, r1, r2) { /** * intersectPolylinePolyline * - * @param {Array} points1 - * @param {Array} points2 - * @returns {Intersection} + * @param {Array} points1 + * @param {Array} points2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPolylinePolyline = function(points1, points2) { const result = new Intersection("No Intersection"); @@ -1627,10 +1628,10 @@ Intersection.intersectPolylinePolyline = function(points1, points2) { /** * intersectPolylineRectangle * - * @param {Array} points - * @param {Point2D} r1 - * @param {Point2D} r2 - * @returns {Intersection} + * @param {Array} points + * @param {module:kld-intersections.Point2D} r1 + * @param {module:kld-intersections.Point2D} r2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectPolylineRectangle = function(points, r1, r2) { const min = r1.min(r2); @@ -1661,11 +1662,11 @@ Intersection.intersectPolylineRectangle = function(points, r1, r2) { /** * intersectRectangleRectangle * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectRectangleRectangle = function(a1, a2, b1, b2) { const min = a1.min(a2); @@ -1696,11 +1697,11 @@ Intersection.intersectRectangleRectangle = function(a1, a2, b1, b2) { /** * intersectRayRay * - * @param {Point2D} a1 - * @param {Point2D} a2 - * @param {Point2D} b1 - * @param {Point2D} b2 - * @returns {Intersection} + * @param {module:kld-intersections.Point2D} a1 + * @param {module:kld-intersections.Point2D} a2 + * @param {module:kld-intersections.Point2D} b1 + * @param {module:kld-intersections.Point2D} b2 + * @returns {module:kld-intersections.Intersection} */ Intersection.intersectRayRay = function(a1, a2, b1, b2) { let result; @@ -1738,9 +1739,9 @@ Intersection.intersectRayRay = function(a1, a2, b1, b2) { * code along with many other excellent examples are avaiable at his site: * http://www.magic-software.com * - * @param {Array} e1 - * @param {Array} e2 - * @returns {Polynomial} + * @param {Array} e1 + * @param {Array} e2 + * @returns {external:Polynomial} */ Intersection.bezout = function(e1, e2) { const AB = e1[0]*e2[1] - e2[0]*e1[1]; diff --git a/lib/IntersectionArgs.js b/lib/IntersectionArgs.js index 13368db..ffeee69 100644 --- a/lib/IntersectionArgs.js +++ b/lib/IntersectionArgs.js @@ -8,13 +8,13 @@ /** * IntersectionArgs - * + * @memberof module:kld-intersections */ class IntersectionArgs { /** * @param {string} name - * @param {Array} args - * @returns {IntersectionArgs} + * @param {Array} args + * @returns {module:kld-intersections.IntersectionArgs} */ constructor(name, args) { this.init(name, args); @@ -23,7 +23,7 @@ class IntersectionArgs { * init * * @param {string} name - * @param {Array} args + * @param {Array} args */ init(name, args) { this.name = name; diff --git a/lib/IntersectionQuery.js b/lib/IntersectionQuery.js index fef841c..ea2c814 100644 --- a/lib/IntersectionQuery.js +++ b/lib/IntersectionQuery.js @@ -3,13 +3,13 @@ * IntersectionQuery.js * * @copyright 2017 Kevin Lindsey - * + * @module IntersectionQuery */ import {Vector2D} from "kld-affine"; /** - * + * @namespace */ const IntersectionQuery = {}; @@ -17,8 +17,8 @@ const IntersectionQuery = {}; /** * pointInCircle * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radius * @returns {boolean} */ @@ -32,8 +32,8 @@ IntersectionQuery.pointInCircle = function(point, center, radius) { /** * pointInEllipse * - * @param {Point2D} point - * @param {Point2D} center + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} center * @param {number} radiusX * @param {number} radiusY * @returns {boolean} @@ -48,8 +48,8 @@ IntersectionQuery.pointInEllipse = function(point, center, radiusX, radiusY) { /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ IntersectionQuery.pointInPolyline = function(point, points) { const {length: len} = points; @@ -82,8 +82,8 @@ IntersectionQuery.pointInPolyline = function(point, points) { /** * pointInPolyline * - * @param {Point2D} point - * @param {Array} points + * @param {module:kld-intersections.Point2D} point + * @param {Array} points */ IntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline; @@ -91,9 +91,9 @@ IntersectionQuery.pointInPolygon = IntersectionQuery.pointInPolyline; /** * pointInRectangle * - * @param {Point2D} point - * @param {Point2D} topLeft - * @param {Point2D} bottomRight + * @param {module:kld-intersections.Point2D} point + * @param {module:kld-intersections.Point2D} topLeft + * @param {module:kld-intersections.Point2D} bottomRight * @returns {boolean} */ IntersectionQuery.pointInRectangle = function(point, topLeft, bottomRight) { diff --git a/lib/Shapes.js b/lib/Shapes.js index d81f92d..66f9ae9 100644 --- a/lib/Shapes.js +++ b/lib/Shapes.js @@ -2,12 +2,16 @@ * Shapes * * @copyright 2017, Kevin Lindsey + * @module Shapes */ import {Point2D} from "kld-affine"; import IntersectionArgs from "./IntersectionArgs.js"; +/** + * @namespace + */ const Shapes = {}; /** @@ -19,7 +23,7 @@ const Shapes = {}; * @param {number} p2y * @param {number} p3x * @param {number} p3y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) { return new IntersectionArgs("Bezier2", [ @@ -41,7 +45,7 @@ Shapes.quadraticBezier = function(p1x, p1y, p2x, p2y, p3x, p3y) { * @param {number} p3y * @param {number} p4x * @param {number} p4y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) { return new IntersectionArgs("Bezier3", [ @@ -59,7 +63,7 @@ Shapes.cubicBezier = function(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y) { * @param {number} centerX * @param {number} centerY * @param {number} radius - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.circle = function(centerX, centerY, radius) { return new IntersectionArgs("Circle", [ @@ -76,7 +80,7 @@ Shapes.circle = function(centerX, centerY, radius) { * @param {number} centerY * @param {number} radiusX * @param {number} radiusY - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.ellipse = function(centerX, centerY, radiusX, radiusY) { return new IntersectionArgs("Ellipse", [ @@ -94,7 +98,7 @@ Shapes.ellipse = function(centerX, centerY, radiusX, radiusY) { * @param {number} p1y * @param {number} p2x * @param {number} p2y - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.line = function(p1x, p1y, p2x, p2y) { return new IntersectionArgs("Line", [ @@ -107,8 +111,8 @@ Shapes.line = function(p1x, p1y, p2x, p2y) { /** * path * - * @param {Array} segments - * @returns {IntersectionArgs} + * @param {Array} segments + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.path = function(segments) { return new IntersectionArgs("Path", segments); @@ -119,7 +123,7 @@ Shapes.path = function(segments) { * polygon * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.polygon = function(coords) { const points = []; @@ -136,7 +140,7 @@ Shapes.polygon = function(coords) { * polyline * * @param {Array} coords - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.polyline = function(coords) { const points = []; @@ -156,7 +160,7 @@ Shapes.polyline = function(coords) { * @param {number} y * @param {number} width * @param {number} height - * @returns {IntersectionArgs} + * @returns {module:kld-intersections.IntersectionArgs} */ Shapes.rectangle = function(x, y, width, height) { return new IntersectionArgs("Rectangle", [