igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
1,192 lines (1,191 loc) • 39.1 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { Base, Point_$type, Number_$type, Boolean_$type, typeCast, fromEnum, markType, PointUtil } from "./type";
import { Rect } from "./Rect";
import { BezierSegment } from "./BezierSegment";
import { PolyBezierSegment } from "./PolyBezierSegment";
import { List$1 } from "./List$1";
import { Tuple$2 } from "./Tuple$2";
import { PolyLineSegment } from "./PolyLineSegment";
import { ArcCenterInfo } from "./ArcCenterInfo";
import { ArcSegment } from "./ArcSegment";
import { Size } from "./Size";
import { MathUtil } from "./MathUtil";
import { LineSegment } from "./LineSegment";
import { PathGeometry } from "./PathGeometry";
import { LineGeometry } from "./LineGeometry";
import { RectangleGeometry } from "./RectangleGeometry";
import { EllipseGeometry } from "./EllipseGeometry";
import { isNaN_, isInfinity } from "./number";
/**
* @hidden
*/
var CoreGeometryUtil = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(CoreGeometryUtil, _super);
function CoreGeometryUtil() {
return _super !== null && _super.apply(this, arguments) || this;
}
CoreGeometryUtil.q = function (a, b, c) {
var d = b.x;
var e = b.y;
var f = c.x;
var g = c.y;
var h = a.x;
var i = a.y;
var j = f - d;
var k = g - e;
var l = j * j + k * k;
if (l == 0) {
return (h - d) * (h - d) + (i - e) * (i - e);
}
var m = ((h - d) * j + (i - e) * k) / l;
m = m < 0 ? 0 : (m > 1 ? 1 : m);
var n = d + j * m;
var o = e + k * m;
var p = (n - h) * (n - h) + (o - i) * (o - i);
return p;
};
CoreGeometryUtil.z = function (a, b, c) {
var d = (b.y <= a.y && c.y > a.y) || (c.y <= a.y && b.y > a.y);
if (d) {
var e = (c.x - b.x) / (c.y - b.y);
var f = (a.y - b.y);
var g = e * f;
var h = b.x + g;
if (a.x < h) {
if (c.y > b.y) {
return 1;
}
else {
return -1;
}
}
}
return 0;
};
CoreGeometryUtil.c = function (a, b) {
var c = (b.top <= a.y && b.bottom > a.y) && (b.left >= a.x || b.right >= a.x);
return c;
};
CoreGeometryUtil.w = function (a, b, c) {
var d = b;
var e = c.e;
var f = c.f;
var g = c.g;
var h = CoreGeometryUtil.ao(d, e, f, g);
if (!CoreGeometryUtil.c(a, h)) {
return 0;
}
var i = CoreGeometryUtil.an(d, e, f, g);
if (!CoreGeometryUtil.c(a, i)) {
return 0;
}
return CoreGeometryUtil.x(a, d, e, f, g);
};
CoreGeometryUtil.aa = function (a, b, c) {
if (c.b == null || c.b.count < 3) {
return 0;
}
var d = c.b.count;
var e = b;
var f = b;
var g = b;
var h = b;
var i = 0;
var j = 0;
while (i < d) {
if (i + 1 < d && i + 2 < d) {
f = c.b._inner[i];
g = c.b._inner[i + 1];
h = c.b._inner[i + 2];
var k = CoreGeometryUtil.ao(e, f, g, h);
if (CoreGeometryUtil.c(a, k)) {
var l = CoreGeometryUtil.an(e, f, g, h);
if (CoreGeometryUtil.c(a, l)) {
j += CoreGeometryUtil.x(a, e, f, h, h);
}
}
e = h;
}
i = i + 3;
}
return j;
};
CoreGeometryUtil.x = function (a, b, c, d, e) {
return CoreGeometryUtil.ad(a, b, c, d, e, 1, 0);
};
CoreGeometryUtil.ao = function (a, b, c, d) {
var e = new List$1(Point_$type, 0);
e.add(a);
e.add(b);
e.add(c);
e.add(d);
var f = 1.7976931348623157E+308;
var g = 1.7976931348623157E+308;
var h = -1.7976931348623157E+308;
var i = -1.7976931348623157E+308;
for (var j = 0; j < e.count; j++) {
var k = e._inner[j];
f = k.x < f ? k.x : f;
h = k.x > h ? k.x : h;
g = k.y < g ? k.y : g;
i = k.y > i ? k.y : i;
}
return new Rect(0, f, g, h - f, i - g);
};
CoreGeometryUtil.an = function (a, b, c, d) {
var e = new List$1(Point_$type, 0);
e.add(a);
e.add(d);
var f = CoreGeometryUtil.n(a.x, b.x, c.x, d.x);
for (var g = 0; g < f.count; g++) {
if (f._inner[g] >= 0 && f._inner[g] <= 1) {
e.add(CoreGeometryUtil.ak(a, b, c, d, f._inner[g]));
}
}
var h = CoreGeometryUtil.n(a.y, b.y, c.y, d.y);
for (var i = 0; i < h.count; i++) {
if (h._inner[i] >= 0 && h._inner[i] <= 1) {
e.add(CoreGeometryUtil.ak(a, b, c, d, h._inner[i]));
}
}
var j = 1.7976931348623157E+308;
var k = 1.7976931348623157E+308;
var l = -1.7976931348623157E+308;
var m = -1.7976931348623157E+308;
for (var n = 0; n < e.count; n++) {
j = Math.min(j, e._inner[n].x);
l = Math.max(l, e._inner[n].x);
k = Math.min(k, e._inner[n].y);
m = Math.max(m, e._inner[n].y);
}
return new Rect(0, j, k, l - j, m - k);
};
CoreGeometryUtil.n = function (a, b, c, d) {
var e = 3 * (-a + 3 * b - 3 * c + d);
var f = 6 * (a - 2 * b + c);
var g = 3 * (b - a);
var h = CoreGeometryUtil.o(e, f, g);
return h;
};
CoreGeometryUtil.o = function (a, b, c) {
var d = new List$1(Number_$type, 0);
var e = Math.abs(a) < 1E-09;
if (e) {
if (Math.abs(b) > 1E-09) {
var f = -c / b;
if (!isNaN_(f) && !isInfinity(f)) {
d.add(f);
}
}
}
else {
var g = b * b - 4 * a * c;
if (g >= 0) {
var h = Math.sqrt(g);
var i = (-b + h) / (2 * a);
var j = (-b - h) / (2 * a);
d.add(i);
d.add(j);
}
}
return d;
};
CoreGeometryUtil.ak = function (a, b, c, d, e) {
var f = 1 - e;
var g = f * f * f;
var h = f * f;
var i = e * e * e;
var j = e * e;
var k = g * a.x + 3 * h * e * b.x + 3 * f * j * c.x + i * d.x;
var l = g * a.y + 3 * h * e * b.y + 3 * f * j * c.y + i * d.y;
return { $type: Point_$type, x: k, y: l };
};
CoreGeometryUtil.ah = function (a, b, c, d) {
if (c.b == null || c.b.count < 3) {
return new Tuple$2(Boolean_$type, Point_$type, CoreGeometryUtil.e(a, b, d), b);
}
var e = c.b.count;
var f = b;
var g = b;
var h = b;
var i = b;
var j = 0;
while (j < e) {
if (j + 1 < e && j + 2 < e) {
g = c.b._inner[j];
h = c.b._inner[j + 1];
i = c.b._inner[j + 2];
var k = CoreGeometryUtil.ao(f, g, h, i);
if (RectUtil.r(k, d).containsPoint(a)) {
var l = CoreGeometryUtil.an(f, g, h, i);
if (RectUtil.r(l, d).containsPoint(a)) {
if (CoreGeometryUtil.ae(a, f, g, h, i, d).c) {
return new Tuple$2(Boolean_$type, Point_$type, true, c.b._inner[c.b.count - 1]);
}
}
}
f = i;
}
j = j + 3;
}
return new Tuple$2(Boolean_$type, Point_$type, false, c.b._inner[c.b.count - 1]);
};
CoreGeometryUtil.e = function (a, b, c) {
var d = b.x - a.x;
var e = b.y - a.y;
var f = d * d + e * e;
if (f < c * c) {
return true;
}
return false;
};
CoreGeometryUtil.ag = function (a, b, c, d) {
var e = b;
var f = c.e;
var g = c.f;
var h = c.g;
var i = CoreGeometryUtil.ao(e, f, g, h);
if (!RectUtil.r(i, d).containsPoint(a)) {
return new Tuple$2(Boolean_$type, Point_$type, false, h);
}
var j = CoreGeometryUtil.an(e, f, g, h);
if (!RectUtil.r(j, d).containsPoint(a)) {
return new Tuple$2(Boolean_$type, Point_$type, false, h);
}
return CoreGeometryUtil.ae(a, e, f, g, h, d);
};
CoreGeometryUtil.ae = function (a, b, c, d, e, f) {
if (CoreGeometryUtil.m(a, b, c, d, e, f, 0)) {
return new Tuple$2(Boolean_$type, Point_$type, true, e);
}
else {
return new Tuple$2(Boolean_$type, Point_$type, false, e);
}
};
CoreGeometryUtil.ad = function (a, b, c, d, e, f, g) {
if (g >= CoreGeometryUtil.u) {
return CoreGeometryUtil.z(a, b, e);
}
if (CoreGeometryUtil.f(b, c, d, e)) {
return CoreGeometryUtil.z(a, b, e);
}
var h = CoreGeometryUtil.ao(b, c, d, e);
if (h.width < (f / 2) && h.height < (f / 2)) {
return CoreGeometryUtil.z(a, b, e);
}
var i = CoreGeometryUtil.a(b, c, d, e, 0.5);
var j = i[0];
var k = i[1];
var l = i[2];
var m = i[3];
var n = i[4];
var o = i[5];
var p = i[6];
var q = i[7];
var r = (CoreGeometryUtil.ad(a, j, k, l, m, f, g + 1));
var s = (CoreGeometryUtil.ad(a, n, o, p, q, f, g + 1));
return r + s;
};
CoreGeometryUtil.m = function (a, b, c, d, e, f, g) {
if (g >= CoreGeometryUtil.u) {
return CoreGeometryUtil.i(a, b, e, f);
}
if (CoreGeometryUtil.f(b, c, d, e)) {
return CoreGeometryUtil.i(a, b, e, f);
}
var h = CoreGeometryUtil.ao(b, c, d, e);
if (h.width < (f / 2) && h.height < (f / 2)) {
return CoreGeometryUtil.i(a, b, e, f);
}
var i = CoreGeometryUtil.a(b, c, d, e, 0.5);
var j = i[0];
var k = i[1];
var l = i[2];
var m = i[3];
var n = i[4];
var o = i[5];
var p = i[6];
var q = i[7];
if (CoreGeometryUtil.m(a, j, k, l, m, f, g + 1)) {
return true;
}
if (CoreGeometryUtil.m(a, n, o, p, q, f, g + 1)) {
return true;
}
return false;
};
CoreGeometryUtil.a = function (a, b, c, d, e) {
var f = { $type: Point_$type, x: a.x + e * (b.x - a.x), y: a.y + e * (b.y - a.y) };
var g = { $type: Point_$type, x: b.x + e * (c.x - b.x), y: b.y + e * (c.y - b.y) };
var h = { $type: Point_$type, x: c.x + e * (d.x - c.x), y: c.y + e * (d.y - c.y) };
var i = { $type: Point_$type, x: f.x + e * (g.x - f.x), y: f.y + e * (g.y - f.y) };
var j = { $type: Point_$type, x: g.x + e * (h.x - g.x), y: g.y + e * (h.y - g.y) };
var k = { $type: Point_$type, x: i.x + e * (j.x - i.x), y: i.y + e * (j.y - i.y) };
var l = a;
var m = f;
var n = i;
var o = k;
var p = k;
var q = j;
var r = h;
var s = d;
var t = new Array(8);
t[0] = l;
t[1] = m;
t[2] = n;
t[3] = o;
t[4] = p;
t[5] = q;
t[6] = r;
t[7] = s;
return t;
};
CoreGeometryUtil.f = function (a, b, c, d) {
var e = Math.sqrt(CoreGeometryUtil.q(b, a, d));
var f = Math.sqrt(CoreGeometryUtil.q(c, a, d));
if (e + f < 0.0001) {
return true;
}
return false;
};
CoreGeometryUtil.ab = function (a, b, c) {
if (c._points == null || c._points.count == 0) {
if (PointUtil.equals(a, b)) {
return 1;
}
}
var d = b;
var e = b;
var f = 0;
for (var g = 0; g < c._points.count; g++) {
e = c._points._inner[g];
f += CoreGeometryUtil.z(a, d, e);
d = e;
}
return f;
};
CoreGeometryUtil.ai = function (a, b, c, d) {
if (c._points == null || c._points.count == 0) {
return new Tuple$2(Boolean_$type, Point_$type, CoreGeometryUtil.e(a, b, d), b);
}
var e = b;
var f = b;
for (var g = 0; g < c._points.count; g++) {
f = c._points._inner[g];
if (CoreGeometryUtil.i(a, e, f, d)) {
return new Tuple$2(Boolean_$type, Point_$type, true, c._points._inner[c._points.count - 1]);
}
e = f;
}
return new Tuple$2(Boolean_$type, Point_$type, false, c._points._inner[c._points.count - 1]);
};
CoreGeometryUtil.b = function (a, b) {
var c = (a.x - b.e.x) / 2;
var d = (a.y - b.e.y) / 2;
var e = Math.abs(b.f.width);
var f = Math.abs(b.f.height);
var g = MathUtil.p(b.c);
var h = Math.cos(g);
var i = Math.sin(g);
var j = h * c + i * d;
var k = -i * c + h * d;
var l = ((j * j) / (e * e)) + ((k * k) / (f * f));
if (l > 1) {
var m = Math.sqrt(l);
e = e * m;
f = f * m;
}
var n = e * e;
var o = f * f;
var p = j * j;
var q = k * k;
var r = (n * o) - (n * q) - (o * p);
var s = ((n * q) + (o * p));
if (s == 0) {
return null;
}
var t = Math.sqrt(Math.max(0, r / s));
if (b.b == (b.d == 1)) {
t = -t;
}
var u = t * ((e * k) / f);
var v = t * -((f * j) / e);
var w = (h * u) - (i * v) + ((b.e.x + a.x) / 2);
var x = (i * u) + (h * v) + ((b.e.y + a.y) / 2);
var y = CoreGeometryUtil.p(1, 0, (j - u) / e, (k - v) / f);
var z = CoreGeometryUtil.p((j - u) / e, (k - v) / f, (-j - u) / e, (-k - v) / f);
if (b.d == 1 && z < 0) {
z += 2 * Math.PI;
}
else if (b.d == 0 && z > 0) {
z -= 2 * Math.PI;
}
return ((function () {
var $ret = new ArcCenterInfo();
$ret.c = { $type: Point_$type, x: w, y: x };
$ret.a = y;
$ret.b = z;
return $ret;
})());
};
CoreGeometryUtil.p = function (a, b, c, d) {
var e = a * c + b * d;
var f = Math.sqrt((a * a + b * b));
var g = Math.sqrt((c * c + d * d));
var h = Math.acos(Math.min(Math.max(e / (f * g), -1), 1));
if (a * d - b * c < 0) {
return -h;
}
return h;
};
CoreGeometryUtil.d = function (a, b, c, d, e) {
b = CoreGeometryUtil.t(b);
a = CoreGeometryUtil.t(a);
var f = d ? (2 * Math.PI - c) : c;
var g = CoreGeometryUtil.t(a - b);
if (e == 1) {
return g <= f;
}
else {
return (2 * Math.PI - g) <= f;
}
};
CoreGeometryUtil.v = function (a, b, c) {
var d = CoreGeometryUtil.b(b, c);
if (d == null) {
return CoreGeometryUtil.z(a, b, c.e);
}
var e = d.c.x;
var f = d.c.y;
var g = a.x - e;
var h = a.y - f;
var i = MathUtil.p(-c.c);
var j = Math.cos(i);
var k = Math.sin(i);
var l = Math.abs(c.f.width);
var m = Math.abs(c.f.height);
var n = (g * j - h * k) / l;
var o = (h * j + g * k) / m;
var p = Math.sqrt(n * n + o * o);
var q = Math.atan2(o, n);
q = CoreGeometryUtil.t(q);
var r = d.a;
var s = d.a + d.b;
r = CoreGeometryUtil.t(r);
s = CoreGeometryUtil.t(s);
var t = 1 - (o * o);
if (t < 0) {
return 0;
}
var u = CoreGeometryUtil.d(q, r, d.b, c.b, c.d);
var v = [Math.sqrt(t), -Math.sqrt(t)];
for (var w = 0; w < v.length; w++) {
var x = v[w];
var y = x * l;
var z = o * m;
var aa = j * y - k * z + e;
var ab = k * y + j * z + f;
if (aa > a.x) {
if (CoreGeometryUtil.d(q, r, d.b, c.b, c.d)) {
return d.b > 0 ? 1 : -1;
}
}
}
return 0;
};
CoreGeometryUtil.t = function (a) {
if (isNaN_(a) || isInfinity(a)) {
return a;
}
while (a > 2 * Math.PI) {
a -= 2 * Math.PI;
}
while (a < 0) {
a += 2 * Math.PI;
}
return a;
};
CoreGeometryUtil.af = function (a, b, c, d) {
var e = CoreGeometryUtil.b(b, c);
if (e == null) {
if (CoreGeometryUtil.i(a, b, c.e, d)) {
return new Tuple$2(Boolean_$type, Point_$type, true, c.e);
}
else {
return new Tuple$2(Boolean_$type, Point_$type, false, c.e);
}
}
var f = e.c.x;
var g = e.c.y;
var h = a.x - f;
var i = a.y - g;
var j = MathUtil.p(-c.c);
var k = Math.cos(j);
var l = Math.sin(j);
var m = Math.abs(c.f.width);
var n = Math.abs(c.f.height);
var o = (h * k - i * l) / m;
var p = (i * k + h * l) / n;
var q = d;
var r = 0;
var s = Math.sqrt(q * q + r * r);
var t = (q * k - r * l) / m;
var u = (r * k + q * l) / n;
var v = Math.sqrt(t * t + u * u);
var w = Math.sqrt(o * o + p * p);
var x = Math.abs(w - 1) < v;
var y = Math.atan2(p, o);
y = CoreGeometryUtil.t(y);
var z = e.a;
var aa = e.a + e.b;
z = CoreGeometryUtil.t(z);
aa = CoreGeometryUtil.t(aa);
var ab = CoreGeometryUtil.d(y, z, e.b, c.b, c.d);
return new Tuple$2(Boolean_$type, Point_$type, ab && x, c.e);
};
CoreGeometryUtil.ac = function (a, b, c) {
var d = 0;
if (typeCast(LineSegment.$, c) !== null) {
var e = c;
d += CoreGeometryUtil.z(a, b, e.c);
}
else if (typeCast(PolyBezierSegment.$, c) !== null) {
var f = c;
d += CoreGeometryUtil.aa(a, b, f);
}
else if (typeCast(BezierSegment.$, c) !== null) {
var g = c;
d += CoreGeometryUtil.w(a, b, g);
}
else if (typeCast(PolyLineSegment.$, c) !== null) {
var h = c;
d += CoreGeometryUtil.ab(a, b, h);
}
else if (typeCast(ArcSegment.$, c) !== null) {
var i = c;
d += CoreGeometryUtil.v(a, b, i);
}
return d;
};
CoreGeometryUtil.aj = function (a, b, c, d) {
if (typeCast(LineSegment.$, c) !== null) {
var e = c;
var f = CoreGeometryUtil.i(a, b, e.c, d);
return new Tuple$2(Boolean_$type, Point_$type, f, e.c);
}
else if (typeCast(PolyBezierSegment.$, c) !== null) {
var g = c;
return CoreGeometryUtil.ah(a, b, g, d);
}
else if (typeCast(BezierSegment.$, c) !== null) {
var h = c;
return CoreGeometryUtil.ag(a, b, h, d);
}
else if (typeCast(PolyLineSegment.$, c) !== null) {
var i = c;
return CoreGeometryUtil.ai(a, b, i, d);
}
else if (typeCast(ArcSegment.$, c) !== null) {
var j = c;
return CoreGeometryUtil.af(a, b, j, d);
}
return new Tuple$2(Boolean_$type, Point_$type, false, { $type: Point_$type, x: NaN, y: NaN });
};
CoreGeometryUtil.am = function (a, b) {
if (typeCast(LineSegment.$, b) !== null) {
var c = b;
return c.c;
}
else if (typeCast(PolyBezierSegment.$, b) !== null) {
var d = b;
if (d.b == null || d.b.count == 0) {
return a;
}
return d.b._inner[d.b.count - 1];
}
else if (typeCast(BezierSegment.$, b) !== null) {
var e = b;
return e.g;
}
else if (typeCast(PolyLineSegment.$, b) !== null) {
var f = b;
if (f._points == null || f._points.count == 0) {
return a;
}
return f._points._inner[f._points.count - 1];
}
else if (typeCast(ArcSegment.$, b) !== null) {
var g = b;
return g.e;
}
return a;
};
CoreGeometryUtil.y = function (a, b) {
var c = b._startPoint;
if (b._segments == null || b._segments.count == 0) {
if (PointUtil.equals(c, a)) {
return 1;
}
}
var d = 0;
for (var e = 0; e < b._segments.count; e++) {
var f = b._segments._inner[e];
d += CoreGeometryUtil.ac(a, c, f);
c = CoreGeometryUtil.am(c, f);
}
return d;
};
CoreGeometryUtil.h = function (a, b, c) {
var d = b._startPoint;
if (b._segments == null || b._segments.count == 0) {
return CoreGeometryUtil.k(a, d, c);
}
for (var e = 0; e < b._segments.count; e++) {
var f = b._segments._inner[e];
var g = CoreGeometryUtil.aj(a, d, f, c);
if (g.c) {
return true;
}
else {
d = g.d;
}
}
return false;
};
CoreGeometryUtil.k = function (a, b, c) {
if ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) < c * c) {
return true;
}
return false;
};
CoreGeometryUtil.g = function (a, b) {
var e_1, _a;
if (b == null || b.an == null) {
return false;
}
var c = 0;
if (typeCast(PathGeometry.$, b.an) !== null) {
var d = b.an;
try {
for (var _b = __values(fromEnum(d.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
var e = _c.value;
c += CoreGeometryUtil.y(a, e);
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
}
else if (typeCast(LineGeometry.$, b.an) !== null) {
var f = b.an;
c += CoreGeometryUtil.z(a, f.d, f.c);
}
else if (typeCast(RectangleGeometry.$, b.an) !== null) {
var g = b.an;
if (g.e.containsPoint(a)) {
return true;
}
}
else if (typeCast(EllipseGeometry.$, b.an) !== null) {
var h = b.an;
return ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c) * (h.c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d) * (h.d)))) <= 1;
}
return c != 0;
};
CoreGeometryUtil.j = function (a, b, c) {
var e_2, _a;
if (b == null || b.an == null) {
return false;
}
if (typeCast(PathGeometry.$, b.an) !== null) {
var d = b.an;
try {
for (var _b = __values(fromEnum(d.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
var e = _c.value;
if (CoreGeometryUtil.h(a, e, c)) {
return true;
}
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_2)
throw e_2.error;
}
}
}
else if (typeCast(LineGeometry.$, b.an) !== null) {
var f = b.an;
return CoreGeometryUtil.i(a, f.d, f.c, c);
}
else if (typeCast(RectangleGeometry.$, b.an) !== null) {
var g = b.an;
return RectUtil.r(g.e, c).containsPoint(a) && !RectUtil.r(g.e, -c).containsPoint(a);
}
else if (typeCast(EllipseGeometry.$, b.an) !== null) {
var h = b.an;
return ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c + c) * (h.c + c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d + c) * (h.d + c)))) <= 1 && ((((a.x - h.e.x) * (a.x - h.e.x)) / ((h.c - c) * (h.c - c))) + (((a.y - h.e.y) * (a.y - h.e.y)) / ((h.d - c) * (h.d - c)))) >= 1;
}
return false;
};
CoreGeometryUtil.i = function (a, b, c, d) {
var e = d * d;
var f = b.x;
var g = b.y;
var h = c.x;
var i = c.y;
var j = a.x;
var k = a.y;
if (g == i) {
var l = Math.abs(g - k) < d;
var m = j >= Math.min(f, h) - d && j <= Math.max(f, h) + d;
if (l && m) {
return true;
}
else {
return false;
}
}
if (f == h) {
var n = Math.abs(f - j) < d;
var o = k >= Math.min(g, i) - d && k <= Math.max(g, i) + d;
if (n && o) {
return true;
}
else {
return false;
}
}
var p = h - f;
var q = i - g;
var r = p * p + q * q;
if (r == 0) {
return (j - f) * (j - f) + (k - g) * (k - g) < e;
}
var s = ((j - f) * p + (k - g) * q) / r;
s = s < 0 ? 0 : (s > 1 ? 1 : s);
var t = f + p * s;
var u = g + q * s;
var v = (t - j) * (t - j) + (u - k) * (u - k);
if (v < e) {
return true;
}
return false;
};
CoreGeometryUtil.l = function (a, b, c, d) {
var e;
var f;
var g = d * d;
var h = c.count;
if (h == 0) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) < g;
}
var i = a.x;
var j = a.y;
for (var k = 0; k < h; k++) {
if (k == 0) {
f = c.item(k);
e = b;
}
else {
f = c.item(k);
e = c.item(k - 1);
}
var l = e.x;
var m = e.y;
var n = f.x;
var o = f.y;
if (m == o) {
var p = Math.abs(m - j) < d;
var q = i >= Math.min(l, n) - d && i <= Math.max(l, n) + d;
if (p && q) {
return true;
}
else {
continue;
}
}
if (l == n) {
var r = Math.abs(l - i) < d;
var s = j >= Math.min(m, o) - d && j <= Math.max(m, o) + d;
if (r && s) {
return true;
}
else {
continue;
}
}
var t = n - l;
var u = o - m;
var v = t * t + u * u;
if (v == 0) {
return (i - l) * (i - l) + (j - m) * (j - m) < g;
}
var w = ((i - l) * t + (j - m) * u) / v;
w = w < 0 ? 0 : (w > 1 ? 1 : w);
var x = l + t * w;
var y = m + u * w;
var z = (x - i) * (x - i) + (y - j) * (y - j);
if (z < g) {
return true;
}
}
return false;
};
CoreGeometryUtil.r = function (a) {
if (isNaN_(a) || isInfinity(a)) {
return a;
}
while (a > 360) {
a -= 360;
}
while (a < 0) {
a += 360;
}
return a;
};
CoreGeometryUtil.s = function (a) {
if (isNaN_(a) || isInfinity(a)) {
return a;
}
while (a > Math.PI * 2) {
a -= Math.PI * 2;
}
while (a < 0) {
a += Math.PI * 2;
}
return a;
};
CoreGeometryUtil.al = function (a, b, c, d, e) {
var f = { $type: Point_$type, x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
var g = b.x - a.x;
var h = b.y - a.y;
var i = Math.sqrt(g * g + h * h);
var j = h;
var k = g * -1;
if (e == d) {
j = h * -1;
k = g;
}
var l = Math.max(Math.abs(j), Math.abs(k));
j = j / l;
k = k / l;
var m = Math.sqrt(j * j + k * k);
var n = j / m;
var o = k / m;
var p = i / 2;
var q = Math.sqrt(c * c - p * p);
if (isNaN_(q)) {
q = 0;
}
var r = q * n;
var s = q * o;
var t = { $type: Point_$type, x: f.x + r, y: f.y + s };
return t;
};
CoreGeometryUtil.$t = markType(CoreGeometryUtil, 'CoreGeometryUtil');
CoreGeometryUtil.u = 100;
return CoreGeometryUtil;
}(Base));
export { CoreGeometryUtil };
/**
* @hidden
*/
var RectUtil = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(RectUtil, _super);
function RectUtil() {
return _super !== null && _super.apply(this, arguments) || this;
}
RectUtil.l = function (a) {
if (a.isEmpty) {
return { $type: Point_$type, x: NaN, y: NaN };
}
return { $type: Point_$type, x: 0.5 * (a.left + a.right), y: 0.5 * (a.bottom + a.top) };
};
RectUtil.e = function (a) {
if (a.isEmpty) {
return 0;
}
return a.width * a.height;
};
RectUtil.p = function (a) {
if (a.isEmpty) {
return a;
}
return new Rect(0, a.left, a.top, a.width, a.height);
};
RectUtil.m = function (a, b) {
if (a.containsPoint(b)) {
return b;
}
var c = { $type: Point_$type, x: a.left + 0.5 * a.width, y: a.top + 0.5 * a.height };
var d = { $type: Point_$type, x: b.x - c.x, y: b.y - c.y };
var e;
if (d.x != 0) {
e = (a.left - c.x) / d.x;
var f = c.y + e * d.y;
if (f > a.top && f < a.bottom) {
return e > 0 ? { $type: Point_$type, x: a.left, y: f } : { $type: Point_$type, x: a.right, y: c.y - e * d.y };
}
}
e = (a.top - c.y) / d.y;
var g = c.x + e * d.x;
return e > 0 ? { $type: Point_$type, x: g, y: a.top } : { $type: Point_$type, x: c.x - e * d.x, y: a.bottom };
};
RectUtil.g = function (a, b) {
if (a.isEmpty) {
return NaN;
}
return RectUtil.f(a, b.x, b.y);
};
RectUtil.h = function (a, b) {
if (a.isEmpty) {
return Number.POSITIVE_INFINITY;
}
var c = RectUtil.f(a, b.left, b.top);
if (c > 0) {
c = Math.min(c, RectUtil.f(a, b.left, b.bottom));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(a, b.right, b.bottom));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(a, b.right, b.top));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(b, a.left, a.top));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(b, a.left, a.bottom));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(b, a.right, a.bottom));
}
if (c > 0) {
c = Math.min(c, RectUtil.f(b, a.right, a.top));
}
return c;
};
RectUtil.f = function (a, b, c) {
var d = b - a.left;
var e = c - a.top;
var f = a.width * d;
var g = a.height * e;
if (f > 0) {
var h = a.width * a.width;
if (f < h) {
d -= (f / h) * a.width;
}
else {
d -= a.width;
}
}
if (g > 0) {
var i = a.height * a.height;
if (g < i) {
e -= (g / i) * a.height;
}
else {
e -= a.height;
}
}
return d * d + e * e;
};
RectUtil.a = function (a, b) {
if (a.isEmpty || b.isEmpty) {
return false;
}
if (a.left > b.left) {
return false;
}
if (a.right < b.right) {
return false;
}
if (a.top > b.top) {
return false;
}
if (a.bottom < b.bottom) {
return false;
}
return true;
};
RectUtil.b = function (a, b) {
if (a.isEmpty || b.isEmpty) {
return false;
}
if (a.right < b.left) {
return false;
}
if (a.left > b.right) {
return false;
}
if (a.top > b.bottom) {
return false;
}
if (a.bottom < b.top) {
return false;
}
return true;
};
RectUtil.i = function (a, b) {
if (a.isEmpty || b.isEmpty) {
return 0;
}
var c = Math.min(a.right, b.right) - Math.max(a.left, b.left);
if (c <= 0) {
return 0;
}
var d = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top);
if (d <= 0) {
return 0;
}
return c * d;
};
RectUtil.q = function (a, b, c) {
if (a.isEmpty) {
return a;
}
return new Rect(0, a.x - b, a.y - c, Math.max(0, a.width + 2 * b), Math.max(0, a.height + 2 * c));
};
RectUtil.t = function (a, b, c) {
a.x = a.x - b;
a.y = a.y - c;
var d = a.width + 2 * b;
var e = a.height + 2 * c;
a.width = d > 1 ? d : 1;
a.height = e > 1 ? e : 1;
return a;
};
RectUtil.s = function (a, b, c) {
a.x = a.x - b;
a.y = a.y - c;
var d = a.width + 2 * b;
var e = a.height + 2 * c;
a.width = d > 1 ? d : 1;
a.height = e > 1 ? e : 1;
return a;
};
RectUtil.r = function (a, b) {
var c = a.x - b;
var d = a.y - b;
var e = a.width + b + b;
var f = a.height + b + b;
var g = e > 0 ? e : 0;
var h = f > 0 ? f : 0;
return new Rect(0, c, d, g, h);
};
RectUtil.y = function (a) {
a.x = Math.round(a.x);
a.y = Math.round(a.y);
a.width = Math.round(a.width);
a.height = Math.round(a.height);
return a;
};
RectUtil.c = function (a) {
return a.x == 0 && a.y == 0 && a.width == 0 && a.height == 0;
};
RectUtil.z = function (a) {
var b = new Size(1, a.width, a.height);
return b;
};
RectUtil.u = function (a, b) {
var c = RectUtil.v(a, RectUtil.z(b));
return c;
};
RectUtil.v = function (a, b) {
var c = a;
c.x = a.x / b.width;
c.y = a.y / b.height;
c.width = a.width / b.width;
c.height = a.height / b.height;
return c;
};
RectUtil.n = function (a) {
var b = { $type: Point_$type, x: a.x, y: a.y };
return b;
};
RectUtil.o = function (a) {
var b = { $type: Point_$type, x: a.x + a.width, y: a.y };
return b;
};
RectUtil.j = function (a) {
var b = { $type: Point_$type, x: a.x, y: a.y + a.height };
return b;
};
RectUtil.k = function (a) {
var b = { $type: Point_$type, x: a.x + a.width, y: a.y + a.height };
return b;
};
RectUtil.d = function (a) {
var b = ((function () {
var $ret = new List$1(Point_$type, 0);
$ret.add(RectUtil.n(a));
$ret.add(RectUtil.o(a));
$ret.add(RectUtil.k(a));
$ret.add(RectUtil.j(a));
return $ret;
})());
return b;
};
RectUtil.w = function (a, b) {
b = CoreGeometryUtil.r(b);
if (b == 0 || b == 180) {
return new Rect(0, a.left, a.top, a.width, a.height);
}
var c = RectUtil.l(a);
if (b == 90 || b == 270) {
var d = a.height / 2;
var e = a.width / 2;
return new Rect(0, c.x - d, c.y - e, a.height, a.width);
}
return RectUtil.x(a, c.x, c.y, b);
};
RectUtil.x = function (a, b, c, d) {
var e = RectUtil.d(a);
var f = MathUtil.p(d);
var g = Math.cos(f);
var h = Math.sin(f);
var i = 1.7976931348623157E+308;
var j = 1.7976931348623157E+308;
var k = -1.7976931348623157E+308;
var l = -1.7976931348623157E+308;
var m;
for (var n = 0; n < e.count; n++) {
m = e._inner[n];
var o = (g * (m.x - b) - h * (m.y - c) + b);
var p = (h * (m.x - b) + g * (m.y - c) + c);
i = Math.min(i, p);
j = Math.min(j, o);
k = Math.max(k, o);
l = Math.max(l, p);
}
var q = new Rect(0, j, i, k - j, l - i);
return q;
};
RectUtil.$t = markType(RectUtil, 'RectUtil');
return RectUtil;
}(Base));
export { RectUtil };