@xort/cga 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,5 @@
1
1
  // \0rolldown/runtime.js
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
3
  var __exportAll = (all, flags) => {
10
4
  let target = Object.setPrototypeOf({}, null);
11
5
  for (var name in all) __defProp(target, name, {
@@ -15,22 +9,6 @@ var __exportAll = (all, flags) => {
15
9
  if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
10
  return flags & 2 ? target : Object.preventExtensions(target);
17
11
  };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
21
- desc = __getOwnPropDesc(from, key);
22
- __defProp(to, key, {
23
- get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
24
- enumerable: !desc || desc.enumerable
25
- });
26
- }
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
31
- value: mod,
32
- enumerable: true
33
- }) : target, mod));
34
12
  // src/alg/queries.ts
35
13
  /** Squared distances are always measured from the returned witnesses. */
36
14
  function distanceResult(a, b, parameters = [0, 0]) {
@@ -3780,11 +3758,17 @@ function offsetRings(input, delta, join, end, miterLimit) {
3780
3758
  }
3781
3759
  const points = ring.map((p) => ({ ...p }));
3782
3760
  if (end === 0 || end === 6) {
3783
- const a = points[0], b = points[1], z = points.at(-1), y = points.at(-2), l = distance$1(a, b), k = distance$1(z, y);
3784
- a.X -= (b.X - a.X) / l * delta;
3785
- a.Y -= (b.Y - a.Y) / l * delta;
3786
- z.X += (z.X - y.X) / k * delta;
3787
- z.Y += (z.Y - y.Y) / k * delta;
3761
+ const a = points[0], b = points[1], z = points.at(-1), y = points.at(-2), l = distance$1(a, b), k = distance$1(z, y), startDirection = {
3762
+ X: (b.X - a.X) / l,
3763
+ Y: (b.Y - a.Y) / l
3764
+ }, endDirection = {
3765
+ X: (z.X - y.X) / k,
3766
+ Y: (z.Y - y.Y) / k
3767
+ };
3768
+ a.X -= startDirection.X * delta;
3769
+ a.Y -= startDirection.Y * delta;
3770
+ z.X += endDirection.X * delta;
3771
+ z.Y += endDirection.Y * delta;
3788
3772
  }
3789
3773
  const right = offsetRing(points, delta, join, miterLimit, false), left = offsetRing([...points].reverse(), delta, join, miterLimit, false), outline = [...right];
3790
3774
  const cap = (center, from, to) => {
@@ -3829,9 +3813,20 @@ function triangulateRings(input) {
3829
3813
  return values.filter((p, i) => !same(p, values[(i + values.length - 1) % values.length]));
3830
3814
  });
3831
3815
  if (!rings.length || rings[0].length < 3) return [];
3832
- const extent = Math.max(...rings.flat().flatMap((p) => [Math.abs(p.X), Math.abs(p.Y)]), 1), epsilon = Number.EPSILON * extent * extent * 16;
3816
+ let extent = 0;
3817
+ for (const ring of rings) for (const p of ring) {
3818
+ if (!Number.isFinite(p.X) || !Number.isFinite(p.Y)) throw new RangeError("Triangulation coordinates must be finite");
3819
+ extent = Math.max(extent, Math.abs(p.X), Math.abs(p.Y));
3820
+ }
3821
+ if (!extent) return [];
3822
+ for (const ring of rings) for (const p of ring) {
3823
+ p.X /= extent;
3824
+ p.Y /= extent;
3825
+ }
3826
+ const epsilon = Number.EPSILON * 16;
3833
3827
  const boundaries = rings.filter((r) => r.length >= 3);
3834
3828
  if (!boundaries.length) return [];
3829
+ for (const ring of boundaries) if (new Set(ring.map((p) => `${p.X},${p.Y}`)).size !== ring.length) throw new RangeError("Triangulation requires simple rings without repeated vertices");
3835
3830
  for (const ring of boundaries) if (ring.some((p) => !Number.isFinite(p.X) || !Number.isFinite(p.Y))) throw new RangeError("Triangulation coordinates must be finite");
3836
3831
  for (let r = 0; r < boundaries.length; r++) for (let s = r + 1; s < boundaries.length; s++) {
3837
3832
  const a = boundaries[r], b = boundaries[s];
@@ -6423,7 +6418,7 @@ var Voronoi = class {
6423
6418
  }
6424
6419
  };
6425
6420
  // src/alg/delaunay.ts
6426
- var pow$1 = Math.pow;
6421
+ var pow = Math.pow;
6427
6422
  function collinear(d) {
6428
6423
  const { triangles, coords } = d;
6429
6424
  for (let i = 0; i < triangles.length; i += 3) {
@@ -6534,12 +6529,12 @@ var Delaunay = class Delaunay {
6534
6529
  const { inedges, hull, _hullIndex, halfedges, triangles, points } = this;
6535
6530
  if (inedges[i] === -1 || !points.length) return (i + 1) % (points.length >> 1);
6536
6531
  let c = i;
6537
- let dc = pow$1(x - points[i * 2], 2) + pow$1(y - points[i * 2 + 1], 2);
6532
+ let dc = pow(x - points[i * 2], 2) + pow(y - points[i * 2 + 1], 2);
6538
6533
  const e0 = inedges[i];
6539
6534
  let e = e0;
6540
6535
  do {
6541
6536
  let t = triangles[e];
6542
- const dt = pow$1(x - points[t * 2], 2) + pow$1(y - points[t * 2 + 1], 2);
6537
+ const dt = pow(x - points[t * 2], 2) + pow(y - points[t * 2 + 1], 2);
6543
6538
  if (dt < dc) dc = dt, c = t;
6544
6539
  e = e % 3 === 2 ? e - 2 : e + 1;
6545
6540
  if (triangles[e] !== i) break;
@@ -6547,7 +6542,7 @@ var Delaunay = class Delaunay {
6547
6542
  if (e === -1) {
6548
6543
  e = hull[(_hullIndex[i] + 1) % hull.length];
6549
6544
  if (e !== t) {
6550
- if (pow$1(x - points[e * 2], 2) + pow$1(y - points[e * 2 + 1], 2) < dc) return e;
6545
+ if (pow(x - points[e * 2], 2) + pow(y - points[e * 2 + 1], 2) < dc) return e;
6551
6546
  }
6552
6547
  break;
6553
6548
  }
@@ -9494,1999 +9489,246 @@ function geometryFromJSON(data) {
9494
9489
  default: throw new RangeError("Unknown geometry kind");
9495
9490
  }
9496
9491
  }
9497
- // node_modules/decimal.js/decimal.mjs
9498
- /*!
9499
- * decimal.js v10.6.0
9500
- * An arbitrary-precision Decimal type for JavaScript.
9501
- * https://github.com/MikeMcl/decimal.js
9502
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
9503
- * MIT Licence
9504
- */
9505
- var EXP_LIMIT = 9e15;
9506
- var MAX_DIGITS = 1e9;
9507
- var NUMERALS = "0123456789abcdef";
9508
- var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
9509
- var PI$1 = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
9510
- var DEFAULTS = {
9511
- precision: 20,
9512
- rounding: 4,
9513
- modulo: 1,
9514
- toExpNeg: -7,
9515
- toExpPos: 21,
9516
- minE: -EXP_LIMIT,
9517
- maxE: EXP_LIMIT,
9518
- crypto: false
9519
- };
9520
- var inexact;
9521
- var quadrant;
9522
- var external = true;
9523
- var decimalError = "[DecimalError] ";
9524
- var invalidArgument = decimalError + "Invalid argument: ";
9525
- var precisionLimitExceeded = decimalError + "Precision limit exceeded";
9526
- var cryptoUnavailable = decimalError + "crypto unavailable";
9527
- var tag = "[object Decimal]";
9528
- var mathfloor = Math.floor;
9529
- var mathpow = Math.pow;
9530
- var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
9531
- var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
9532
- var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
9533
- var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
9534
- var BASE = 1e7;
9535
- var LOG_BASE = 7;
9536
- var MAX_SAFE_INTEGER = 0x1fffffffffffff;
9537
- var LN10_PRECISION = LN10.length - 1;
9538
- var PI_PRECISION = PI$1.length - 1;
9539
- var P = { toStringTag: tag };
9540
- P.absoluteValue = P.abs = function() {
9541
- var x = new this.constructor(this);
9542
- if (x.s < 0) x.s = 1;
9543
- return finalise(x);
9544
- };
9545
- P.ceil = function() {
9546
- return finalise(new this.constructor(this), this.e + 1, 2);
9547
- };
9548
- P.clampedTo = P.clamp = function(min, max) {
9549
- var k, x = this, Ctor = x.constructor;
9550
- min = new Ctor(min);
9551
- max = new Ctor(max);
9552
- if (!min.s || !max.s) return new Ctor(NaN);
9553
- if (min.gt(max)) throw Error(invalidArgument + max);
9554
- k = x.cmp(min);
9555
- return k < 0 ? min : x.cmp(max) > 0 ? max : new Ctor(x);
9556
- };
9557
- P.comparedTo = P.cmp = function(y) {
9558
- var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
9559
- if (!xd || !yd) return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
9560
- if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0;
9561
- if (xs !== ys) return xs;
9562
- if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1;
9563
- xdL = xd.length;
9564
- ydL = yd.length;
9565
- for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
9566
- return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
9567
- };
9568
- P.cosine = P.cos = function() {
9569
- var pr, rm, x = this, Ctor = x.constructor;
9570
- if (!x.d) return new Ctor(NaN);
9571
- if (!x.d[0]) return new Ctor(1);
9572
- pr = Ctor.precision;
9573
- rm = Ctor.rounding;
9574
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
9575
- Ctor.rounding = 1;
9576
- x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
9577
- Ctor.precision = pr;
9578
- Ctor.rounding = rm;
9579
- return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
9580
- };
9581
- P.cubeRoot = P.cbrt = function() {
9582
- var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
9583
- if (!x.isFinite() || x.isZero()) return new Ctor(x);
9584
- external = false;
9585
- s = x.s * mathpow(x.s * x, 1 / 3);
9586
- if (!s || Math.abs(s) == 1 / 0) {
9587
- n = digitsToString(x.d);
9588
- e = x.e;
9589
- if (s = (e - n.length + 1) % 3) n += s == 1 || s == -2 ? "0" : "00";
9590
- s = mathpow(n, 1 / 3);
9591
- e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
9592
- if (s == 1 / 0) n = "5e" + e;
9593
- else {
9594
- n = s.toExponential();
9595
- n = n.slice(0, n.indexOf("e") + 1) + e;
9596
- }
9597
- r = new Ctor(n);
9598
- r.s = x.s;
9599
- } else r = new Ctor(s.toString());
9600
- sd = (e = Ctor.precision) + 3;
9492
+ // src/math/Decimal.ts
9493
+ var MAX_EXPONENT = 1e6;
9494
+ var MAX_INPUT_DIGITS = 2e4;
9495
+ var abs = (n) => n < 0n ? -n : n;
9496
+ var digits$1 = (n) => abs(n).toString().length;
9497
+ function power(n) {
9498
+ if (!Number.isSafeInteger(n) || n < 0 || n > 202e4) throw new RangeError("Decimal exponent exceeds the supported range");
9499
+ return 10n ** BigInt(n);
9500
+ }
9501
+ function increment(q, remainder, divisor, sign, mode, sticky = false) {
9502
+ if (remainder === 0n && !sticky) return false;
9503
+ if (mode === 0) return true;
9504
+ if (mode === 1) return false;
9505
+ if (mode === 2) return sign > 0n;
9506
+ if (mode === 3) return sign < 0n;
9507
+ const compare = 2n * remainder - divisor;
9508
+ if (compare !== 0n) return compare > 0n;
9509
+ if (sticky) return true;
9510
+ return mode === 4 || mode === 6 && abs(q) % 2n === 1n || mode === 7 && sign > 0n || mode === 8 && sign < 0n;
9511
+ }
9512
+ function integerSqrt(n) {
9513
+ if (n < 2n) return n;
9514
+ let x = 1n << BigInt(Math.ceil(n.toString(2).length / 2));
9601
9515
  for (;;) {
9602
- t = r;
9603
- t3 = t.times(t).times(t);
9604
- t3plusx = t3.plus(x);
9605
- r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
9606
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
9607
- n = n.slice(sd - 3, sd + 1);
9608
- if (n == "9999" || !rep && n == "4999") {
9609
- if (!rep) {
9610
- finalise(t, e + 1, 0);
9611
- if (t.times(t).times(t).eq(x)) {
9612
- r = t;
9613
- break;
9614
- }
9615
- }
9616
- sd += 4;
9617
- rep = 1;
9618
- } else {
9619
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
9620
- finalise(r, e + 1, 1);
9621
- m = !r.times(r).times(r).eq(x);
9622
- }
9623
- break;
9624
- }
9516
+ const next = (x + n / x) / 2n;
9517
+ if (next >= x) return x;
9518
+ x = next;
9519
+ }
9520
+ }
9521
+ /** Finite decimal subset used by HVec3, Robust and CSG.
9522
+ * Constructors preserve input digits; arithmetic rounds to configured significant digits.
9523
+ * Instances are immutable. Unsupported/non-finite inputs and division by zero throw.
9524
+ */
9525
+ var Decimal = class Decimal {
9526
+ static precision = 20;
9527
+ static rounding = 4;
9528
+ static ROUND_UP = 0;
9529
+ static ROUND_DOWN = 1;
9530
+ static ROUND_CEIL = 2;
9531
+ static ROUND_FLOOR = 3;
9532
+ static ROUND_HALF_UP = 4;
9533
+ static ROUND_HALF_DOWN = 5;
9534
+ static ROUND_HALF_EVEN = 6;
9535
+ static ROUND_HALF_CEIL = 7;
9536
+ static ROUND_HALF_FLOOR = 8;
9537
+ coefficient;
9538
+ exponent;
9539
+ constructor(value = 0) {
9540
+ if (value instanceof Decimal) {
9541
+ this.coefficient = value.coefficient;
9542
+ this.exponent = value.exponent;
9543
+ return;
9625
9544
  }
9545
+ const text = String(value).trim();
9546
+ const match = /^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))(?:e([+-]?\d+))?$/i.exec(text);
9547
+ if (!match) throw new RangeError("Expected a finite decimal value");
9548
+ const fraction = match[3] ?? match[4] ?? "";
9549
+ const raw = ((match[2] ?? "") + fraction).replace(/^0+/, "") || "0";
9550
+ const exponent = Number(match[5] ?? 0) - fraction.length;
9551
+ if (raw.length > MAX_INPUT_DIGITS || !Number.isSafeInteger(exponent) || Math.abs(exponent) > MAX_EXPONENT) throw new RangeError("Decimal input exceeds the supported range");
9552
+ this.coefficient = BigInt((match[1] === "-" ? "-" : "") + raw);
9553
+ this.exponent = exponent;
9554
+ this.normalize();
9626
9555
  }
9627
- external = true;
9628
- return finalise(r, e, Ctor.rounding, m);
9629
- };
9630
- P.decimalPlaces = P.dp = function() {
9631
- var w, d = this.d, n = NaN;
9632
- if (d) {
9633
- w = d.length - 1;
9634
- n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
9635
- w = d[w];
9636
- if (w) for (; w % 10 == 0; w /= 10) n--;
9637
- if (n < 0) n = 0;
9638
- }
9639
- return n;
9640
- };
9641
- P.dividedBy = P.div = function(y) {
9642
- return divide(this, new this.constructor(y));
9643
- };
9644
- P.dividedToIntegerBy = P.divToInt = function(y) {
9645
- var x = this, Ctor = x.constructor;
9646
- return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
9647
- };
9648
- P.equals = P.eq = function(y) {
9649
- return this.cmp(y) === 0;
9650
- };
9651
- P.floor = function() {
9652
- return finalise(new this.constructor(this), this.e + 1, 3);
9653
- };
9654
- P.greaterThan = P.gt = function(y) {
9655
- return this.cmp(y) > 0;
9656
- };
9657
- P.greaterThanOrEqualTo = P.gte = function(y) {
9658
- var k = this.cmp(y);
9659
- return k == 1 || k === 0;
9660
- };
9661
- P.hyperbolicCosine = P.cosh = function() {
9662
- var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
9663
- if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN);
9664
- if (x.isZero()) return one;
9665
- pr = Ctor.precision;
9666
- rm = Ctor.rounding;
9667
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
9668
- Ctor.rounding = 1;
9669
- len = x.d.length;
9670
- if (len < 32) {
9671
- k = Math.ceil(len / 3);
9672
- n = (1 / tinyPow(4, k)).toString();
9673
- } else {
9674
- k = 16;
9675
- n = "2.3283064365386962890625e-10";
9676
- }
9677
- x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
9678
- var cosh2_x, i = k, d8 = new Ctor(8);
9679
- for (; i--;) {
9680
- cosh2_x = x.times(x);
9681
- x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
9682
- }
9683
- return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
9684
- };
9685
- P.hyperbolicSine = P.sinh = function() {
9686
- var k, pr, rm, len, x = this, Ctor = x.constructor;
9687
- if (!x.isFinite() || x.isZero()) return new Ctor(x);
9688
- pr = Ctor.precision;
9689
- rm = Ctor.rounding;
9690
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
9691
- Ctor.rounding = 1;
9692
- len = x.d.length;
9693
- if (len < 3) x = taylorSeries(Ctor, 2, x, x, true);
9694
- else {
9695
- k = 1.4 * Math.sqrt(len);
9696
- k = k > 16 ? 16 : k | 0;
9697
- x = x.times(1 / tinyPow(5, k));
9698
- x = taylorSeries(Ctor, 2, x, x, true);
9699
- var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
9700
- for (; k--;) {
9701
- sinh2_x = x.times(x);
9702
- x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
9703
- }
9704
- }
9705
- Ctor.precision = pr;
9706
- Ctor.rounding = rm;
9707
- return finalise(x, pr, rm, true);
9708
- };
9709
- P.hyperbolicTangent = P.tanh = function() {
9710
- var pr, rm, x = this, Ctor = x.constructor;
9711
- if (!x.isFinite()) return new Ctor(x.s);
9712
- if (x.isZero()) return new Ctor(x);
9713
- pr = Ctor.precision;
9714
- rm = Ctor.rounding;
9715
- Ctor.precision = pr + 7;
9716
- Ctor.rounding = 1;
9717
- return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
9718
- };
9719
- P.inverseCosine = P.acos = function() {
9720
- var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
9721
- if (k !== -1) return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
9722
- if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(.5);
9723
- Ctor.precision = pr + 6;
9724
- Ctor.rounding = 1;
9725
- x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
9726
- Ctor.precision = pr;
9727
- Ctor.rounding = rm;
9728
- return x.times(2);
9729
- };
9730
- P.inverseHyperbolicCosine = P.acosh = function() {
9731
- var pr, rm, x = this, Ctor = x.constructor;
9732
- if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN);
9733
- if (!x.isFinite()) return new Ctor(x);
9734
- pr = Ctor.precision;
9735
- rm = Ctor.rounding;
9736
- Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
9737
- Ctor.rounding = 1;
9738
- external = false;
9739
- x = x.times(x).minus(1).sqrt().plus(x);
9740
- external = true;
9741
- Ctor.precision = pr;
9742
- Ctor.rounding = rm;
9743
- return x.ln();
9744
- };
9745
- P.inverseHyperbolicSine = P.asinh = function() {
9746
- var pr, rm, x = this, Ctor = x.constructor;
9747
- if (!x.isFinite() || x.isZero()) return new Ctor(x);
9748
- pr = Ctor.precision;
9749
- rm = Ctor.rounding;
9750
- Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
9751
- Ctor.rounding = 1;
9752
- external = false;
9753
- x = x.times(x).plus(1).sqrt().plus(x);
9754
- external = true;
9755
- Ctor.precision = pr;
9756
- Ctor.rounding = rm;
9757
- return x.ln();
9758
- };
9759
- P.inverseHyperbolicTangent = P.atanh = function() {
9760
- var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
9761
- if (!x.isFinite()) return new Ctor(NaN);
9762
- if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
9763
- pr = Ctor.precision;
9764
- rm = Ctor.rounding;
9765
- xsd = x.sd();
9766
- if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true);
9767
- Ctor.precision = wpr = xsd - x.e;
9768
- x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
9769
- Ctor.precision = pr + 4;
9770
- Ctor.rounding = 1;
9771
- x = x.ln();
9772
- Ctor.precision = pr;
9773
- Ctor.rounding = rm;
9774
- return x.times(.5);
9775
- };
9776
- P.inverseSine = P.asin = function() {
9777
- var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
9778
- if (x.isZero()) return new Ctor(x);
9779
- k = x.abs().cmp(1);
9780
- pr = Ctor.precision;
9781
- rm = Ctor.rounding;
9782
- if (k !== -1) {
9783
- if (k === 0) {
9784
- halfPi = getPi(Ctor, pr + 4, rm).times(.5);
9785
- halfPi.s = x.s;
9786
- return halfPi;
9787
- }
9788
- return new Ctor(NaN);
9789
- }
9790
- Ctor.precision = pr + 6;
9791
- Ctor.rounding = 1;
9792
- x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
9793
- Ctor.precision = pr;
9794
- Ctor.rounding = rm;
9795
- return x.times(2);
9796
- };
9797
- P.inverseTangent = P.atan = function() {
9798
- var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
9799
- if (!x.isFinite()) {
9800
- if (!x.s) return new Ctor(NaN);
9801
- if (pr + 4 <= PI_PRECISION) {
9802
- r = getPi(Ctor, pr + 4, rm).times(.5);
9803
- r.s = x.s;
9804
- return r;
9805
- }
9806
- } else if (x.isZero()) return new Ctor(x);
9807
- else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
9808
- r = getPi(Ctor, pr + 4, rm).times(.25);
9809
- r.s = x.s;
9810
- return r;
9556
+ static set(config) {
9557
+ const p = config.precision ?? this.precision, r = config.rounding ?? this.rounding;
9558
+ if (!Number.isInteger(p) || p < 1 || p > 1e3) throw new RangeError("Decimal precision must be an integer from 1 to 1000");
9559
+ if (!Number.isInteger(r) || r < 0 || r > 8) throw new RangeError("Decimal rounding must be an integer from 0 to 8");
9560
+ this.precision = p;
9561
+ this.rounding = r;
9562
+ return this;
9811
9563
  }
9812
- Ctor.precision = wpr = pr + 10;
9813
- Ctor.rounding = 1;
9814
- k = Math.min(28, wpr / LOG_BASE + 2 | 0);
9815
- for (i = k; i; --i) x = x.div(x.times(x).plus(1).sqrt().plus(1));
9816
- external = false;
9817
- j = Math.ceil(wpr / LOG_BASE);
9818
- n = 1;
9819
- x2 = x.times(x);
9820
- r = new Ctor(x);
9821
- px = x;
9822
- for (; i !== -1;) {
9823
- px = px.times(x2);
9824
- t = r.minus(px.div(n += 2));
9825
- px = px.times(x2);
9826
- r = t.plus(px.div(n += 2));
9827
- if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;);
9828
- }
9829
- if (k) r = r.times(2 << k - 1);
9830
- external = true;
9831
- return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
9832
- };
9833
- P.isFinite = function() {
9834
- return !!this.d;
9835
- };
9836
- P.isInteger = P.isInt = function() {
9837
- return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
9838
- };
9839
- P.isNaN = function() {
9840
- return !this.s;
9841
- };
9842
- P.isNegative = P.isNeg = function() {
9843
- return this.s < 0;
9844
- };
9845
- P.isPositive = P.isPos = function() {
9846
- return this.s > 0;
9847
- };
9848
- P.isZero = function() {
9849
- return !!this.d && this.d[0] === 0;
9850
- };
9851
- P.lessThan = P.lt = function(y) {
9852
- return this.cmp(y) < 0;
9853
- };
9854
- P.lessThanOrEqualTo = P.lte = function(y) {
9855
- return this.cmp(y) < 1;
9856
- };
9857
- P.logarithm = P.log = function(base) {
9858
- var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
9859
- if (base == null) {
9860
- base = new Ctor(10);
9861
- isBase10 = true;
9862
- } else {
9863
- base = new Ctor(base);
9864
- d = base.d;
9865
- if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN);
9866
- isBase10 = base.eq(10);
9867
- }
9868
- d = arg.d;
9869
- if (arg.s < 0 || !d || !d[0] || arg.eq(1)) return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
9870
- if (isBase10) {
9871
- if (d.length > 1) inf = true;
9872
- else {
9873
- for (k = d[0]; k % 10 === 0;) k /= 10;
9874
- inf = k !== 1;
9875
- }
9876
- }
9877
- external = false;
9878
- sd = pr + guard;
9879
- num = naturalLogarithm(arg, sd);
9880
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
9881
- r = divide(num, denominator, sd, 1);
9882
- if (checkRoundingDigits(r.d, k = pr, rm)) do {
9883
- sd += 10;
9884
- num = naturalLogarithm(arg, sd);
9885
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
9886
- r = divide(num, denominator, sd, 1);
9887
- if (!inf) {
9888
- if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) r = finalise(r, pr + 1, 0);
9889
- break;
9890
- }
9891
- } while (checkRoundingDigits(r.d, k += 10, rm));
9892
- external = true;
9893
- return finalise(r, pr, rm);
9894
- };
9895
- P.minus = P.sub = function(y) {
9896
- var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
9897
- y = new Ctor(y);
9898
- if (!x.d || !y.d) {
9899
- if (!x.s || !y.s) y = new Ctor(NaN);
9900
- else if (x.d) y.s = -y.s;
9901
- else y = new Ctor(y.d || x.s !== y.s ? x : NaN);
9902
- return y;
9903
- }
9904
- if (x.s != y.s) {
9905
- y.s = -y.s;
9906
- return x.plus(y);
9907
- }
9908
- xd = x.d;
9909
- yd = y.d;
9910
- pr = Ctor.precision;
9911
- rm = Ctor.rounding;
9912
- if (!xd[0] || !yd[0]) {
9913
- if (yd[0]) y.s = -y.s;
9914
- else if (xd[0]) y = new Ctor(x);
9915
- else return new Ctor(rm === 3 ? -0 : 0);
9916
- return external ? finalise(y, pr, rm) : y;
9917
- }
9918
- e = mathfloor(y.e / LOG_BASE);
9919
- xe = mathfloor(x.e / LOG_BASE);
9920
- xd = xd.slice();
9921
- k = xe - e;
9922
- if (k) {
9923
- xLTy = k < 0;
9924
- if (xLTy) {
9925
- d = xd;
9926
- k = -k;
9927
- len = yd.length;
9928
- } else {
9929
- d = yd;
9930
- e = xe;
9931
- len = xd.length;
9932
- }
9933
- i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
9934
- if (k > i) {
9935
- k = i;
9936
- d.length = 1;
9937
- }
9938
- d.reverse();
9939
- for (i = k; i--;) d.push(0);
9940
- d.reverse();
9941
- } else {
9942
- i = xd.length;
9943
- len = yd.length;
9944
- xLTy = i < len;
9945
- if (xLTy) len = i;
9946
- for (i = 0; i < len; i++) if (xd[i] != yd[i]) {
9947
- xLTy = xd[i] < yd[i];
9948
- break;
9949
- }
9950
- k = 0;
9951
- }
9952
- if (xLTy) {
9953
- d = xd;
9954
- xd = yd;
9955
- yd = d;
9956
- y.s = -y.s;
9957
- }
9958
- len = xd.length;
9959
- for (i = yd.length - len; i > 0; --i) xd[len++] = 0;
9960
- for (i = yd.length; i > k;) {
9961
- if (xd[--i] < yd[i]) {
9962
- for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1;
9963
- --xd[j];
9964
- xd[i] += BASE;
9965
- }
9966
- xd[i] -= yd[i];
9967
- }
9968
- for (; xd[--len] === 0;) xd.pop();
9969
- for (; xd[0] === 0; xd.shift()) --e;
9970
- if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0);
9971
- y.d = xd;
9972
- y.e = getBase10Exponent(xd, e);
9973
- return external ? finalise(y, pr, rm) : y;
9974
- };
9975
- P.modulo = P.mod = function(y) {
9976
- var q, x = this, Ctor = x.constructor;
9977
- y = new Ctor(y);
9978
- if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN);
9979
- if (!y.d || x.d && !x.d[0]) return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
9980
- external = false;
9981
- if (Ctor.modulo == 9) {
9982
- q = divide(x, y.abs(), 0, 3, 1);
9983
- q.s *= y.s;
9984
- } else q = divide(x, y, 0, Ctor.modulo, 1);
9985
- q = q.times(y);
9986
- external = true;
9987
- return x.minus(q);
9988
- };
9989
- P.naturalExponential = P.exp = function() {
9990
- return naturalExponential(this);
9991
- };
9992
- P.naturalLogarithm = P.ln = function() {
9993
- return naturalLogarithm(this);
9994
- };
9995
- P.negated = P.neg = function() {
9996
- var x = new this.constructor(this);
9997
- x.s = -x.s;
9998
- return finalise(x);
9999
- };
10000
- P.plus = P.add = function(y) {
10001
- var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
10002
- y = new Ctor(y);
10003
- if (!x.d || !y.d) {
10004
- if (!x.s || !y.s) y = new Ctor(NaN);
10005
- else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN);
10006
- return y;
10007
- }
10008
- if (x.s != y.s) {
10009
- y.s = -y.s;
10010
- return x.minus(y);
10011
- }
10012
- xd = x.d;
10013
- yd = y.d;
10014
- pr = Ctor.precision;
10015
- rm = Ctor.rounding;
10016
- if (!xd[0] || !yd[0]) {
10017
- if (!yd[0]) y = new Ctor(x);
10018
- return external ? finalise(y, pr, rm) : y;
10019
- }
10020
- k = mathfloor(x.e / LOG_BASE);
10021
- e = mathfloor(y.e / LOG_BASE);
10022
- xd = xd.slice();
10023
- i = k - e;
10024
- if (i) {
10025
- if (i < 0) {
10026
- d = xd;
10027
- i = -i;
10028
- len = yd.length;
10029
- } else {
10030
- d = yd;
10031
- e = k;
10032
- len = xd.length;
10033
- }
10034
- k = Math.ceil(pr / LOG_BASE);
10035
- len = k > len ? k + 1 : len + 1;
10036
- if (i > len) {
10037
- i = len;
10038
- d.length = 1;
10039
- }
10040
- d.reverse();
10041
- for (; i--;) d.push(0);
10042
- d.reverse();
10043
- }
10044
- len = xd.length;
10045
- i = yd.length;
10046
- if (len - i < 0) {
10047
- i = len;
10048
- d = yd;
10049
- yd = xd;
10050
- xd = d;
10051
- }
10052
- for (carry = 0; i;) {
10053
- carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
10054
- xd[i] %= BASE;
10055
- }
10056
- if (carry) {
10057
- xd.unshift(carry);
10058
- ++e;
10059
- }
10060
- for (len = xd.length; xd[--len] == 0;) xd.pop();
10061
- y.d = xd;
10062
- y.e = getBase10Exponent(xd, e);
10063
- return external ? finalise(y, pr, rm) : y;
10064
- };
10065
- P.precision = P.sd = function(z) {
10066
- var k, x = this;
10067
- if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
10068
- if (x.d) {
10069
- k = getPrecision(x.d);
10070
- if (z && x.e + 1 > k) k = x.e + 1;
10071
- } else k = NaN;
10072
- return k;
10073
- };
10074
- P.round = function() {
10075
- var x = this, Ctor = x.constructor;
10076
- return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
10077
- };
10078
- P.sine = P.sin = function() {
10079
- var pr, rm, x = this, Ctor = x.constructor;
10080
- if (!x.isFinite()) return new Ctor(NaN);
10081
- if (x.isZero()) return new Ctor(x);
10082
- pr = Ctor.precision;
10083
- rm = Ctor.rounding;
10084
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
10085
- Ctor.rounding = 1;
10086
- x = sine(Ctor, toLessThanHalfPi(Ctor, x));
10087
- Ctor.precision = pr;
10088
- Ctor.rounding = rm;
10089
- return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
10090
- };
10091
- P.squareRoot = P.sqrt = function() {
10092
- var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
10093
- if (s !== 1 || !d || !d[0]) return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
10094
- external = false;
10095
- s = Math.sqrt(+x);
10096
- if (s == 0 || s == 1 / 0) {
10097
- n = digitsToString(d);
10098
- if ((n.length + e) % 2 == 0) n += "0";
10099
- s = Math.sqrt(n);
10100
- e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
10101
- if (s == 1 / 0) n = "5e" + e;
10102
- else {
10103
- n = s.toExponential();
10104
- n = n.slice(0, n.indexOf("e") + 1) + e;
9564
+ static config(config) {
9565
+ return this.set(config);
9566
+ }
9567
+ static isDecimal(value) {
9568
+ return value instanceof Decimal;
9569
+ }
9570
+ normalize() {
9571
+ if (this.coefficient === 0n) {
9572
+ this.exponent = 0;
9573
+ return;
10105
9574
  }
10106
- r = new Ctor(n);
10107
- } else r = new Ctor(s.toString());
10108
- sd = (e = Ctor.precision) + 3;
10109
- for (;;) {
10110
- t = r;
10111
- r = t.plus(divide(x, t, sd + 2, 1)).times(.5);
10112
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
10113
- n = n.slice(sd - 3, sd + 1);
10114
- if (n == "9999" || !rep && n == "4999") {
10115
- if (!rep) {
10116
- finalise(t, e + 1, 0);
10117
- if (t.times(t).eq(x)) {
10118
- r = t;
10119
- break;
10120
- }
10121
- }
10122
- sd += 4;
10123
- rep = 1;
10124
- } else {
10125
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
10126
- finalise(r, e + 1, 1);
10127
- m = !r.times(r).eq(x);
10128
- }
10129
- break;
9575
+ const text = abs(this.coefficient).toString();
9576
+ const trimmed = text.replace(/0+$/, "");
9577
+ this.exponent += text.length - trimmed.length;
9578
+ this.coefficient = BigInt(trimmed) * (this.coefficient < 0n ? -1n : 1n);
9579
+ if (Math.abs(this.exponent) > MAX_EXPONENT) throw new RangeError("Decimal result exceeds the supported exponent range");
9580
+ }
9581
+ static make(coefficient, exponent, round = true, sticky = false) {
9582
+ const result = Object.create(Decimal.prototype);
9583
+ if (round && coefficient !== 0n) {
9584
+ const excess = digits$1(coefficient) - Decimal.precision;
9585
+ if (excess > 0) {
9586
+ const divisor = power(excess), sign = coefficient < 0n ? -1n : 1n;
9587
+ const remainder = abs(coefficient % divisor);
9588
+ let q = coefficient / divisor;
9589
+ if (increment(q, remainder, divisor, sign, Decimal.rounding, sticky)) q += sign;
9590
+ coefficient = q;
9591
+ exponent += excess;
10130
9592
  }
10131
9593
  }
9594
+ result.coefficient = coefficient;
9595
+ result.exponent = exponent;
9596
+ result.normalize();
9597
+ return result;
10132
9598
  }
10133
- external = true;
10134
- return finalise(r, e, Ctor.rounding, m);
10135
- };
10136
- P.tangent = P.tan = function() {
10137
- var pr, rm, x = this, Ctor = x.constructor;
10138
- if (!x.isFinite()) return new Ctor(NaN);
10139
- if (x.isZero()) return new Ctor(x);
10140
- pr = Ctor.precision;
10141
- rm = Ctor.rounding;
10142
- Ctor.precision = pr + 10;
10143
- Ctor.rounding = 1;
10144
- x = x.sin();
10145
- x.s = 1;
10146
- x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
10147
- Ctor.precision = pr;
10148
- Ctor.rounding = rm;
10149
- return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
10150
- };
10151
- P.times = P.mul = function(y) {
10152
- var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
10153
- y.s *= x.s;
10154
- if (!xd || !xd[0] || !yd || !yd[0]) return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
10155
- e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
10156
- xdL = xd.length;
10157
- ydL = yd.length;
10158
- if (xdL < ydL) {
10159
- r = xd;
10160
- xd = yd;
10161
- yd = r;
10162
- rL = xdL;
10163
- xdL = ydL;
10164
- ydL = rL;
10165
- }
10166
- r = [];
10167
- rL = xdL + ydL;
10168
- for (i = rL; i--;) r.push(0);
10169
- for (i = ydL; --i >= 0;) {
10170
- carry = 0;
10171
- for (k = xdL + i; k > i;) {
10172
- t = r[k] + yd[i] * xd[k - i - 1] + carry;
10173
- r[k--] = t % BASE | 0;
10174
- carry = t / BASE | 0;
10175
- }
10176
- r[k] = (r[k] + carry) % BASE | 0;
10177
- }
10178
- for (; !r[--rL];) r.pop();
10179
- if (carry) ++e;
10180
- else r.shift();
10181
- y.d = r;
10182
- y.e = getBase10Exponent(r, e);
10183
- return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
10184
- };
10185
- P.toBinary = function(sd, rm) {
10186
- return toStringBinary(this, 2, sd, rm);
10187
- };
10188
- P.toDecimalPlaces = P.toDP = function(dp, rm) {
10189
- var x = this, Ctor = x.constructor;
10190
- x = new Ctor(x);
10191
- if (dp === void 0) return x;
10192
- checkInt32(dp, 0, MAX_DIGITS);
10193
- if (rm === void 0) rm = Ctor.rounding;
10194
- else checkInt32(rm, 0, 8);
10195
- return finalise(x, dp + x.e + 1, rm);
10196
- };
10197
- P.toExponential = function(dp, rm) {
10198
- var str, x = this, Ctor = x.constructor;
10199
- if (dp === void 0) str = finiteToString(x, true);
10200
- else {
10201
- checkInt32(dp, 0, MAX_DIGITS);
10202
- if (rm === void 0) rm = Ctor.rounding;
10203
- else checkInt32(rm, 0, 8);
10204
- x = finalise(new Ctor(x), dp + 1, rm);
10205
- str = finiteToString(x, true, dp + 1);
9599
+ add(value) {
9600
+ const b = new Decimal(value), e = Math.min(this.exponent, b.exponent);
9601
+ return Decimal.make(this.coefficient * power(this.exponent - e) + b.coefficient * power(b.exponent - e), e);
10206
9602
  }
10207
- return x.isNeg() && !x.isZero() ? "-" + str : str;
10208
- };
10209
- P.toFixed = function(dp, rm) {
10210
- var str, y, x = this, Ctor = x.constructor;
10211
- if (dp === void 0) str = finiteToString(x);
10212
- else {
10213
- checkInt32(dp, 0, MAX_DIGITS);
10214
- if (rm === void 0) rm = Ctor.rounding;
10215
- else checkInt32(rm, 0, 8);
10216
- y = finalise(new Ctor(x), dp + x.e + 1, rm);
10217
- str = finiteToString(y, false, dp + y.e + 1);
9603
+ plus(value) {
9604
+ return this.add(value);
10218
9605
  }
10219
- return x.isNeg() && !x.isZero() ? "-" + str : str;
10220
- };
10221
- P.toFraction = function(maxD) {
10222
- var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
10223
- if (!xd) return new Ctor(x);
10224
- n1 = d0 = new Ctor(1);
10225
- d1 = n0 = new Ctor(0);
10226
- d = new Ctor(d1);
10227
- e = d.e = getPrecision(xd) - x.e - 1;
10228
- k = e % LOG_BASE;
10229
- d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
10230
- if (maxD == null) maxD = e > 0 ? d : n1;
10231
- else {
10232
- n = new Ctor(maxD);
10233
- if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n);
10234
- maxD = n.gt(d) ? e > 0 ? d : n1 : n;
10235
- }
10236
- external = false;
10237
- n = new Ctor(digitsToString(xd));
10238
- pr = Ctor.precision;
10239
- Ctor.precision = e = xd.length * LOG_BASE * 2;
10240
- for (;;) {
10241
- q = divide(n, d, 0, 1, 1);
10242
- d2 = d0.plus(q.times(d1));
10243
- if (d2.cmp(maxD) == 1) break;
10244
- d0 = d1;
10245
- d1 = d2;
10246
- d2 = n1;
10247
- n1 = n0.plus(q.times(d2));
10248
- n0 = d2;
10249
- d2 = d;
10250
- d = n.minus(q.times(d2));
10251
- n = d2;
10252
- }
10253
- d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
10254
- n0 = n0.plus(d2.times(n1));
10255
- d0 = d0.plus(d2.times(d1));
10256
- n0.s = n1.s = x.s;
10257
- r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
10258
- Ctor.precision = pr;
10259
- external = true;
10260
- return r;
10261
- };
10262
- P.toHexadecimal = P.toHex = function(sd, rm) {
10263
- return toStringBinary(this, 16, sd, rm);
10264
- };
10265
- P.toNearest = function(y, rm) {
10266
- var x = this, Ctor = x.constructor;
10267
- x = new Ctor(x);
10268
- if (y == null) {
10269
- if (!x.d) return x;
10270
- y = new Ctor(1);
10271
- rm = Ctor.rounding;
10272
- } else {
10273
- y = new Ctor(y);
10274
- if (rm === void 0) rm = Ctor.rounding;
10275
- else checkInt32(rm, 0, 8);
10276
- if (!x.d) return y.s ? x : y;
10277
- if (!y.d) {
10278
- if (y.s) y.s = x.s;
10279
- return y;
10280
- }
10281
- }
10282
- if (y.d[0]) {
10283
- external = false;
10284
- x = divide(x, y, 0, rm, 1).times(y);
10285
- external = true;
10286
- finalise(x);
10287
- } else {
10288
- y.s = x.s;
10289
- x = y;
10290
- }
10291
- return x;
10292
- };
10293
- P.toNumber = function() {
10294
- return +this;
10295
- };
10296
- P.toOctal = function(sd, rm) {
10297
- return toStringBinary(this, 8, sd, rm);
10298
- };
10299
- P.toPower = P.pow = function(y) {
10300
- var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
10301
- if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn));
10302
- x = new Ctor(x);
10303
- if (x.eq(1)) return x;
10304
- pr = Ctor.precision;
10305
- rm = Ctor.rounding;
10306
- if (y.eq(1)) return finalise(x, pr, rm);
10307
- e = mathfloor(y.e / LOG_BASE);
10308
- if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
10309
- r = intPow(Ctor, x, k, pr);
10310
- return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
10311
- }
10312
- s = x.s;
10313
- if (s < 0) {
10314
- if (e < y.d.length - 1) return new Ctor(NaN);
10315
- if ((y.d[e] & 1) == 0) s = 1;
10316
- if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
10317
- x.s = s;
10318
- return x;
10319
- }
10320
- }
10321
- k = mathpow(+x, yn);
10322
- e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
10323
- if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? s / 0 : 0);
10324
- external = false;
10325
- Ctor.rounding = x.s = 1;
10326
- k = Math.min(12, (e + "").length);
10327
- r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
10328
- if (r.d) {
10329
- r = finalise(r, pr + 5, 1);
10330
- if (checkRoundingDigits(r.d, pr, rm)) {
10331
- e = pr + 10;
10332
- r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
10333
- if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) r = finalise(r, pr + 1, 0);
10334
- }
10335
- }
10336
- r.s = s;
10337
- external = true;
10338
- Ctor.rounding = rm;
10339
- return finalise(r, pr, rm);
10340
- };
10341
- P.toPrecision = function(sd, rm) {
10342
- var str, x = this, Ctor = x.constructor;
10343
- if (sd === void 0) str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
10344
- else {
10345
- checkInt32(sd, 1, MAX_DIGITS);
10346
- if (rm === void 0) rm = Ctor.rounding;
10347
- else checkInt32(rm, 0, 8);
10348
- x = finalise(new Ctor(x), sd, rm);
10349
- str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
9606
+ sub(value) {
9607
+ return this.add(new Decimal(value).negated());
10350
9608
  }
10351
- return x.isNeg() && !x.isZero() ? "-" + str : str;
10352
- };
10353
- P.toSignificantDigits = P.toSD = function(sd, rm) {
10354
- var x = this, Ctor = x.constructor;
10355
- if (sd === void 0) {
10356
- sd = Ctor.precision;
10357
- rm = Ctor.rounding;
10358
- } else {
10359
- checkInt32(sd, 1, MAX_DIGITS);
10360
- if (rm === void 0) rm = Ctor.rounding;
10361
- else checkInt32(rm, 0, 8);
10362
- }
10363
- return finalise(new Ctor(x), sd, rm);
10364
- };
10365
- P.toString = function() {
10366
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
10367
- return x.isNeg() && !x.isZero() ? "-" + str : str;
10368
- };
10369
- P.truncated = P.trunc = function() {
10370
- return finalise(new this.constructor(this), this.e + 1, 1);
10371
- };
10372
- P.valueOf = P.toJSON = function() {
10373
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
10374
- return x.isNeg() ? "-" + str : str;
10375
- };
10376
- function digitsToString(d) {
10377
- var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
10378
- if (indexOfLastWord > 0) {
10379
- str += w;
10380
- for (i = 1; i < indexOfLastWord; i++) {
10381
- ws = d[i] + "";
10382
- k = LOG_BASE - ws.length;
10383
- if (k) str += getZeroString(k);
10384
- str += ws;
10385
- }
10386
- w = d[i];
10387
- ws = w + "";
10388
- k = LOG_BASE - ws.length;
10389
- if (k) str += getZeroString(k);
10390
- } else if (w === 0) return "0";
10391
- for (; w % 10 === 0;) w /= 10;
10392
- return str + w;
10393
- }
10394
- function checkInt32(i, min, max) {
10395
- if (i !== ~~i || i < min || i > max) throw Error(invalidArgument + i);
10396
- }
10397
- function checkRoundingDigits(d, i, rm, repeating) {
10398
- var di, k = d[0], r, rd;
10399
- for (; k >= 10; k /= 10) --i;
10400
- if (--i < 0) {
10401
- i += LOG_BASE;
10402
- di = 0;
10403
- } else {
10404
- di = Math.ceil((i + 1) / LOG_BASE);
10405
- i %= LOG_BASE;
10406
- }
10407
- k = mathpow(10, LOG_BASE - i);
10408
- rd = d[di] % k | 0;
10409
- if (repeating == null) {
10410
- if (i < 3) {
10411
- if (i == 0) rd = rd / 100 | 0;
10412
- else if (i == 1) rd = rd / 10 | 0;
10413
- r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
10414
- } else r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
10415
- } else if (i < 4) {
10416
- if (i == 0) rd = rd / 1e3 | 0;
10417
- else if (i == 1) rd = rd / 100 | 0;
10418
- else if (i == 2) rd = rd / 10 | 0;
10419
- r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
10420
- } else r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
10421
- return r;
10422
- }
10423
- function convertBase(str, baseIn, baseOut) {
10424
- var j, arr = [0], arrL, i = 0, strL = str.length;
10425
- for (; i < strL;) {
10426
- for (arrL = arr.length; arrL--;) arr[arrL] *= baseIn;
10427
- arr[0] += NUMERALS.indexOf(str.charAt(i++));
10428
- for (j = 0; j < arr.length; j++) if (arr[j] > baseOut - 1) {
10429
- if (arr[j + 1] === void 0) arr[j + 1] = 0;
10430
- arr[j + 1] += arr[j] / baseOut | 0;
10431
- arr[j] %= baseOut;
10432
- }
10433
- }
10434
- return arr.reverse();
10435
- }
10436
- function cosine(Ctor, x) {
10437
- var k, len, y;
10438
- if (x.isZero()) return x;
10439
- len = x.d.length;
10440
- if (len < 32) {
10441
- k = Math.ceil(len / 3);
10442
- y = (1 / tinyPow(4, k)).toString();
10443
- } else {
10444
- k = 16;
10445
- y = "2.3283064365386962890625e-10";
10446
- }
10447
- Ctor.precision += k;
10448
- x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
10449
- for (var i = k; i--;) {
10450
- var cos2x = x.times(x);
10451
- x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
10452
- }
10453
- Ctor.precision -= k;
10454
- return x;
10455
- }
10456
- var divide = (function() {
10457
- function multiplyInteger(x, k, base) {
10458
- var temp, carry = 0, i = x.length;
10459
- for (x = x.slice(); i--;) {
10460
- temp = x[i] * k + carry;
10461
- x[i] = temp % base | 0;
10462
- carry = temp / base | 0;
10463
- }
10464
- if (carry) x.unshift(carry);
10465
- return x;
10466
- }
10467
- function compare(a, b, aL, bL) {
10468
- var i, r;
10469
- if (aL != bL) r = aL > bL ? 1 : -1;
10470
- else for (i = r = 0; i < aL; i++) if (a[i] != b[i]) {
10471
- r = a[i] > b[i] ? 1 : -1;
10472
- break;
10473
- }
10474
- return r;
9609
+ minus(value) {
9610
+ return this.sub(value);
10475
9611
  }
10476
- function subtract(a, b, aL, base) {
10477
- var i = 0;
10478
- for (; aL--;) {
10479
- a[aL] -= i;
10480
- i = a[aL] < b[aL] ? 1 : 0;
10481
- a[aL] = i * base + a[aL] - b[aL];
10482
- }
10483
- for (; !a[0] && a.length > 1;) a.shift();
10484
- }
10485
- return function(x, y, pr, rm, dp, base) {
10486
- var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
10487
- if (!xd || !xd[0] || !yd || !yd[0]) return new Ctor(!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
10488
- if (base) {
10489
- logBase = 1;
10490
- e = x.e - y.e;
10491
- } else {
10492
- base = BASE;
10493
- logBase = LOG_BASE;
10494
- e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
10495
- }
10496
- yL = yd.length;
10497
- xL = xd.length;
10498
- q = new Ctor(sign);
10499
- qd = q.d = [];
10500
- for (i = 0; yd[i] == (xd[i] || 0); i++);
10501
- if (yd[i] > (xd[i] || 0)) e--;
10502
- if (pr == null) {
10503
- sd = pr = Ctor.precision;
10504
- rm = Ctor.rounding;
10505
- } else if (dp) sd = pr + (x.e - y.e) + 1;
10506
- else sd = pr;
10507
- if (sd < 0) {
10508
- qd.push(1);
10509
- more = true;
10510
- } else {
10511
- sd = sd / logBase + 2 | 0;
10512
- i = 0;
10513
- if (yL == 1) {
10514
- k = 0;
10515
- yd = yd[0];
10516
- sd++;
10517
- for (; (i < xL || k) && sd--; i++) {
10518
- t = k * base + (xd[i] || 0);
10519
- qd[i] = t / yd | 0;
10520
- k = t % yd | 0;
10521
- }
10522
- more = k || i < xL;
10523
- } else {
10524
- k = base / (yd[0] + 1) | 0;
10525
- if (k > 1) {
10526
- yd = multiplyInteger(yd, k, base);
10527
- xd = multiplyInteger(xd, k, base);
10528
- yL = yd.length;
10529
- xL = xd.length;
10530
- }
10531
- xi = yL;
10532
- rem = xd.slice(0, yL);
10533
- remL = rem.length;
10534
- for (; remL < yL;) rem[remL++] = 0;
10535
- yz = yd.slice();
10536
- yz.unshift(0);
10537
- yd0 = yd[0];
10538
- if (yd[1] >= base / 2) ++yd0;
10539
- do {
10540
- k = 0;
10541
- cmp = compare(yd, rem, yL, remL);
10542
- if (cmp < 0) {
10543
- rem0 = rem[0];
10544
- if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
10545
- k = rem0 / yd0 | 0;
10546
- if (k > 1) {
10547
- if (k >= base) k = base - 1;
10548
- prod = multiplyInteger(yd, k, base);
10549
- prodL = prod.length;
10550
- remL = rem.length;
10551
- cmp = compare(prod, rem, prodL, remL);
10552
- if (cmp == 1) {
10553
- k--;
10554
- subtract(prod, yL < prodL ? yz : yd, prodL, base);
10555
- }
10556
- } else {
10557
- if (k == 0) cmp = k = 1;
10558
- prod = yd.slice();
10559
- }
10560
- prodL = prod.length;
10561
- if (prodL < remL) prod.unshift(0);
10562
- subtract(rem, prod, remL, base);
10563
- if (cmp == -1) {
10564
- remL = rem.length;
10565
- cmp = compare(yd, rem, yL, remL);
10566
- if (cmp < 1) {
10567
- k++;
10568
- subtract(rem, yL < remL ? yz : yd, remL, base);
10569
- }
10570
- }
10571
- remL = rem.length;
10572
- } else if (cmp === 0) {
10573
- k++;
10574
- rem = [0];
10575
- }
10576
- qd[i++] = k;
10577
- if (cmp && rem[0]) rem[remL++] = xd[xi] || 0;
10578
- else {
10579
- rem = [xd[xi]];
10580
- remL = 1;
10581
- }
10582
- } while ((xi++ < xL || rem[0] !== void 0) && sd--);
10583
- more = rem[0] !== void 0;
10584
- }
10585
- if (!qd[0]) qd.shift();
10586
- }
10587
- if (logBase == 1) {
10588
- q.e = e;
10589
- inexact = more;
10590
- } else {
10591
- for (i = 1, k = qd[0]; k >= 10; k /= 10) i++;
10592
- q.e = i + e * logBase - 1;
10593
- finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
10594
- }
10595
- return q;
10596
- };
10597
- })();
10598
- function finalise(x, sd, rm, isTruncated) {
10599
- var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
10600
- out: if (sd != null) {
10601
- xd = x.d;
10602
- if (!xd) return x;
10603
- for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++;
10604
- i = sd - digits;
10605
- if (i < 0) {
10606
- i += LOG_BASE;
10607
- j = sd;
10608
- w = xd[xdi = 0];
10609
- rd = w / mathpow(10, digits - j - 1) % 10 | 0;
10610
- } else {
10611
- xdi = Math.ceil((i + 1) / LOG_BASE);
10612
- k = xd.length;
10613
- if (xdi >= k) {
10614
- if (isTruncated) {
10615
- for (; k++ <= xdi;) xd.push(0);
10616
- w = rd = 0;
10617
- digits = 1;
10618
- i %= LOG_BASE;
10619
- j = i - LOG_BASE + 1;
10620
- } else break out;
10621
- } else {
10622
- w = k = xd[xdi];
10623
- for (digits = 1; k >= 10; k /= 10) digits++;
10624
- i %= LOG_BASE;
10625
- j = i - LOG_BASE + digits;
10626
- rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
10627
- }
10628
- }
10629
- isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
10630
- roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
10631
- if (sd < 1 || !xd[0]) {
10632
- xd.length = 0;
10633
- if (roundUp) {
10634
- sd -= x.e + 1;
10635
- xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
10636
- x.e = -sd || 0;
10637
- } else xd[0] = x.e = 0;
10638
- return x;
10639
- }
10640
- if (i == 0) {
10641
- xd.length = xdi;
10642
- k = 1;
10643
- xdi--;
10644
- } else {
10645
- xd.length = xdi + 1;
10646
- k = mathpow(10, LOG_BASE - i);
10647
- xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
10648
- }
10649
- if (roundUp) for (;;) if (xdi == 0) {
10650
- for (i = 1, j = xd[0]; j >= 10; j /= 10) i++;
10651
- j = xd[0] += k;
10652
- for (k = 1; j >= 10; j /= 10) k++;
10653
- if (i != k) {
10654
- x.e++;
10655
- if (xd[0] == BASE) xd[0] = 1;
10656
- }
10657
- break;
10658
- } else {
10659
- xd[xdi] += k;
10660
- if (xd[xdi] != BASE) break;
10661
- xd[xdi--] = 0;
10662
- k = 1;
10663
- }
10664
- for (i = xd.length; xd[--i] === 0;) xd.pop();
10665
- }
10666
- if (external) {
10667
- if (x.e > Ctor.maxE) {
10668
- x.d = null;
10669
- x.e = NaN;
10670
- } else if (x.e < Ctor.minE) {
10671
- x.e = 0;
10672
- x.d = [0];
10673
- }
10674
- }
10675
- return x;
10676
- }
10677
- function finiteToString(x, isExp, sd) {
10678
- if (!x.isFinite()) return nonFiniteToString(x);
10679
- var k, e = x.e, str = digitsToString(x.d), len = str.length;
10680
- if (isExp) {
10681
- if (sd && (k = sd - len) > 0) str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
10682
- else if (len > 1) str = str.charAt(0) + "." + str.slice(1);
10683
- str = str + (x.e < 0 ? "e" : "e+") + x.e;
10684
- } else if (e < 0) {
10685
- str = "0." + getZeroString(-e - 1) + str;
10686
- if (sd && (k = sd - len) > 0) str += getZeroString(k);
10687
- } else if (e >= len) {
10688
- str += getZeroString(e + 1 - len);
10689
- if (sd && (k = sd - e - 1) > 0) str = str + "." + getZeroString(k);
10690
- } else {
10691
- if ((k = e + 1) < len) str = str.slice(0, k) + "." + str.slice(k);
10692
- if (sd && (k = sd - len) > 0) {
10693
- if (e + 1 === len) str += ".";
10694
- str += getZeroString(k);
10695
- }
10696
- }
10697
- return str;
10698
- }
10699
- function getBase10Exponent(digits, e) {
10700
- var w = digits[0];
10701
- for (e *= LOG_BASE; w >= 10; w /= 10) e++;
10702
- return e;
10703
- }
10704
- function getLn10(Ctor, sd, pr) {
10705
- if (sd > LN10_PRECISION) {
10706
- external = true;
10707
- if (pr) Ctor.precision = pr;
10708
- throw Error(precisionLimitExceeded);
10709
- }
10710
- return finalise(new Ctor(LN10), sd, 1, true);
10711
- }
10712
- function getPi(Ctor, sd, rm) {
10713
- if (sd > PI_PRECISION) throw Error(precisionLimitExceeded);
10714
- return finalise(new Ctor(PI$1), sd, rm, true);
10715
- }
10716
- function getPrecision(digits) {
10717
- var w = digits.length - 1, len = w * LOG_BASE + 1;
10718
- w = digits[w];
10719
- if (w) {
10720
- for (; w % 10 == 0; w /= 10) len--;
10721
- for (w = digits[0]; w >= 10; w /= 10) len++;
10722
- }
10723
- return len;
10724
- }
10725
- function getZeroString(k) {
10726
- var zs = "";
10727
- for (; k--;) zs += "0";
10728
- return zs;
10729
- }
10730
- function intPow(Ctor, x, n, pr) {
10731
- var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
10732
- external = false;
10733
- for (;;) {
10734
- if (n % 2) {
10735
- r = r.times(x);
10736
- if (truncate(r.d, k)) isTruncated = true;
10737
- }
10738
- n = mathfloor(n / 2);
10739
- if (n === 0) {
10740
- n = r.d.length - 1;
10741
- if (isTruncated && r.d[n] === 0) ++r.d[n];
10742
- break;
10743
- }
10744
- x = x.times(x);
10745
- truncate(x.d, k);
9612
+ mul(value) {
9613
+ const b = new Decimal(value);
9614
+ return Decimal.make(this.coefficient * b.coefficient, this.exponent + b.exponent);
10746
9615
  }
10747
- external = true;
10748
- return r;
10749
- }
10750
- function isOdd(n) {
10751
- return n.d[n.d.length - 1] & 1;
10752
- }
10753
- function maxOrMin(Ctor, args, n) {
10754
- var k, y, x = new Ctor(args[0]), i = 0;
10755
- for (; ++i < args.length;) {
10756
- y = new Ctor(args[i]);
10757
- if (!y.s) {
10758
- x = y;
10759
- break;
10760
- }
10761
- k = x.cmp(y);
10762
- if (k === n || k === 0 && x.s === n) x = y;
10763
- }
10764
- return x;
10765
- }
10766
- function naturalExponential(x, sd) {
10767
- var denominator, guard, j, pow, sum, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
10768
- if (!x.d || !x.d[0] || x.e > 17) return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : NaN);
10769
- if (sd == null) {
10770
- external = false;
10771
- wpr = pr;
10772
- } else wpr = sd;
10773
- t = new Ctor(.03125);
10774
- while (x.e > -2) {
10775
- x = x.times(t);
10776
- k += 5;
10777
- }
10778
- guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
10779
- wpr += guard;
10780
- denominator = pow = sum = new Ctor(1);
10781
- Ctor.precision = wpr;
10782
- for (;;) {
10783
- pow = finalise(pow.times(x), wpr, 1);
10784
- denominator = denominator.times(++i);
10785
- t = sum.plus(divide(pow, denominator, wpr, 1));
10786
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
10787
- j = k;
10788
- while (j--) sum = finalise(sum.times(sum), wpr, 1);
10789
- if (sd == null) {
10790
- if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
10791
- Ctor.precision = wpr += 10;
10792
- denominator = pow = t = new Ctor(1);
10793
- i = 0;
10794
- rep++;
10795
- } else return finalise(sum, Ctor.precision = pr, rm, external = true);
10796
- } else {
10797
- Ctor.precision = pr;
10798
- return sum;
10799
- }
10800
- }
10801
- sum = t;
10802
- }
10803
- }
10804
- function naturalLogarithm(y, sd) {
10805
- var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
10806
- if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
10807
- if (sd == null) {
10808
- external = false;
10809
- wpr = pr;
10810
- } else wpr = sd;
10811
- Ctor.precision = wpr += guard;
10812
- c = digitsToString(xd);
10813
- c0 = c.charAt(0);
10814
- if (Math.abs(e = x.e) < 15e14) {
10815
- while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
10816
- x = x.times(y);
10817
- c = digitsToString(x.d);
10818
- c0 = c.charAt(0);
10819
- n++;
10820
- }
10821
- e = x.e;
10822
- if (c0 > 1) {
10823
- x = new Ctor("0." + c);
10824
- e++;
10825
- } else x = new Ctor(c0 + "." + c.slice(1));
10826
- } else {
10827
- t = getLn10(Ctor, wpr + 2, pr).times(e + "");
10828
- x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
10829
- Ctor.precision = pr;
10830
- return sd == null ? finalise(x, pr, rm, external = true) : x;
10831
- }
10832
- x1 = x;
10833
- sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
10834
- x2 = finalise(x.times(x), wpr, 1);
10835
- denominator = 3;
10836
- for (;;) {
10837
- numerator = finalise(numerator.times(x2), wpr, 1);
10838
- t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
10839
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
10840
- sum = sum.times(2);
10841
- if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
10842
- sum = divide(sum, new Ctor(n), wpr, 1);
10843
- if (sd == null) {
10844
- if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
10845
- Ctor.precision = wpr += guard;
10846
- t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
10847
- x2 = finalise(x.times(x), wpr, 1);
10848
- denominator = rep = 1;
10849
- } else return finalise(sum, Ctor.precision = pr, rm, external = true);
10850
- } else {
10851
- Ctor.precision = pr;
10852
- return sum;
10853
- }
10854
- }
10855
- sum = t;
10856
- denominator += 2;
10857
- }
10858
- }
10859
- function nonFiniteToString(x) {
10860
- return String(x.s * x.s / 0);
10861
- }
10862
- function parseDecimal(x, str) {
10863
- var e, i, len;
10864
- if ((e = str.indexOf(".")) > -1) str = str.replace(".", "");
10865
- if ((i = str.search(/e/i)) > 0) {
10866
- if (e < 0) e = i;
10867
- e += +str.slice(i + 1);
10868
- str = str.substring(0, i);
10869
- } else if (e < 0) e = str.length;
10870
- for (i = 0; str.charCodeAt(i) === 48; i++);
10871
- for (len = str.length; str.charCodeAt(len - 1) === 48; --len);
10872
- str = str.slice(i, len);
10873
- if (str) {
10874
- len -= i;
10875
- x.e = e = e - i - 1;
10876
- x.d = [];
10877
- i = (e + 1) % LOG_BASE;
10878
- if (e < 0) i += LOG_BASE;
10879
- if (i < len) {
10880
- if (i) x.d.push(+str.slice(0, i));
10881
- for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE));
10882
- str = str.slice(i);
10883
- i = LOG_BASE - str.length;
10884
- } else i -= len;
10885
- for (; i--;) str += "0";
10886
- x.d.push(+str);
10887
- if (external) {
10888
- if (x.e > x.constructor.maxE) {
10889
- x.d = null;
10890
- x.e = NaN;
10891
- } else if (x.e < x.constructor.minE) {
10892
- x.e = 0;
10893
- x.d = [0];
10894
- }
10895
- }
10896
- } else {
10897
- x.e = 0;
10898
- x.d = [0];
10899
- }
10900
- return x;
10901
- }
10902
- function parseOther(x, str) {
10903
- var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
10904
- if (str.indexOf("_") > -1) {
10905
- str = str.replace(/(\d)_(?=\d)/g, "$1");
10906
- if (isDecimal.test(str)) return parseDecimal(x, str);
10907
- } else if (str === "Infinity" || str === "NaN") {
10908
- if (!+str) x.s = NaN;
10909
- x.e = NaN;
10910
- x.d = null;
10911
- return x;
10912
- }
10913
- if (isHex.test(str)) {
10914
- base = 16;
10915
- str = str.toLowerCase();
10916
- } else if (isBinary.test(str)) base = 2;
10917
- else if (isOctal.test(str)) base = 8;
10918
- else throw Error(invalidArgument + str);
10919
- i = str.search(/p/i);
10920
- if (i > 0) {
10921
- p = +str.slice(i + 1);
10922
- str = str.substring(2, i);
10923
- } else str = str.slice(2);
10924
- i = str.indexOf(".");
10925
- isFloat = i >= 0;
10926
- Ctor = x.constructor;
10927
- if (isFloat) {
10928
- str = str.replace(".", "");
10929
- len = str.length;
10930
- i = len - i;
10931
- divisor = intPow(Ctor, new Ctor(base), i, i * 2);
10932
- }
10933
- xd = convertBase(str, base, BASE);
10934
- xe = xd.length - 1;
10935
- for (i = xe; xd[i] === 0; --i) xd.pop();
10936
- if (i < 0) return new Ctor(x.s * 0);
10937
- x.e = getBase10Exponent(xd, xe);
10938
- x.d = xd;
10939
- external = false;
10940
- if (isFloat) x = divide(x, divisor, len * 4);
10941
- if (p) x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
10942
- external = true;
10943
- return x;
10944
- }
10945
- function sine(Ctor, x) {
10946
- var k, len = x.d.length;
10947
- if (len < 3) return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
10948
- k = 1.4 * Math.sqrt(len);
10949
- k = k > 16 ? 16 : k | 0;
10950
- x = x.times(1 / tinyPow(5, k));
10951
- x = taylorSeries(Ctor, 2, x, x);
10952
- var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
10953
- for (; k--;) {
10954
- sin2_x = x.times(x);
10955
- x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
10956
- }
10957
- return x;
10958
- }
10959
- function taylorSeries(Ctor, n, x, y, isHyperbolic) {
10960
- var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
10961
- external = false;
10962
- x2 = x.times(x);
10963
- u = new Ctor(y);
10964
- for (;;) {
10965
- t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
10966
- u = isHyperbolic ? y.plus(t) : y.minus(t);
10967
- y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
10968
- t = u.plus(y);
10969
- if (t.d[k] !== void 0) {
10970
- for (j = k; t.d[j] === u.d[j] && j--;);
10971
- if (j == -1) break;
10972
- }
10973
- j = u;
10974
- u = y;
10975
- y = t;
10976
- t = j;
10977
- i++;
10978
- }
10979
- external = true;
10980
- t.d.length = k + 1;
10981
- return t;
10982
- }
10983
- function tinyPow(b, e) {
10984
- var n = b;
10985
- while (--e) n *= b;
10986
- return n;
10987
- }
10988
- function toLessThanHalfPi(Ctor, x) {
10989
- var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(.5);
10990
- x = x.abs();
10991
- if (x.lte(halfPi)) {
10992
- quadrant = isNeg ? 4 : 1;
10993
- return x;
10994
- }
10995
- t = x.divToInt(pi);
10996
- if (t.isZero()) quadrant = isNeg ? 3 : 2;
10997
- else {
10998
- x = x.minus(t.times(pi));
10999
- if (x.lte(halfPi)) {
11000
- quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
11001
- return x;
11002
- }
11003
- quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
11004
- }
11005
- return x.minus(pi).abs();
11006
- }
11007
- function toStringBinary(x, baseOut, sd, rm) {
11008
- var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
11009
- if (isExp) {
11010
- checkInt32(sd, 1, MAX_DIGITS);
11011
- if (rm === void 0) rm = Ctor.rounding;
11012
- else checkInt32(rm, 0, 8);
11013
- } else {
11014
- sd = Ctor.precision;
11015
- rm = Ctor.rounding;
11016
- }
11017
- if (!x.isFinite()) str = nonFiniteToString(x);
11018
- else {
11019
- str = finiteToString(x);
11020
- i = str.indexOf(".");
11021
- if (isExp) {
11022
- base = 2;
11023
- if (baseOut == 16) sd = sd * 4 - 3;
11024
- else if (baseOut == 8) sd = sd * 3 - 2;
11025
- } else base = baseOut;
11026
- if (i >= 0) {
11027
- str = str.replace(".", "");
11028
- y = new Ctor(1);
11029
- y.e = str.length - i;
11030
- y.d = convertBase(finiteToString(y), 10, base);
11031
- y.e = y.d.length;
11032
- }
11033
- xd = convertBase(str, 10, base);
11034
- e = len = xd.length;
11035
- for (; xd[--len] == 0;) xd.pop();
11036
- if (!xd[0]) str = isExp ? "0p+0" : "0";
11037
- else {
11038
- if (i < 0) e--;
11039
- else {
11040
- x = new Ctor(x);
11041
- x.d = xd;
11042
- x.e = e;
11043
- x = divide(x, y, sd, rm, 0, base);
11044
- xd = x.d;
11045
- e = x.e;
11046
- roundUp = inexact;
11047
- }
11048
- i = xd[sd];
11049
- k = base / 2;
11050
- roundUp = roundUp || xd[sd + 1] !== void 0;
11051
- roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
11052
- xd.length = sd;
11053
- if (roundUp) for (; ++xd[--sd] > base - 1;) {
11054
- xd[sd] = 0;
11055
- if (!sd) {
11056
- ++e;
11057
- xd.unshift(1);
11058
- }
11059
- }
11060
- for (len = xd.length; !xd[len - 1]; --len);
11061
- for (i = 0, str = ""; i < len; i++) str += NUMERALS.charAt(xd[i]);
11062
- if (isExp) {
11063
- if (len > 1) {
11064
- if (baseOut == 16 || baseOut == 8) {
11065
- i = baseOut == 16 ? 4 : 3;
11066
- for (--len; len % i; len++) str += "0";
11067
- xd = convertBase(str, base, baseOut);
11068
- for (len = xd.length; !xd[len - 1]; --len);
11069
- for (i = 1, str = "1."; i < len; i++) str += NUMERALS.charAt(xd[i]);
11070
- } else str = str.charAt(0) + "." + str.slice(1);
11071
- }
11072
- str = str + (e < 0 ? "p" : "p+") + e;
11073
- } else if (e < 0) {
11074
- for (; ++e;) str = "0" + str;
11075
- str = "0." + str;
11076
- } else if (++e > len) for (e -= len; e--;) str += "0";
11077
- else if (e < len) str = str.slice(0, e) + "." + str.slice(e);
9616
+ times(value) {
9617
+ return this.mul(value);
9618
+ }
9619
+ div(value) {
9620
+ const b = new Decimal(value);
9621
+ if (b.isZero()) throw new RangeError("Division by zero");
9622
+ if (this.isZero()) return new Decimal(0);
9623
+ const scale = Decimal.precision + 2 + digits$1(b.coefficient) - digits$1(this.coefficient);
9624
+ const numerator = this.coefficient * power(Math.max(0, scale));
9625
+ const denominator = b.coefficient * power(Math.max(0, -scale));
9626
+ return Decimal.make(numerator / denominator, this.exponent - b.exponent - scale, true, numerator % denominator !== 0n);
9627
+ }
9628
+ dividedBy(value) {
9629
+ return this.div(value);
9630
+ }
9631
+ sqrt() {
9632
+ if (this.coefficient < 0n) throw new RangeError("Square root requires a nonnegative value");
9633
+ if (this.isZero()) return new Decimal(0);
9634
+ let c = this.coefficient, e = this.exponent;
9635
+ if (e % 2 !== 0) {
9636
+ c *= 10n;
9637
+ e--;
11078
9638
  }
11079
- str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
9639
+ const scale = Math.max(0, Decimal.precision + 2 - Math.ceil(digits$1(c) / 2));
9640
+ const radicand = c * power(2 * scale), root = integerSqrt(radicand);
9641
+ return Decimal.make(root, e / 2 - scale, true, root * root !== radicand);
11080
9642
  }
11081
- return x.s < 0 ? "-" + str : str;
11082
- }
11083
- function truncate(arr, len) {
11084
- if (arr.length > len) {
11085
- arr.length = len;
9643
+ negated() {
9644
+ return Decimal.make(-this.coefficient, this.exponent, false);
9645
+ }
9646
+ neg() {
9647
+ return this.negated();
9648
+ }
9649
+ abs() {
9650
+ return Decimal.make(abs(this.coefficient), this.exponent, false);
9651
+ }
9652
+ comparedTo(value) {
9653
+ const b = new Decimal(value);
9654
+ if (this.coefficient === b.coefficient && this.exponent === b.exponent) return 0;
9655
+ if (this.coefficient < 0n && b.coefficient >= 0n) return -1;
9656
+ if (this.coefficient >= 0n && b.coefficient < 0n) return 1;
9657
+ if (this.isZero()) return b.isNegative() ? 1 : -1;
9658
+ if (b.isZero()) return this.isNegative() ? -1 : 1;
9659
+ const order = digits$1(this.coefficient) + this.exponent;
9660
+ const otherOrder = digits$1(b.coefficient) + b.exponent;
9661
+ if (order !== otherOrder) return (order < otherOrder ? -1 : 1) * (this.isNegative() ? -1 : 1);
9662
+ const e = Math.min(this.exponent, b.exponent);
9663
+ return this.coefficient * power(this.exponent - e) < b.coefficient * power(b.exponent - e) ? -1 : 1;
9664
+ }
9665
+ cmp(value) {
9666
+ return this.comparedTo(value);
9667
+ }
9668
+ eq(value) {
9669
+ return this.comparedTo(value) === 0;
9670
+ }
9671
+ equals(value) {
9672
+ return this.eq(value);
9673
+ }
9674
+ lt(value) {
9675
+ return this.comparedTo(value) < 0;
9676
+ }
9677
+ lte(value) {
9678
+ return this.comparedTo(value) <= 0;
9679
+ }
9680
+ gt(value) {
9681
+ return this.comparedTo(value) > 0;
9682
+ }
9683
+ gte(value) {
9684
+ return this.comparedTo(value) >= 0;
9685
+ }
9686
+ isZero() {
9687
+ return this.coefficient === 0n;
9688
+ }
9689
+ isNegative() {
9690
+ return this.coefficient < 0n;
9691
+ }
9692
+ isPositive() {
9693
+ return this.coefficient > 0n;
9694
+ }
9695
+ isFinite() {
11086
9696
  return true;
11087
9697
  }
11088
- }
11089
- function abs(x) {
11090
- return new this(x).abs();
11091
- }
11092
- function acos(x) {
11093
- return new this(x).acos();
11094
- }
11095
- function acosh(x) {
11096
- return new this(x).acosh();
11097
- }
11098
- function add(x, y) {
11099
- return new this(x).plus(y);
11100
- }
11101
- function asin(x) {
11102
- return new this(x).asin();
11103
- }
11104
- function asinh(x) {
11105
- return new this(x).asinh();
11106
- }
11107
- function atan(x) {
11108
- return new this(x).atan();
11109
- }
11110
- function atanh(x) {
11111
- return new this(x).atanh();
11112
- }
11113
- function atan2(y, x) {
11114
- y = new this(y);
11115
- x = new this(x);
11116
- var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
11117
- if (!y.s || !x.s) r = new this(NaN);
11118
- else if (!y.d && !x.d) {
11119
- r = getPi(this, wpr, 1).times(x.s > 0 ? .25 : .75);
11120
- r.s = y.s;
11121
- } else if (!x.d || y.isZero()) {
11122
- r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
11123
- r.s = y.s;
11124
- } else if (!y.d || x.isZero()) {
11125
- r = getPi(this, wpr, 1).times(.5);
11126
- r.s = y.s;
11127
- } else if (x.s < 0) {
11128
- this.precision = wpr;
11129
- this.rounding = 1;
11130
- r = this.atan(divide(y, x, wpr, 1));
11131
- x = getPi(this, wpr, 1);
11132
- this.precision = pr;
11133
- this.rounding = rm;
11134
- r = y.s < 0 ? r.minus(x) : r.plus(x);
11135
- } else r = this.atan(divide(y, x, wpr, 1));
11136
- return r;
11137
- }
11138
- function cbrt(x) {
11139
- return new this(x).cbrt();
11140
- }
11141
- function ceil(x) {
11142
- return finalise(x = new this(x), x.e + 1, 2);
11143
- }
11144
- function clamp$1(x, min, max) {
11145
- return new this(x).clamp(min, max);
11146
- }
11147
- function config(obj) {
11148
- if (!obj || typeof obj !== "object") throw Error(decimalError + "Object expected");
11149
- var i, p, v, useDefaults = obj.defaults === true, ps = [
11150
- "precision",
11151
- 1,
11152
- MAX_DIGITS,
11153
- "rounding",
11154
- 0,
11155
- 8,
11156
- "toExpNeg",
11157
- -EXP_LIMIT,
11158
- 0,
11159
- "toExpPos",
11160
- 0,
11161
- EXP_LIMIT,
11162
- "maxE",
11163
- 0,
11164
- EXP_LIMIT,
11165
- "minE",
11166
- -EXP_LIMIT,
11167
- 0,
11168
- "modulo",
11169
- 0,
11170
- 9
11171
- ];
11172
- for (i = 0; i < ps.length; i += 3) {
11173
- if (p = ps[i], useDefaults) this[p] = DEFAULTS[p];
11174
- if ((v = obj[p]) !== void 0) {
11175
- if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
11176
- else throw Error(invalidArgument + p + ": " + v);
11177
- }
11178
- }
11179
- if (p = "crypto", useDefaults) this[p] = DEFAULTS[p];
11180
- if ((v = obj[p]) !== void 0) {
11181
- if (v === true || v === false || v === 0 || v === 1) {
11182
- if (v) {
11183
- if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) this[p] = true;
11184
- else throw Error(cryptoUnavailable);
11185
- } else this[p] = false;
11186
- } else throw Error(invalidArgument + p + ": " + v);
11187
- }
11188
- return this;
11189
- }
11190
- function cos(x) {
11191
- return new this(x).cos();
11192
- }
11193
- function cosh(x) {
11194
- return new this(x).cosh();
11195
- }
11196
- function clone$1(obj) {
11197
- var i, p, ps;
11198
- function Decimal(v) {
11199
- var e, i, t, x = this;
11200
- if (!(x instanceof Decimal)) return new Decimal(v);
11201
- x.constructor = Decimal;
11202
- if (isDecimalInstance(v)) {
11203
- x.s = v.s;
11204
- if (external) {
11205
- if (!v.d || v.e > Decimal.maxE) {
11206
- x.e = NaN;
11207
- x.d = null;
11208
- } else if (v.e < Decimal.minE) {
11209
- x.e = 0;
11210
- x.d = [0];
11211
- } else {
11212
- x.e = v.e;
11213
- x.d = v.d.slice();
11214
- }
11215
- } else {
11216
- x.e = v.e;
11217
- x.d = v.d ? v.d.slice() : v.d;
11218
- }
11219
- return;
11220
- }
11221
- t = typeof v;
11222
- if (t === "number") {
11223
- if (v === 0) {
11224
- x.s = 1 / v < 0 ? -1 : 1;
11225
- x.e = 0;
11226
- x.d = [0];
11227
- return;
11228
- }
11229
- if (v < 0) {
11230
- v = -v;
11231
- x.s = -1;
11232
- } else x.s = 1;
11233
- if (v === ~~v && v < 1e7) {
11234
- for (e = 0, i = v; i >= 10; i /= 10) e++;
11235
- if (external) {
11236
- if (e > Decimal.maxE) {
11237
- x.e = NaN;
11238
- x.d = null;
11239
- } else if (e < Decimal.minE) {
11240
- x.e = 0;
11241
- x.d = [0];
11242
- } else {
11243
- x.e = e;
11244
- x.d = [v];
11245
- }
11246
- } else {
11247
- x.e = e;
11248
- x.d = [v];
11249
- }
11250
- return;
11251
- }
11252
- if (v * 0 !== 0) {
11253
- if (!v) x.s = NaN;
11254
- x.e = NaN;
11255
- x.d = null;
11256
- return;
11257
- }
11258
- return parseDecimal(x, v.toString());
11259
- }
11260
- if (t === "string") {
11261
- if ((i = v.charCodeAt(0)) === 45) {
11262
- v = v.slice(1);
11263
- x.s = -1;
11264
- } else {
11265
- if (i === 43) v = v.slice(1);
11266
- x.s = 1;
11267
- }
11268
- return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
11269
- }
11270
- if (t === "bigint") {
11271
- if (v < 0) {
11272
- v = -v;
11273
- x.s = -1;
11274
- } else x.s = 1;
11275
- return parseDecimal(x, v.toString());
11276
- }
11277
- throw Error(invalidArgument + v);
11278
- }
11279
- Decimal.prototype = P;
11280
- Decimal.ROUND_UP = 0;
11281
- Decimal.ROUND_DOWN = 1;
11282
- Decimal.ROUND_CEIL = 2;
11283
- Decimal.ROUND_FLOOR = 3;
11284
- Decimal.ROUND_HALF_UP = 4;
11285
- Decimal.ROUND_HALF_DOWN = 5;
11286
- Decimal.ROUND_HALF_EVEN = 6;
11287
- Decimal.ROUND_HALF_CEIL = 7;
11288
- Decimal.ROUND_HALF_FLOOR = 8;
11289
- Decimal.EUCLID = 9;
11290
- Decimal.config = Decimal.set = config;
11291
- Decimal.clone = clone$1;
11292
- Decimal.isDecimal = isDecimalInstance;
11293
- Decimal.abs = abs;
11294
- Decimal.acos = acos;
11295
- Decimal.acosh = acosh;
11296
- Decimal.add = add;
11297
- Decimal.asin = asin;
11298
- Decimal.asinh = asinh;
11299
- Decimal.atan = atan;
11300
- Decimal.atanh = atanh;
11301
- Decimal.atan2 = atan2;
11302
- Decimal.cbrt = cbrt;
11303
- Decimal.ceil = ceil;
11304
- Decimal.clamp = clamp$1;
11305
- Decimal.cos = cos;
11306
- Decimal.cosh = cosh;
11307
- Decimal.div = div;
11308
- Decimal.exp = exp;
11309
- Decimal.floor = floor;
11310
- Decimal.hypot = hypot;
11311
- Decimal.ln = ln;
11312
- Decimal.log = log;
11313
- Decimal.log10 = log10;
11314
- Decimal.log2 = log2;
11315
- Decimal.max = max;
11316
- Decimal.min = min;
11317
- Decimal.mod = mod;
11318
- Decimal.mul = mul;
11319
- Decimal.pow = pow;
11320
- Decimal.random = random;
11321
- Decimal.round = round;
11322
- Decimal.sign = sign$1;
11323
- Decimal.sin = sin;
11324
- Decimal.sinh = sinh;
11325
- Decimal.sqrt = sqrt;
11326
- Decimal.sub = sub;
11327
- Decimal.sum = sum;
11328
- Decimal.tan = tan;
11329
- Decimal.tanh = tanh;
11330
- Decimal.trunc = trunc;
11331
- if (obj === void 0) obj = {};
11332
- if (obj) {
11333
- if (obj.defaults !== true) {
11334
- ps = [
11335
- "precision",
11336
- "rounding",
11337
- "toExpNeg",
11338
- "toExpPos",
11339
- "maxE",
11340
- "minE",
11341
- "modulo",
11342
- "crypto"
11343
- ];
11344
- for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
9698
+ isNaN() {
9699
+ return false;
9700
+ }
9701
+ toNumber() {
9702
+ return Number(this.toString());
9703
+ }
9704
+ toString() {
9705
+ const c = abs(this.coefficient).toString(), sign = this.isNegative() ? "-" : "";
9706
+ const order = c.length + this.exponent - 1;
9707
+ if (this.isZero()) return "0";
9708
+ if (order <= -7 || order >= 21) return sign + c[0] + (c.length > 1 ? "." + c.slice(1) : "") + "e" + (order >= 0 ? "+" : "") + order;
9709
+ const point = c.length + this.exponent;
9710
+ return sign + (point <= 0 ? "0." + "0".repeat(-point) + c : point >= c.length ? c + "0".repeat(point - c.length) : c.slice(0, point) + "." + c.slice(point));
9711
+ }
9712
+ toFixed(decimalPlaces = 0, rounding = Decimal.rounding) {
9713
+ if (!Number.isInteger(decimalPlaces) || decimalPlaces < 0 || decimalPlaces > 1e3 || !Number.isInteger(rounding) || rounding < 0 || rounding > 8) throw new RangeError("Invalid decimal places or rounding");
9714
+ const shift = this.exponent + decimalPlaces;
9715
+ let q = this.coefficient;
9716
+ if (shift >= 0) q *= power(shift);
9717
+ else {
9718
+ const divisor = power(-shift), sign = q < 0n ? -1n : 1n, remainder = abs(q % divisor);
9719
+ q /= divisor;
9720
+ if (increment(q, remainder, divisor, sign, rounding)) q += sign;
11345
9721
  }
9722
+ const text = abs(q).toString().padStart(decimalPlaces + 1, "0");
9723
+ return (q < 0n ? "-" : "") + (decimalPlaces === 0 ? text : text.slice(0, -decimalPlaces) + "." + text.slice(-decimalPlaces));
11346
9724
  }
11347
- Decimal.config(obj);
11348
- return Decimal;
11349
- }
11350
- function div(x, y) {
11351
- return new this(x).div(y);
11352
- }
11353
- function exp(x) {
11354
- return new this(x).exp();
11355
- }
11356
- function floor(x) {
11357
- return finalise(x = new this(x), x.e + 1, 3);
11358
- }
11359
- function hypot() {
11360
- var i, n, t = new this(0);
11361
- external = false;
11362
- for (i = 0; i < arguments.length;) {
11363
- n = new this(arguments[i++]);
11364
- if (!n.d) {
11365
- if (n.s) {
11366
- external = true;
11367
- return new this(1 / 0);
11368
- }
11369
- t = n;
11370
- } else if (t.d) t = t.plus(n.times(n));
9725
+ toJSON() {
9726
+ return this.toString();
11371
9727
  }
11372
- external = true;
11373
- return t.sqrt();
11374
- }
11375
- function isDecimalInstance(obj) {
11376
- return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
11377
- }
11378
- function ln(x) {
11379
- return new this(x).ln();
11380
- }
11381
- function log(x, y) {
11382
- return new this(x).log(y);
11383
- }
11384
- function log2(x) {
11385
- return new this(x).log(2);
11386
- }
11387
- function log10(x) {
11388
- return new this(x).log(10);
11389
- }
11390
- function max() {
11391
- return maxOrMin(this, arguments, -1);
11392
- }
11393
- function min() {
11394
- return maxOrMin(this, arguments, 1);
11395
- }
11396
- function mod(x, y) {
11397
- return new this(x).mod(y);
11398
- }
11399
- function mul(x, y) {
11400
- return new this(x).mul(y);
11401
- }
11402
- function pow(x, y) {
11403
- return new this(x).pow(y);
11404
- }
11405
- function random(sd) {
11406
- var d, e, k, n, i = 0, r = new this(1), rd = [];
11407
- if (sd === void 0) sd = this.precision;
11408
- else checkInt32(sd, 1, MAX_DIGITS);
11409
- k = Math.ceil(sd / LOG_BASE);
11410
- if (!this.crypto) for (; i < k;) rd[i++] = Math.random() * 1e7 | 0;
11411
- else if (crypto.getRandomValues) {
11412
- d = crypto.getRandomValues(new Uint32Array(k));
11413
- for (; i < k;) {
11414
- n = d[i];
11415
- if (n >= 429e7) d[i] = crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
11416
- else rd[i++] = n % 1e7;
11417
- }
11418
- } else if (crypto.randomBytes) {
11419
- d = crypto.randomBytes(k *= 4);
11420
- for (; i < k;) {
11421
- n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
11422
- if (n >= 214e7) crypto.randomBytes(4).copy(d, i);
11423
- else {
11424
- rd.push(n % 1e7);
11425
- i += 4;
11426
- }
11427
- }
11428
- i = k / 4;
11429
- } else throw Error(cryptoUnavailable);
11430
- k = rd[--i];
11431
- sd %= LOG_BASE;
11432
- if (k && sd) {
11433
- n = mathpow(10, LOG_BASE - sd);
11434
- rd[i] = (k / n | 0) * n;
11435
- }
11436
- for (; rd[i] === 0; i--) rd.pop();
11437
- if (i < 0) {
11438
- e = 0;
11439
- rd = [0];
11440
- } else {
11441
- e = -1;
11442
- for (; rd[0] === 0; e -= LOG_BASE) rd.shift();
11443
- for (k = 1, n = rd[0]; n >= 10; n /= 10) k++;
11444
- if (k < LOG_BASE) e -= LOG_BASE - k;
11445
- }
11446
- r.e = e;
11447
- r.d = rd;
11448
- return r;
11449
- }
11450
- function round(x) {
11451
- return finalise(x = new this(x), x.e + 1, this.rounding);
11452
- }
11453
- function sign$1(x) {
11454
- x = new this(x);
11455
- return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
11456
- }
11457
- function sin(x) {
11458
- return new this(x).sin();
11459
- }
11460
- function sinh(x) {
11461
- return new this(x).sinh();
11462
- }
11463
- function sqrt(x) {
11464
- return new this(x).sqrt();
11465
- }
11466
- function sub(x, y) {
11467
- return new this(x).sub(y);
11468
- }
11469
- function sum() {
11470
- var i = 0, args = arguments, x = new this(args[i]);
11471
- external = false;
11472
- for (; x.s && ++i < args.length;) x = x.plus(args[i]);
11473
- external = true;
11474
- return finalise(x, this.precision, this.rounding);
11475
- }
11476
- function tan(x) {
11477
- return new this(x).tan();
11478
- }
11479
- function tanh(x) {
11480
- return new this(x).tanh();
11481
- }
11482
- function trunc(x) {
11483
- return finalise(x = new this(x), x.e + 1, 1);
11484
- }
11485
- P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
11486
- P[Symbol.toStringTag] = "Decimal";
11487
- var Decimal = P.constructor = clone$1(DEFAULTS);
11488
- LN10 = new Decimal(LN10);
11489
- PI$1 = new Decimal(PI$1);
9728
+ valueOf() {
9729
+ return this.toString();
9730
+ }
9731
+ };
11490
9732
  // src/math/HVec3.ts
11491
9733
  /** Mutable decimal vector. Pass strings to preserve more precision than a JS number. */
11492
9734
  var HVec3 = class HVec3 {
@@ -12377,1401 +10619,1274 @@ var Rectangle$1 = class Rectangle$1 {
12377
10619
  return result;
12378
10620
  }
12379
10621
  };
12380
- // src-gis/core/EllipsoidGeodesic.ts
12381
- var import_geographiclib_geodesic_min = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
12382
- var define;
12383
- (function(cb) {
12384
- var geodesic = {};
12385
- geodesic.Constants = {};
12386
- geodesic.Math = {};
12387
- geodesic.Accumulator = {};
12388
- (function(c) {
12389
- "use strict";
12390
- c.WGS84 = {
12391
- a: 6378137,
12392
- f: 1 / 298.257223563
12393
- };
12394
- c.version = {
12395
- major: 2,
12396
- minor: 2,
12397
- patch: 0
12398
- };
12399
- c.version_string = "2.2.0";
12400
- })(geodesic.Constants);
12401
- (function(m) {
12402
- "use strict";
12403
- m.digits = 53;
12404
- m.epsilon = Math.pow(.5, m.digits - 1);
12405
- m.degree = Math.PI / 180;
12406
- m.sq = function(x) {
12407
- return x * x;
12408
- };
12409
- m.hypot = function(x, y) {
12410
- return Math.sqrt(x * x + y * y);
12411
- };
12412
- m.cbrt = Math.cbrt || function(x) {
12413
- var y = Math.pow(Math.abs(x), 1 / 3);
12414
- return x > 0 ? y : x < 0 ? -y : x;
12415
- };
12416
- m.log1p = Math.log1p || function(x) {
12417
- var y = 1 + x, z = y - 1;
12418
- return z === 0 ? x : x * Math.log(y) / z;
12419
- };
12420
- m.atanh = Math.atanh || function(x) {
12421
- var y = Math.abs(x);
12422
- y = m.log1p(2 * y / (1 - y)) / 2;
12423
- return x > 0 ? y : x < 0 ? -y : x;
12424
- };
12425
- m.copysign = function(x, y) {
12426
- return Math.abs(x) * (y < 0 || y === 0 && 1 / y < 0 ? -1 : 1);
12427
- };
12428
- m.sum = function(u, v) {
12429
- var s = u + v, up = s - v, vpp = s - up, t;
12430
- up -= u;
12431
- vpp -= v;
12432
- t = s ? 0 - (up + vpp) : s;
12433
- return {
12434
- s,
12435
- t
12436
- };
12437
- };
12438
- m.polyval = function(N, p, s, x) {
12439
- var y = N < 0 ? 0 : p[s++];
12440
- while (--N >= 0) y = y * x + p[s++];
12441
- return y;
12442
- };
12443
- m.AngRound = function(x) {
12444
- var z = 1 / 16, y = Math.abs(x);
12445
- y = y < z ? z - (z - y) : y;
12446
- return m.copysign(y, x);
12447
- };
12448
- m.remainder = function(x, y) {
12449
- x %= y;
12450
- return x < -y / 2 ? x + y : x < y / 2 ? x : x - y;
12451
- };
12452
- m.AngNormalize = function(x) {
12453
- var y = m.remainder(x, 360);
12454
- return Math.abs(y) === 180 ? m.copysign(180, x) : y;
12455
- };
12456
- m.LatFix = function(x) {
12457
- return Math.abs(x) > 90 ? NaN : x;
12458
- };
12459
- m.AngDiff = function(x, y) {
12460
- var r = m.sum(m.remainder(-x, 360), m.remainder(y, 360)), d, e;
12461
- r = m.sum(m.remainder(r.s, 360), r.t);
12462
- d = r.s;
12463
- e = r.t;
12464
- if (d === 0 || Math.abs(d) === 180) d = m.copysign(d, e === 0 ? y - x : -e);
12465
- return {
12466
- d,
12467
- e
12468
- };
12469
- };
12470
- m.sincosd = function(x) {
12471
- var d = x % 360, r, q = Math.round(d / 90), s, c, sinx, cosx;
12472
- d -= 90 * q;
12473
- r = d * this.degree;
12474
- s = Math.sin(r);
12475
- c = Math.cos(r);
12476
- if (Math.abs(d) === 45) {
12477
- c = Math.sqrt(.5);
12478
- s = m.copysign(c, r);
12479
- } else if (Math.abs(d) === 30) {
12480
- c = Math.sqrt(.75);
12481
- s = m.copysign(.5, r);
12482
- }
12483
- switch (q & 3) {
12484
- case 0:
12485
- sinx = s;
12486
- cosx = c;
12487
- break;
12488
- case 1:
12489
- sinx = c;
12490
- cosx = -s;
12491
- break;
12492
- case 2:
12493
- sinx = -s;
12494
- cosx = -c;
12495
- break;
12496
- default:
12497
- sinx = -c;
12498
- cosx = s;
12499
- }
12500
- cosx += 0;
12501
- if (sinx === 0) sinx = m.copysign(sinx, x);
12502
- return {
12503
- s: sinx,
12504
- c: cosx
12505
- };
12506
- };
12507
- m.sincosde = function(x, t) {
12508
- var d = x % 360, r, q = Math.round(d / 90), s, c, sinx, cosx;
12509
- d = m.AngRound(d - 90 * q + t);
12510
- r = d * this.degree;
12511
- s = Math.sin(r);
12512
- c = Math.cos(r);
12513
- if (Math.abs(d) === 45) {
12514
- c = Math.sqrt(.5);
12515
- s = m.copysign(c, r);
12516
- } else if (Math.abs(d) === 30) {
12517
- c = Math.sqrt(.75);
12518
- s = m.copysign(.5, r);
12519
- }
12520
- switch (q & 3) {
12521
- case 0:
12522
- sinx = s;
12523
- cosx = c;
12524
- break;
12525
- case 1:
12526
- sinx = c;
12527
- cosx = -s;
12528
- break;
12529
- case 2:
12530
- sinx = -s;
12531
- cosx = -c;
12532
- break;
12533
- default:
12534
- sinx = -c;
12535
- cosx = s;
12536
- }
12537
- cosx += 0;
12538
- if (sinx === 0) sinx = m.copysign(sinx, x + t);
12539
- return {
12540
- s: sinx,
12541
- c: cosx
12542
- };
12543
- };
12544
- m.atan2d = function(y, x) {
12545
- var q = 0, ang;
12546
- if (Math.abs(y) > Math.abs(x)) {
12547
- [y, x] = [x, y];
12548
- q = 2;
12549
- }
12550
- if (m.copysign(1, x) < 0) {
12551
- x = -x;
12552
- ++q;
12553
- }
12554
- ang = Math.atan2(y, x) / this.degree;
12555
- switch (q) {
12556
- case 1:
12557
- ang = m.copysign(180, y) - ang;
12558
- break;
12559
- case 2:
12560
- ang = 90 - ang;
12561
- break;
12562
- case 3: ang = -90 + ang;
12563
- }
12564
- return ang;
12565
- };
12566
- })(geodesic.Math);
12567
- (function(a, m) {
12568
- "use strict";
12569
- a.Accumulator = function(y) {
12570
- this.Set(y);
12571
- };
12572
- a.Accumulator.prototype.Set = function(y) {
12573
- if (!y) y = 0;
12574
- if (y.constructor === a.Accumulator) {
12575
- this._s = y._s;
12576
- this._t = y._t;
12577
- } else {
12578
- this._s = y;
12579
- this._t = 0;
12580
- }
12581
- };
12582
- a.Accumulator.prototype.Add = function(y) {
12583
- var u = m.sum(y, this._t), v = m.sum(u.s, this._s);
12584
- u = u.t;
12585
- this._s = v.s;
12586
- this._t = v.t;
12587
- if (this._s === 0) this._s = u;
12588
- else this._t += u;
12589
- };
12590
- a.Accumulator.prototype.Sum = function(y) {
12591
- var b;
12592
- if (!y) return this._s;
12593
- else {
12594
- b = new a.Accumulator(this);
12595
- b.Add(y);
12596
- return b._s;
12597
- }
12598
- };
12599
- a.Accumulator.prototype.Negate = function() {
12600
- this._s *= -1;
12601
- this._t *= -1;
12602
- };
12603
- a.Accumulator.prototype.Remainder = function(y) {
12604
- this._s = m.remainder(this._s, y);
12605
- this.Add(0);
12606
- };
12607
- })(geodesic.Accumulator, geodesic.Math);
12608
- geodesic.Geodesic = {};
12609
- geodesic.GeodesicLine = {};
12610
- geodesic.PolygonArea = {};
12611
- (function(g, l, p, m, c) {
12612
- "use strict";
12613
- var GEOGRAPHICLIB_GEODESIC_ORDER = 6, nA1_ = GEOGRAPHICLIB_GEODESIC_ORDER, nA2_ = GEOGRAPHICLIB_GEODESIC_ORDER, nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER, nA3x_ = nA3_, nC3x_, nC4x_, maxit1_ = 20, maxit2_ = maxit1_ + m.digits + 10, tol0_ = m.epsilon, tol1_ = 200 * tol0_, tol2_ = Math.sqrt(tol0_), tolb_ = tol0_, xthresh_ = 1e3 * tol2_, CAP_NONE = 0, CAP_ALL = 31, OUT_ALL = 32640, astroid, A1m1f_coeff, C1f_coeff, C1pf_coeff, A2m1f_coeff, C2f_coeff, A3_coeff, C3_coeff, C4_coeff;
12614
- g.tiny_ = Math.sqrt(Number.MIN_VALUE / Number.EPSILON);
12615
- g.nC1_ = GEOGRAPHICLIB_GEODESIC_ORDER;
12616
- g.nC1p_ = GEOGRAPHICLIB_GEODESIC_ORDER;
12617
- g.nC2_ = GEOGRAPHICLIB_GEODESIC_ORDER;
12618
- g.nC3_ = GEOGRAPHICLIB_GEODESIC_ORDER;
12619
- g.nC4_ = GEOGRAPHICLIB_GEODESIC_ORDER;
12620
- nC3x_ = g.nC3_ * (g.nC3_ - 1) / 2;
12621
- nC4x_ = g.nC4_ * (g.nC4_ + 1) / 2;
12622
- g.CAP_C1 = 1;
12623
- g.CAP_C1p = 2;
12624
- g.CAP_C2 = 4;
12625
- g.CAP_C3 = 8;
12626
- g.CAP_C4 = 16;
12627
- g.NONE = 0;
12628
- g.ARC = 64;
12629
- g.LATITUDE = 128 | CAP_NONE;
12630
- g.LONGITUDE = 256 | g.CAP_C3;
12631
- g.AZIMUTH = 512 | CAP_NONE;
12632
- g.DISTANCE = 1024 | g.CAP_C1;
12633
- g.STANDARD = g.LATITUDE | g.LONGITUDE | g.AZIMUTH | g.DISTANCE;
12634
- g.DISTANCE_IN = 2048 | g.CAP_C1 | g.CAP_C1p;
12635
- g.REDUCEDLENGTH = 4096 | g.CAP_C1 | g.CAP_C2;
12636
- g.GEODESICSCALE = 8192 | g.CAP_C1 | g.CAP_C2;
12637
- g.AREA = 16384 | g.CAP_C4;
12638
- g.ALL = OUT_ALL | CAP_ALL;
12639
- g.LONG_UNROLL = 32768;
12640
- g.OUT_MASK = OUT_ALL | g.LONG_UNROLL;
12641
- g.SinCosSeries = function(sinp, sinx, cosx, c) {
12642
- var k = c.length, n = k - (sinp ? 1 : 0), ar = 2 * (cosx - sinx) * (cosx + sinx), y0 = n & 1 ? c[--k] : 0, y1 = 0;
12643
- n = Math.floor(n / 2);
12644
- while (n--) {
12645
- y1 = ar * y0 - y1 + c[--k];
12646
- y0 = ar * y1 - y0 + c[--k];
12647
- }
12648
- return sinp ? 2 * sinx * cosx * y0 : cosx * (y0 - y1);
12649
- };
12650
- astroid = function(x, y) {
12651
- var k, p = m.sq(x), q = m.sq(y), r = (p + q - 1) / 6, S, r2, r3, disc, u, T3, T, ang, v, uv, w;
12652
- if (!(q === 0 && r <= 0)) {
12653
- S = p * q / 4;
12654
- r2 = m.sq(r);
12655
- r3 = r * r2;
12656
- disc = S * (S + 2 * r3);
12657
- u = r;
12658
- if (disc >= 0) {
12659
- T3 = S + r3;
12660
- T3 += T3 < 0 ? -Math.sqrt(disc) : Math.sqrt(disc);
12661
- T = m.cbrt(T3);
12662
- u += T + (T !== 0 ? r2 / T : 0);
12663
- } else {
12664
- ang = Math.atan2(Math.sqrt(-disc), -(S + r3));
12665
- u += 2 * r * Math.cos(ang / 3);
12666
- }
12667
- v = Math.sqrt(m.sq(u) + q);
12668
- uv = u < 0 ? q / (v - u) : u + v;
12669
- w = (uv - q) / (2 * v);
12670
- k = uv / (Math.sqrt(uv + m.sq(w)) + w);
12671
- } else k = 0;
12672
- return k;
12673
- };
12674
- A1m1f_coeff = [
12675
- 1,
12676
- 4,
12677
- 64,
12678
- 0,
12679
- 256
12680
- ];
12681
- g.A1m1f = function(eps) {
12682
- var p = Math.floor(nA1_ / 2);
12683
- return (m.polyval(p, A1m1f_coeff, 0, m.sq(eps)) / A1m1f_coeff[p + 1] + eps) / (1 - eps);
12684
- };
12685
- C1f_coeff = [
12686
- -1,
12687
- 6,
12688
- -16,
12689
- 32,
12690
- -9,
12691
- 64,
12692
- -128,
12693
- 2048,
12694
- 9,
12695
- -16,
12696
- 768,
12697
- 3,
12698
- -5,
12699
- 512,
12700
- -7,
12701
- 1280,
12702
- -7,
12703
- 2048
12704
- ];
12705
- g.C1f = function(eps, c) {
12706
- var eps2 = m.sq(eps), d = eps, o = 0, l = 1, p;
12707
- for (; l <= g.nC1_; ++l) {
12708
- p = Math.floor((g.nC1_ - l) / 2);
12709
- c[l] = d * m.polyval(p, C1f_coeff, o, eps2) / C1f_coeff[o + p + 1];
12710
- o += p + 2;
12711
- d *= eps;
12712
- }
12713
- };
12714
- C1pf_coeff = [
12715
- 205,
12716
- -432,
12717
- 768,
12718
- 1536,
12719
- 4005,
12720
- -4736,
12721
- 3840,
12722
- 12288,
12723
- -225,
12724
- 116,
12725
- 384,
12726
- -7173,
12727
- 2695,
12728
- 7680,
12729
- 3467,
12730
- 7680,
12731
- 38081,
12732
- 61440
12733
- ];
12734
- g.C1pf = function(eps, c) {
12735
- var eps2 = m.sq(eps), d = eps, o = 0, l = 1, p;
12736
- for (; l <= g.nC1p_; ++l) {
12737
- p = Math.floor((g.nC1p_ - l) / 2);
12738
- c[l] = d * m.polyval(p, C1pf_coeff, o, eps2) / C1pf_coeff[o + p + 1];
12739
- o += p + 2;
12740
- d *= eps;
12741
- }
12742
- };
12743
- A2m1f_coeff = [
12744
- -11,
12745
- -28,
12746
- -192,
12747
- 0,
12748
- 256
12749
- ];
12750
- g.A2m1f = function(eps) {
12751
- var p = Math.floor(nA2_ / 2);
12752
- return (m.polyval(p, A2m1f_coeff, 0, m.sq(eps)) / A2m1f_coeff[p + 1] - eps) / (1 + eps);
12753
- };
12754
- C2f_coeff = [
12755
- 1,
12756
- 2,
12757
- 16,
12758
- 32,
12759
- 35,
12760
- 64,
12761
- 384,
12762
- 2048,
12763
- 15,
12764
- 80,
12765
- 768,
12766
- 7,
12767
- 35,
12768
- 512,
12769
- 63,
12770
- 1280,
12771
- 77,
12772
- 2048
12773
- ];
12774
- g.C2f = function(eps, c) {
12775
- var eps2 = m.sq(eps), d = eps, o = 0, l = 1, p;
12776
- for (; l <= g.nC2_; ++l) {
12777
- p = Math.floor((g.nC2_ - l) / 2);
12778
- c[l] = d * m.polyval(p, C2f_coeff, o, eps2) / C2f_coeff[o + p + 1];
12779
- o += p + 2;
12780
- d *= eps;
12781
- }
12782
- };
12783
- g.Geodesic = function(a, f) {
12784
- this.a = a;
12785
- this.f = f;
12786
- this._f1 = 1 - this.f;
12787
- this._e2 = this.f * (2 - this.f);
12788
- this._ep2 = this._e2 / m.sq(this._f1);
12789
- this._n = this.f / (2 - this.f);
12790
- this._b = this.a * this._f1;
12791
- this._c2 = (m.sq(this.a) + m.sq(this._b) * (this._e2 === 0 ? 1 : (this._e2 > 0 ? m.atanh(Math.sqrt(this._e2)) : Math.atan(Math.sqrt(-this._e2))) / Math.sqrt(Math.abs(this._e2)))) / 2;
12792
- this._etol2 = .1 * tol2_ / Math.sqrt(Math.max(.001, Math.abs(this.f)) * Math.min(1, 1 - this.f / 2) / 2);
12793
- if (!(isFinite(this.a) && this.a > 0)) throw new Error("Equatorial radius is not positive");
12794
- if (!(isFinite(this._b) && this._b > 0)) throw new Error("Polar semi-axis is not positive");
12795
- this._A3x = new Array(nA3x_);
12796
- this._C3x = new Array(nC3x_);
12797
- this._C4x = new Array(nC4x_);
12798
- this.A3coeff();
12799
- this.C3coeff();
12800
- this.C4coeff();
12801
- };
12802
- A3_coeff = [
12803
- -3,
12804
- 128,
12805
- -2,
12806
- -3,
12807
- 64,
12808
- -1,
12809
- -3,
12810
- -1,
12811
- 16,
12812
- 3,
12813
- -1,
12814
- -2,
12815
- 8,
12816
- 1,
12817
- -1,
12818
- 2,
12819
- 1,
12820
- 1
12821
- ];
12822
- g.Geodesic.prototype.A3coeff = function() {
12823
- var o = 0, k = 0, j = nA3_ - 1, p;
12824
- for (; j >= 0; --j) {
12825
- p = Math.min(nA3_ - j - 1, j);
12826
- this._A3x[k++] = m.polyval(p, A3_coeff, o, this._n) / A3_coeff[o + p + 1];
12827
- o += p + 2;
12828
- }
12829
- };
12830
- C3_coeff = [
12831
- 3,
12832
- 128,
12833
- 2,
12834
- 5,
12835
- 128,
12836
- -1,
12837
- 3,
12838
- 3,
12839
- 64,
12840
- -1,
12841
- 0,
12842
- 1,
12843
- 8,
12844
- -1,
12845
- 1,
12846
- 4,
12847
- 5,
12848
- 256,
12849
- 1,
12850
- 3,
12851
- 128,
12852
- -3,
12853
- -2,
12854
- 3,
12855
- 64,
12856
- 1,
12857
- -3,
12858
- 2,
12859
- 32,
12860
- 7,
12861
- 512,
12862
- -10,
12863
- 9,
12864
- 384,
12865
- 5,
12866
- -9,
12867
- 5,
12868
- 192,
12869
- 7,
12870
- 512,
12871
- -14,
12872
- 7,
12873
- 512,
12874
- 21,
12875
- 2560
12876
- ];
12877
- g.Geodesic.prototype.C3coeff = function() {
12878
- var o = 0, k = 0, l = 1, j, p;
12879
- for (; l < g.nC3_; ++l) for (j = g.nC3_ - 1; j >= l; --j) {
12880
- p = Math.min(g.nC3_ - j - 1, j);
12881
- this._C3x[k++] = m.polyval(p, C3_coeff, o, this._n) / C3_coeff[o + p + 1];
12882
- o += p + 2;
12883
- }
12884
- };
12885
- C4_coeff = [
12886
- 97,
12887
- 15015,
12888
- 1088,
12889
- 156,
12890
- 45045,
12891
- -224,
12892
- -4784,
12893
- 1573,
12894
- 45045,
12895
- -10656,
12896
- 14144,
12897
- -4576,
12898
- -858,
12899
- 45045,
12900
- 64,
12901
- 624,
12902
- -4576,
12903
- 6864,
12904
- -3003,
12905
- 15015,
12906
- 100,
12907
- 208,
12908
- 572,
12909
- 3432,
12910
- -12012,
12911
- 30030,
12912
- 45045,
12913
- 1,
12914
- 9009,
12915
- -2944,
12916
- 468,
12917
- 135135,
12918
- 5792,
12919
- 1040,
12920
- -1287,
12921
- 135135,
12922
- 5952,
12923
- -11648,
12924
- 9152,
12925
- -2574,
12926
- 135135,
12927
- -64,
12928
- -624,
12929
- 4576,
12930
- -6864,
12931
- 3003,
12932
- 135135,
12933
- 8,
12934
- 10725,
12935
- 1856,
12936
- -936,
12937
- 225225,
12938
- -8448,
12939
- 4992,
12940
- -1144,
12941
- 225225,
12942
- -1440,
12943
- 4160,
12944
- -4576,
12945
- 1716,
12946
- 225225,
12947
- -136,
12948
- 63063,
12949
- 1024,
12950
- -208,
12951
- 105105,
12952
- 3584,
12953
- -3328,
12954
- 1144,
12955
- 315315,
12956
- -128,
12957
- 135135,
12958
- -2560,
12959
- 832,
12960
- 405405,
12961
- 128,
12962
- 99099
12963
- ];
12964
- g.Geodesic.prototype.C4coeff = function() {
12965
- var o = 0, k = 0, l = 0, j, p;
12966
- for (; l < g.nC4_; ++l) for (j = g.nC4_ - 1; j >= l; --j) {
12967
- p = g.nC4_ - j - 1;
12968
- this._C4x[k++] = m.polyval(p, C4_coeff, o, this._n) / C4_coeff[o + p + 1];
12969
- o += p + 2;
12970
- }
12971
- };
12972
- g.Geodesic.prototype.A3f = function(eps) {
12973
- return m.polyval(nA3x_ - 1, this._A3x, 0, eps);
12974
- };
12975
- g.Geodesic.prototype.C3f = function(eps, c) {
12976
- var mult = 1, o = 0, l = 1, p;
12977
- for (; l < g.nC3_; ++l) {
12978
- p = g.nC3_ - l - 1;
12979
- mult *= eps;
12980
- c[l] = mult * m.polyval(p, this._C3x, o, eps);
12981
- o += p + 1;
12982
- }
12983
- };
12984
- g.Geodesic.prototype.C4f = function(eps, c) {
12985
- var mult = 1, o = 0, l = 0, p;
12986
- for (; l < g.nC4_; ++l) {
12987
- p = g.nC4_ - l - 1;
12988
- c[l] = mult * m.polyval(p, this._C4x, o, eps);
12989
- o += p + 1;
12990
- mult *= eps;
12991
- }
12992
- };
12993
- g.Geodesic.prototype.Lengths = function(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask, C1a, C2a) {
12994
- outmask &= g.OUT_MASK;
12995
- var vals = {}, m0x = 0, J12 = 0, A1 = 0, A2 = 0, B1, B2, l, csig12, t;
12996
- if (outmask & (g.DISTANCE | g.REDUCEDLENGTH | g.GEODESICSCALE)) {
12997
- A1 = g.A1m1f(eps);
12998
- g.C1f(eps, C1a);
12999
- if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
13000
- A2 = g.A2m1f(eps);
13001
- g.C2f(eps, C2a);
13002
- m0x = A1 - A2;
13003
- A2 = 1 + A2;
13004
- }
13005
- A1 = 1 + A1;
13006
- }
13007
- if (outmask & g.DISTANCE) {
13008
- B1 = g.SinCosSeries(true, ssig2, csig2, C1a) - g.SinCosSeries(true, ssig1, csig1, C1a);
13009
- vals.s12b = A1 * (sig12 + B1);
13010
- if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
13011
- B2 = g.SinCosSeries(true, ssig2, csig2, C2a) - g.SinCosSeries(true, ssig1, csig1, C2a);
13012
- J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
13013
- }
13014
- } else if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
13015
- for (l = 1; l <= g.nC2_; ++l) C2a[l] = A1 * C1a[l] - A2 * C2a[l];
13016
- J12 = m0x * sig12 + (g.SinCosSeries(true, ssig2, csig2, C2a) - g.SinCosSeries(true, ssig1, csig1, C2a));
13017
- }
13018
- if (outmask & g.REDUCEDLENGTH) {
13019
- vals.m0 = m0x;
13020
- vals.m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) - csig1 * csig2 * J12;
13021
- } else vals.m12b = NaN;
13022
- if (outmask & g.GEODESICSCALE) {
13023
- csig12 = csig1 * csig2 + ssig1 * ssig2;
13024
- t = this._ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
13025
- vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
13026
- vals.M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
13027
- }
13028
- return vals;
13029
- };
13030
- g.Geodesic.prototype.InverseStart = function(sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a) {
13031
- var vals = {}, sbet12 = sbet2 * cbet1 - cbet2 * sbet1, cbet12 = cbet2 * cbet1 + sbet2 * sbet1, sbet12a, shortline, omg12, sbetm2, somg12, comg12, t, ssig12, csig12, x, y, lamscale, betscale, k2, eps, cbet12a, bet12a, m12b, m0, nvals, k, omg12a, lam12x;
13032
- vals.sig12 = -1;
13033
- sbet12a = sbet2 * cbet1;
13034
- sbet12a += cbet2 * sbet1;
13035
- shortline = cbet12 >= 0 && sbet12 < .5 && cbet2 * lam12 < .5;
13036
- if (shortline) {
13037
- sbetm2 = m.sq(sbet1 + sbet2);
13038
- sbetm2 /= sbetm2 + m.sq(cbet1 + cbet2);
13039
- vals.dnm = Math.sqrt(1 + this._ep2 * sbetm2);
13040
- omg12 = lam12 / (this._f1 * vals.dnm);
13041
- somg12 = Math.sin(omg12);
13042
- comg12 = Math.cos(omg12);
10622
+ var epsilon = Math.pow(.5, 52);
10623
+ var degree = Math.PI / 180;
10624
+ function sq(x) {
10625
+ return x * x;
10626
+ }
10627
+ function hypot(x, y) {
10628
+ return Math.sqrt(x * x + y * y);
10629
+ }
10630
+ var cbrt = Math.cbrt;
10631
+ var atanh = Math.atanh;
10632
+ function copysign(x, y) {
10633
+ return Math.abs(x) * (y < 0 || y === 0 && 1 / y < 0 ? -1 : 1);
10634
+ }
10635
+ function sum(u, v) {
10636
+ var s = u + v, up = s - v, vpp = s - up, t;
10637
+ up -= u;
10638
+ vpp -= v;
10639
+ t = s ? 0 - (up + vpp) : s;
10640
+ return {
10641
+ s,
10642
+ t
10643
+ };
10644
+ }
10645
+ function polyval(N, p, s, x) {
10646
+ var y = N < 0 ? 0 : p[s++];
10647
+ while (--N >= 0) y = y * x + p[s++];
10648
+ return y;
10649
+ }
10650
+ function AngRound(x) {
10651
+ var z = 1 / 16, y = Math.abs(x);
10652
+ y = y < z ? z - (z - y) : y;
10653
+ return copysign(y, x);
10654
+ }
10655
+ function remainder(x, y) {
10656
+ x %= y;
10657
+ return x < -y / 2 ? x + y : x < y / 2 ? x : x - y;
10658
+ }
10659
+ function AngNormalize(x) {
10660
+ var y = remainder(x, 360);
10661
+ return Math.abs(y) === 180 ? copysign(180, x) : y;
10662
+ }
10663
+ function LatFix(x) {
10664
+ return Math.abs(x) > 90 ? NaN : x;
10665
+ }
10666
+ function AngDiff(x, y) {
10667
+ var r = sum(remainder(-x, 360), remainder(y, 360)), d, e;
10668
+ r = sum(remainder(r.s, 360), r.t);
10669
+ d = r.s;
10670
+ e = r.t;
10671
+ if (d === 0 || Math.abs(d) === 180) d = copysign(d, e === 0 ? y - x : -e);
10672
+ return {
10673
+ d,
10674
+ e
10675
+ };
10676
+ }
10677
+ function sincosd(x) {
10678
+ var d = x % 360, r, q = Math.round(d / 90), s, c, sinx, cosx;
10679
+ d -= 90 * q;
10680
+ r = d * degree;
10681
+ s = Math.sin(r);
10682
+ c = Math.cos(r);
10683
+ if (Math.abs(d) === 45) {
10684
+ c = Math.sqrt(.5);
10685
+ s = copysign(c, r);
10686
+ } else if (Math.abs(d) === 30) {
10687
+ c = Math.sqrt(.75);
10688
+ s = copysign(.5, r);
10689
+ }
10690
+ switch (q & 3) {
10691
+ case 0:
10692
+ sinx = s;
10693
+ cosx = c;
10694
+ break;
10695
+ case 1:
10696
+ sinx = c;
10697
+ cosx = -s;
10698
+ break;
10699
+ case 2:
10700
+ sinx = -s;
10701
+ cosx = -c;
10702
+ break;
10703
+ default:
10704
+ sinx = -c;
10705
+ cosx = s;
10706
+ }
10707
+ cosx += 0;
10708
+ if (sinx === 0) sinx = copysign(sinx, x);
10709
+ return {
10710
+ s: sinx,
10711
+ c: cosx
10712
+ };
10713
+ }
10714
+ function sincosde(x, t) {
10715
+ var d = x % 360, r, q = Math.round(d / 90), s, c, sinx, cosx;
10716
+ d = AngRound(d - 90 * q + t);
10717
+ r = d * degree;
10718
+ s = Math.sin(r);
10719
+ c = Math.cos(r);
10720
+ if (Math.abs(d) === 45) {
10721
+ c = Math.sqrt(.5);
10722
+ s = copysign(c, r);
10723
+ } else if (Math.abs(d) === 30) {
10724
+ c = Math.sqrt(.75);
10725
+ s = copysign(.5, r);
10726
+ }
10727
+ switch (q & 3) {
10728
+ case 0:
10729
+ sinx = s;
10730
+ cosx = c;
10731
+ break;
10732
+ case 1:
10733
+ sinx = c;
10734
+ cosx = -s;
10735
+ break;
10736
+ case 2:
10737
+ sinx = -s;
10738
+ cosx = -c;
10739
+ break;
10740
+ default:
10741
+ sinx = -c;
10742
+ cosx = s;
10743
+ }
10744
+ cosx += 0;
10745
+ if (sinx === 0) sinx = copysign(sinx, x + t);
10746
+ return {
10747
+ s: sinx,
10748
+ c: cosx
10749
+ };
10750
+ }
10751
+ function atan2d(y, x) {
10752
+ var q = 0, ang;
10753
+ if (Math.abs(y) > Math.abs(x)) {
10754
+ [y, x] = [x, y];
10755
+ q = 2;
10756
+ }
10757
+ if (copysign(1, x) < 0) {
10758
+ x = -x;
10759
+ ++q;
10760
+ }
10761
+ ang = Math.atan2(y, x) / degree;
10762
+ switch (q) {
10763
+ case 1:
10764
+ ang = copysign(180, y) - ang;
10765
+ break;
10766
+ case 2:
10767
+ ang = 90 - ang;
10768
+ break;
10769
+ case 3: ang = -90 + ang;
10770
+ }
10771
+ return ang;
10772
+ }
10773
+ // src-gis/math/geodesic/kernel.ts
10774
+ /**
10775
+ * Internal TypeScript port of Karney's order-6 geodesic solver.
10776
+ * Derived from GeographicLib geodesic 2.2.0 (2011–2022, Charles Karney), MIT.
10777
+ * Algorithm: https://doi.org/10.1007/s00190-012-0578-z
10778
+ * See THIRD_PARTY_NOTICES.md. No runtime package or global namespace is used.
10779
+ */
10780
+ var GEOGRAPHICLIB_GEODESIC_ORDER = 6;
10781
+ var nA1_ = GEOGRAPHICLIB_GEODESIC_ORDER;
10782
+ var nA2_ = GEOGRAPHICLIB_GEODESIC_ORDER;
10783
+ var nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER;
10784
+ var nA3x_ = nA3_;
10785
+ var nC3x_;
10786
+ var nC4x_;
10787
+ var maxit1_ = 20;
10788
+ var maxit2_ = maxit1_ + 53 + 10;
10789
+ var tol0_ = epsilon;
10790
+ var tol1_ = 200 * tol0_;
10791
+ var tol2_ = Math.sqrt(tol0_);
10792
+ var tolb_ = tol0_;
10793
+ var xthresh_ = 1e3 * tol2_;
10794
+ var A1m1f_coeff;
10795
+ var C1f_coeff;
10796
+ var C1pf_coeff;
10797
+ var A2m1f_coeff;
10798
+ var C2f_coeff;
10799
+ var A3_coeff;
10800
+ var C3_coeff;
10801
+ var C4_coeff;
10802
+ var tiny_ = Math.sqrt(Number.MIN_VALUE / Number.EPSILON);
10803
+ nC3x_ = 15;
10804
+ nC4x_ = 21;
10805
+ var DISTANCE = 1025;
10806
+ var STANDARD = 1929;
10807
+ var DISTANCE_IN = 2051;
10808
+ var REDUCEDLENGTH = 4101;
10809
+ var OUT_MASK = 65408;
10810
+ function SinCosSeries(sinp, sinx, cosx, c) {
10811
+ let k = c.length, n = k - (sinp ? 1 : 0), ar = 2 * (cosx - sinx) * (cosx + sinx), y0 = n & 1 ? c[--k] : 0, y1 = 0;
10812
+ n = Math.floor(n / 2);
10813
+ while (n--) {
10814
+ y1 = ar * y0 - y1 + c[--k];
10815
+ y0 = ar * y1 - y0 + c[--k];
10816
+ }
10817
+ return sinp ? 2 * sinx * cosx * y0 : cosx * (y0 - y1);
10818
+ }
10819
+ function astroid(x, y) {
10820
+ let k, p = sq(x), q = sq(y), r = (p + q - 1) / 6, S, r2, r3, disc, u, T3, T, ang, v, uv, w;
10821
+ if (!(q === 0 && r <= 0)) {
10822
+ S = p * q / 4;
10823
+ r2 = sq(r);
10824
+ r3 = r * r2;
10825
+ disc = S * (S + 2 * r3);
10826
+ u = r;
10827
+ if (disc >= 0) {
10828
+ T3 = S + r3;
10829
+ T3 += T3 < 0 ? -Math.sqrt(disc) : Math.sqrt(disc);
10830
+ T = cbrt(T3);
10831
+ u += T + (T !== 0 ? r2 / T : 0);
10832
+ } else {
10833
+ ang = Math.atan2(Math.sqrt(-disc), -(S + r3));
10834
+ u += 2 * r * Math.cos(ang / 3);
10835
+ }
10836
+ v = Math.sqrt(sq(u) + q);
10837
+ uv = u < 0 ? q / (v - u) : u + v;
10838
+ w = (uv - q) / (2 * v);
10839
+ k = uv / (Math.sqrt(uv + sq(w)) + w);
10840
+ } else k = 0;
10841
+ return k;
10842
+ }
10843
+ A1m1f_coeff = [
10844
+ 1,
10845
+ 4,
10846
+ 64,
10847
+ 0,
10848
+ 256
10849
+ ];
10850
+ function A1m1f(eps) {
10851
+ return (polyval(Math.floor(nA1_ / 2), A1m1f_coeff, 0, sq(eps)) / A1m1f_coeff[4] + eps) / (1 - eps);
10852
+ }
10853
+ C1f_coeff = [
10854
+ -1,
10855
+ 6,
10856
+ -16,
10857
+ 32,
10858
+ -9,
10859
+ 64,
10860
+ -128,
10861
+ 2048,
10862
+ 9,
10863
+ -16,
10864
+ 768,
10865
+ 3,
10866
+ -5,
10867
+ 512,
10868
+ -7,
10869
+ 1280,
10870
+ -7,
10871
+ 2048
10872
+ ];
10873
+ function C1f(eps, c) {
10874
+ let eps2 = sq(eps), d = eps, o = 0, l, p;
10875
+ for (l = 1; l <= 6; ++l) {
10876
+ p = Math.floor((6 - l) / 2);
10877
+ c[l] = d * polyval(p, C1f_coeff, o, eps2) / C1f_coeff[o + p + 1];
10878
+ o += p + 2;
10879
+ d *= eps;
10880
+ }
10881
+ }
10882
+ C1pf_coeff = [
10883
+ 205,
10884
+ -432,
10885
+ 768,
10886
+ 1536,
10887
+ 4005,
10888
+ -4736,
10889
+ 3840,
10890
+ 12288,
10891
+ -225,
10892
+ 116,
10893
+ 384,
10894
+ -7173,
10895
+ 2695,
10896
+ 7680,
10897
+ 3467,
10898
+ 7680,
10899
+ 38081,
10900
+ 61440
10901
+ ];
10902
+ function C1pf(eps, c) {
10903
+ let eps2 = sq(eps), d = eps, o = 0, l, p;
10904
+ for (l = 1; l <= 6; ++l) {
10905
+ p = Math.floor((6 - l) / 2);
10906
+ c[l] = d * polyval(p, C1pf_coeff, o, eps2) / C1pf_coeff[o + p + 1];
10907
+ o += p + 2;
10908
+ d *= eps;
10909
+ }
10910
+ }
10911
+ A2m1f_coeff = [
10912
+ -11,
10913
+ -28,
10914
+ -192,
10915
+ 0,
10916
+ 256
10917
+ ];
10918
+ function A2m1f(eps) {
10919
+ return (polyval(Math.floor(nA2_ / 2), A2m1f_coeff, 0, sq(eps)) / A2m1f_coeff[4] - eps) / (1 + eps);
10920
+ }
10921
+ C2f_coeff = [
10922
+ 1,
10923
+ 2,
10924
+ 16,
10925
+ 32,
10926
+ 35,
10927
+ 64,
10928
+ 384,
10929
+ 2048,
10930
+ 15,
10931
+ 80,
10932
+ 768,
10933
+ 7,
10934
+ 35,
10935
+ 512,
10936
+ 63,
10937
+ 1280,
10938
+ 77,
10939
+ 2048
10940
+ ];
10941
+ function C2f(eps, c) {
10942
+ let eps2 = sq(eps), d = eps, o = 0, l, p;
10943
+ for (l = 1; l <= 6; ++l) {
10944
+ p = Math.floor((6 - l) / 2);
10945
+ c[l] = d * polyval(p, C2f_coeff, o, eps2) / C2f_coeff[o + p + 1];
10946
+ o += p + 2;
10947
+ d *= eps;
10948
+ }
10949
+ }
10950
+ A3_coeff = [
10951
+ -3,
10952
+ 128,
10953
+ -2,
10954
+ -3,
10955
+ 64,
10956
+ -1,
10957
+ -3,
10958
+ -1,
10959
+ 16,
10960
+ 3,
10961
+ -1,
10962
+ -2,
10963
+ 8,
10964
+ 1,
10965
+ -1,
10966
+ 2,
10967
+ 1,
10968
+ 1
10969
+ ];
10970
+ C3_coeff = [
10971
+ 3,
10972
+ 128,
10973
+ 2,
10974
+ 5,
10975
+ 128,
10976
+ -1,
10977
+ 3,
10978
+ 3,
10979
+ 64,
10980
+ -1,
10981
+ 0,
10982
+ 1,
10983
+ 8,
10984
+ -1,
10985
+ 1,
10986
+ 4,
10987
+ 5,
10988
+ 256,
10989
+ 1,
10990
+ 3,
10991
+ 128,
10992
+ -3,
10993
+ -2,
10994
+ 3,
10995
+ 64,
10996
+ 1,
10997
+ -3,
10998
+ 2,
10999
+ 32,
11000
+ 7,
11001
+ 512,
11002
+ -10,
11003
+ 9,
11004
+ 384,
11005
+ 5,
11006
+ -9,
11007
+ 5,
11008
+ 192,
11009
+ 7,
11010
+ 512,
11011
+ -14,
11012
+ 7,
11013
+ 512,
11014
+ 21,
11015
+ 2560
11016
+ ];
11017
+ C4_coeff = [
11018
+ 97,
11019
+ 15015,
11020
+ 1088,
11021
+ 156,
11022
+ 45045,
11023
+ -224,
11024
+ -4784,
11025
+ 1573,
11026
+ 45045,
11027
+ -10656,
11028
+ 14144,
11029
+ -4576,
11030
+ -858,
11031
+ 45045,
11032
+ 64,
11033
+ 624,
11034
+ -4576,
11035
+ 6864,
11036
+ -3003,
11037
+ 15015,
11038
+ 100,
11039
+ 208,
11040
+ 572,
11041
+ 3432,
11042
+ -12012,
11043
+ 30030,
11044
+ 45045,
11045
+ 1,
11046
+ 9009,
11047
+ -2944,
11048
+ 468,
11049
+ 135135,
11050
+ 5792,
11051
+ 1040,
11052
+ -1287,
11053
+ 135135,
11054
+ 5952,
11055
+ -11648,
11056
+ 9152,
11057
+ -2574,
11058
+ 135135,
11059
+ -64,
11060
+ -624,
11061
+ 4576,
11062
+ -6864,
11063
+ 3003,
11064
+ 135135,
11065
+ 8,
11066
+ 10725,
11067
+ 1856,
11068
+ -936,
11069
+ 225225,
11070
+ -8448,
11071
+ 4992,
11072
+ -1144,
11073
+ 225225,
11074
+ -1440,
11075
+ 4160,
11076
+ -4576,
11077
+ 1716,
11078
+ 225225,
11079
+ -136,
11080
+ 63063,
11081
+ 1024,
11082
+ -208,
11083
+ 105105,
11084
+ 3584,
11085
+ -3328,
11086
+ 1144,
11087
+ 315315,
11088
+ -128,
11089
+ 135135,
11090
+ -2560,
11091
+ 832,
11092
+ 405405,
11093
+ 128,
11094
+ 99099
11095
+ ];
11096
+ var Geodesic = class {
11097
+ a = NaN;
11098
+ f = NaN;
11099
+ _f1 = NaN;
11100
+ _e2 = NaN;
11101
+ _ep2 = NaN;
11102
+ _n = NaN;
11103
+ _b = NaN;
11104
+ _c2 = NaN;
11105
+ _etol2 = NaN;
11106
+ _A3x = [];
11107
+ _C3x = [];
11108
+ _C4x = [];
11109
+ constructor(a, f) {
11110
+ this.a = a;
11111
+ this.f = f;
11112
+ this._f1 = 1 - this.f;
11113
+ this._e2 = this.f * (2 - this.f);
11114
+ this._ep2 = this._e2 / sq(this._f1);
11115
+ this._n = this.f / (2 - this.f);
11116
+ this._b = this.a * this._f1;
11117
+ this._c2 = (sq(this.a) + sq(this._b) * (this._e2 === 0 ? 1 : (this._e2 > 0 ? atanh(Math.sqrt(this._e2)) : Math.atan(Math.sqrt(-this._e2))) / Math.sqrt(Math.abs(this._e2)))) / 2;
11118
+ this._etol2 = .1 * tol2_ / Math.sqrt(Math.max(.001, Math.abs(this.f)) * Math.min(1, 1 - this.f / 2) / 2);
11119
+ if (!(isFinite(this.a) && this.a > 0)) throw new RangeError("Equatorial radius is not positive");
11120
+ if (!(isFinite(this._b) && this._b > 0)) throw new RangeError("Polar semi-axis is not positive");
11121
+ this._A3x = new Array(nA3x_);
11122
+ this._C3x = new Array(nC3x_);
11123
+ this._C4x = new Array(nC4x_);
11124
+ this.A3coeff();
11125
+ this.C3coeff();
11126
+ this.C4coeff();
11127
+ }
11128
+ A3coeff() {
11129
+ let o = 0, k = 0, j, p;
11130
+ for (j = 5; j >= 0; --j) {
11131
+ p = Math.min(nA3_ - j - 1, j);
11132
+ this._A3x[k++] = polyval(p, A3_coeff, o, this._n) / A3_coeff[o + p + 1];
11133
+ o += p + 2;
11134
+ }
11135
+ }
11136
+ C3coeff() {
11137
+ let o = 0, k = 0, l, j, p;
11138
+ for (l = 1; l < 6; ++l) for (j = 5; j >= l; --j) {
11139
+ p = Math.min(6 - j - 1, j);
11140
+ this._C3x[k++] = polyval(p, C3_coeff, o, this._n) / C3_coeff[o + p + 1];
11141
+ o += p + 2;
11142
+ }
11143
+ }
11144
+ C4coeff() {
11145
+ let o = 0, k = 0, l, j, p;
11146
+ for (l = 0; l < 6; ++l) for (j = 5; j >= l; --j) {
11147
+ p = 6 - j - 1;
11148
+ this._C4x[k++] = polyval(p, C4_coeff, o, this._n) / C4_coeff[o + p + 1];
11149
+ o += p + 2;
11150
+ }
11151
+ }
11152
+ A3f(eps) {
11153
+ return polyval(5, this._A3x, 0, eps);
11154
+ }
11155
+ C3f(eps, c) {
11156
+ let mult = 1, o = 0, l, p;
11157
+ for (l = 1; l < 6; ++l) {
11158
+ p = 6 - l - 1;
11159
+ mult *= eps;
11160
+ c[l] = mult * polyval(p, this._C3x, o, eps);
11161
+ o += p + 1;
11162
+ }
11163
+ }
11164
+ C4f(eps, c) {
11165
+ let mult = 1, o = 0, l, p;
11166
+ for (l = 0; l < 6; ++l) {
11167
+ p = 6 - l - 1;
11168
+ c[l] = mult * polyval(p, this._C4x, o, eps);
11169
+ o += p + 1;
11170
+ mult *= eps;
11171
+ }
11172
+ }
11173
+ Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask = 0, C1a, C2a) {
11174
+ outmask &= OUT_MASK;
11175
+ let vals = {
11176
+ s12b: NaN,
11177
+ m0: NaN,
11178
+ m12b: NaN,
11179
+ M12: NaN,
11180
+ M21: NaN
11181
+ }, m0x = 0, J12 = 0, A1 = 0, A2 = 0, B1, B2, l, csig12, t;
11182
+ if (outmask & 13317) {
11183
+ A1 = A1m1f(eps);
11184
+ C1f(eps, C1a);
11185
+ if (outmask & 12293) {
11186
+ A2 = A2m1f(eps);
11187
+ C2f(eps, C2a);
11188
+ m0x = A1 - A2;
11189
+ A2 = 1 + A2;
11190
+ }
11191
+ A1 = 1 + A1;
11192
+ }
11193
+ if (outmask & 1025) {
11194
+ B1 = SinCosSeries(true, ssig2, csig2, C1a) - SinCosSeries(true, ssig1, csig1, C1a);
11195
+ vals.s12b = A1 * (sig12 + B1);
11196
+ if (outmask & 12293) {
11197
+ B2 = SinCosSeries(true, ssig2, csig2, C2a) - SinCosSeries(true, ssig1, csig1, C2a);
11198
+ J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
11199
+ }
11200
+ } else if (outmask & 12293) {
11201
+ for (l = 1; l <= 6; ++l) C2a[l] = A1 * C1a[l] - A2 * C2a[l];
11202
+ J12 = m0x * sig12 + (SinCosSeries(true, ssig2, csig2, C2a) - SinCosSeries(true, ssig1, csig1, C2a));
11203
+ }
11204
+ if (outmask & 4101) {
11205
+ vals.m0 = m0x;
11206
+ vals.m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) - csig1 * csig2 * J12;
11207
+ } else vals.m12b = NaN;
11208
+ if (outmask & 8197) {
11209
+ csig12 = csig1 * csig2 + ssig1 * ssig2;
11210
+ t = this._ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
11211
+ vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
11212
+ vals.M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
11213
+ }
11214
+ return vals;
11215
+ }
11216
+ InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a) {
11217
+ let vals = {
11218
+ sig12: NaN,
11219
+ dnm: NaN,
11220
+ salp1: NaN,
11221
+ calp1: NaN,
11222
+ salp2: NaN,
11223
+ calp2: NaN
11224
+ }, sbet12 = sbet2 * cbet1 - cbet2 * sbet1, cbet12 = cbet2 * cbet1 + sbet2 * sbet1, sbet12a, shortline, omg12, sbetm2, somg12, comg12, t, ssig12, csig12, x, y, lamscale, betscale, k2, eps, cbet12a, bet12a, m12b, m0, nvals, k, omg12a, lam12x;
11225
+ vals.sig12 = -1;
11226
+ sbet12a = sbet2 * cbet1;
11227
+ sbet12a += cbet2 * sbet1;
11228
+ shortline = cbet12 >= 0 && sbet12 < .5 && cbet2 * lam12 < .5;
11229
+ if (shortline) {
11230
+ sbetm2 = sq(sbet1 + sbet2);
11231
+ sbetm2 /= sbetm2 + sq(cbet1 + cbet2);
11232
+ vals.dnm = Math.sqrt(1 + this._ep2 * sbetm2);
11233
+ omg12 = lam12 / (this._f1 * vals.dnm);
11234
+ somg12 = Math.sin(omg12);
11235
+ comg12 = Math.cos(omg12);
11236
+ } else {
11237
+ somg12 = slam12;
11238
+ comg12 = clam12;
11239
+ }
11240
+ vals.salp1 = cbet2 * somg12;
11241
+ vals.calp1 = comg12 >= 0 ? sbet12 + cbet2 * sbet1 * sq(somg12) / (1 + comg12) : sbet12a - cbet2 * sbet1 * sq(somg12) / (1 - comg12);
11242
+ ssig12 = hypot(vals.salp1, vals.calp1);
11243
+ csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
11244
+ if (shortline && ssig12 < this._etol2) {
11245
+ vals.salp2 = cbet1 * somg12;
11246
+ vals.calp2 = sbet12 - cbet1 * sbet2 * (comg12 >= 0 ? sq(somg12) / (1 + comg12) : 1 - comg12);
11247
+ t = hypot(vals.salp2, vals.calp2);
11248
+ vals.salp2 /= t;
11249
+ vals.calp2 /= t;
11250
+ vals.sig12 = Math.atan2(ssig12, csig12);
11251
+ } else if (Math.abs(this._n) > .1 || csig12 >= 0 || ssig12 >= 6 * Math.abs(this._n) * Math.PI * sq(cbet1)) {} else {
11252
+ lam12x = Math.atan2(-slam12, -clam12);
11253
+ if (this.f >= 0) {
11254
+ k2 = sq(sbet1) * this._ep2;
11255
+ eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
11256
+ lamscale = this.f * cbet1 * this.A3f(eps) * Math.PI;
11257
+ betscale = lamscale * cbet1;
11258
+ x = lam12x / lamscale;
11259
+ y = sbet12a / betscale;
11260
+ } else {
11261
+ cbet12a = cbet2 * cbet1 - sbet2 * sbet1;
11262
+ bet12a = Math.atan2(sbet12a, cbet12a);
11263
+ nvals = this.Lengths(this._n, Math.PI + bet12a, sbet1, -cbet1, dn1, sbet2, cbet2, dn2, cbet1, cbet2, REDUCEDLENGTH, C1a, C2a);
11264
+ m12b = nvals.m12b;
11265
+ m0 = nvals.m0;
11266
+ x = -1 + m12b / (cbet1 * cbet2 * m0 * Math.PI);
11267
+ betscale = x < -.01 ? sbet12a / x : -this.f * sq(cbet1) * Math.PI;
11268
+ lamscale = betscale / cbet1;
11269
+ y = lam12 / lamscale;
11270
+ }
11271
+ if (y > -tol1_ && x > -1 - xthresh_) {
11272
+ if (this.f >= 0) {
11273
+ vals.salp1 = Math.min(1, -x);
11274
+ vals.calp1 = -Math.sqrt(1 - sq(vals.salp1));
13043
11275
  } else {
13044
- somg12 = slam12;
13045
- comg12 = clam12;
11276
+ vals.calp1 = Math.max(x > -tol1_ ? 0 : -1, x);
11277
+ vals.salp1 = Math.sqrt(1 - sq(vals.calp1));
13046
11278
  }
11279
+ } else {
11280
+ k = astroid(x, y);
11281
+ omg12a = lamscale * (this.f >= 0 ? -x * k / (1 + k) : -y * (1 + k) / k);
11282
+ somg12 = Math.sin(omg12a);
11283
+ comg12 = -Math.cos(omg12a);
13047
11284
  vals.salp1 = cbet2 * somg12;
13048
- vals.calp1 = comg12 >= 0 ? sbet12 + cbet2 * sbet1 * m.sq(somg12) / (1 + comg12) : sbet12a - cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
13049
- ssig12 = m.hypot(vals.salp1, vals.calp1);
13050
- csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
13051
- if (shortline && ssig12 < this._etol2) {
13052
- vals.salp2 = cbet1 * somg12;
13053
- vals.calp2 = sbet12 - cbet1 * sbet2 * (comg12 >= 0 ? m.sq(somg12) / (1 + comg12) : 1 - comg12);
13054
- t = m.hypot(vals.salp2, vals.calp2);
13055
- vals.salp2 /= t;
13056
- vals.calp2 /= t;
13057
- vals.sig12 = Math.atan2(ssig12, csig12);
13058
- } else if (Math.abs(this._n) > .1 || csig12 >= 0 || ssig12 >= 6 * Math.abs(this._n) * Math.PI * m.sq(cbet1)) {} else {
13059
- lam12x = Math.atan2(-slam12, -clam12);
13060
- if (this.f >= 0) {
13061
- k2 = m.sq(sbet1) * this._ep2;
13062
- eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
13063
- lamscale = this.f * cbet1 * this.A3f(eps) * Math.PI;
13064
- betscale = lamscale * cbet1;
13065
- x = lam12x / lamscale;
13066
- y = sbet12a / betscale;
13067
- } else {
13068
- cbet12a = cbet2 * cbet1 - sbet2 * sbet1;
13069
- bet12a = Math.atan2(sbet12a, cbet12a);
13070
- nvals = this.Lengths(this._n, Math.PI + bet12a, sbet1, -cbet1, dn1, sbet2, cbet2, dn2, cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
13071
- m12b = nvals.m12b;
13072
- m0 = nvals.m0;
13073
- x = -1 + m12b / (cbet1 * cbet2 * m0 * Math.PI);
13074
- betscale = x < -.01 ? sbet12a / x : -this.f * m.sq(cbet1) * Math.PI;
13075
- lamscale = betscale / cbet1;
13076
- y = lam12 / lamscale;
13077
- }
13078
- if (y > -tol1_ && x > -1 - xthresh_) {
13079
- if (this.f >= 0) {
13080
- vals.salp1 = Math.min(1, -x);
13081
- vals.calp1 = -Math.sqrt(1 - m.sq(vals.salp1));
13082
- } else {
13083
- vals.calp1 = Math.max(x > -tol1_ ? 0 : -1, x);
13084
- vals.salp1 = Math.sqrt(1 - m.sq(vals.calp1));
13085
- }
13086
- } else {
13087
- k = astroid(x, y);
13088
- omg12a = lamscale * (this.f >= 0 ? -x * k / (1 + k) : -y * (1 + k) / k);
13089
- somg12 = Math.sin(omg12a);
13090
- comg12 = -Math.cos(omg12a);
13091
- vals.salp1 = cbet2 * somg12;
13092
- vals.calp1 = sbet12a - cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
13093
- }
13094
- }
13095
- if (!(vals.salp1 <= 0)) {
13096
- t = m.hypot(vals.salp1, vals.calp1);
13097
- vals.salp1 /= t;
13098
- vals.calp1 /= t;
13099
- } else {
13100
- vals.salp1 = 1;
13101
- vals.calp1 = 0;
13102
- }
13103
- return vals;
13104
- };
13105
- g.Geodesic.prototype.Lambda12 = function(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam120, clam120, diffp, C1a, C2a, C3a) {
13106
- var vals = {}, t, salp0, calp0, somg1, comg1, somg2, comg2, somg12, comg12, B312, eta, k2, nvals;
13107
- if (sbet1 === 0 && calp1 === 0) calp1 = -g.tiny_;
13108
- salp0 = salp1 * cbet1;
13109
- calp0 = m.hypot(calp1, salp1 * sbet1);
13110
- vals.ssig1 = sbet1;
13111
- somg1 = salp0 * sbet1;
13112
- vals.csig1 = comg1 = calp1 * cbet1;
13113
- t = m.hypot(vals.ssig1, vals.csig1);
13114
- vals.ssig1 /= t;
13115
- vals.csig1 /= t;
13116
- vals.salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;
13117
- vals.calp2 = cbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1 ? Math.sqrt(m.sq(calp1 * cbet1) + (cbet1 < -sbet1 ? (cbet2 - cbet1) * (cbet1 + cbet2) : (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 : Math.abs(calp1);
13118
- vals.ssig2 = sbet2;
13119
- somg2 = salp0 * sbet2;
13120
- vals.csig2 = comg2 = vals.calp2 * cbet2;
13121
- t = m.hypot(vals.ssig2, vals.csig2);
13122
- vals.ssig2 /= t;
13123
- vals.csig2 /= t;
13124
- vals.sig12 = Math.atan2(Math.max(0, vals.csig1 * vals.ssig2 - vals.ssig1 * vals.csig2), vals.csig1 * vals.csig2 + vals.ssig1 * vals.ssig2);
13125
- somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);
13126
- comg12 = comg1 * comg2 + somg1 * somg2;
13127
- eta = Math.atan2(somg12 * clam120 - comg12 * slam120, comg12 * clam120 + somg12 * slam120);
13128
- k2 = m.sq(calp0) * this._ep2;
13129
- vals.eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
13130
- this.C3f(vals.eps, C3a);
13131
- B312 = g.SinCosSeries(true, vals.ssig2, vals.csig2, C3a) - g.SinCosSeries(true, vals.ssig1, vals.csig1, C3a);
13132
- vals.domg12 = -this.f * this.A3f(vals.eps) * salp0 * (vals.sig12 + B312);
13133
- vals.lam12 = eta + vals.domg12;
13134
- if (diffp) {
13135
- if (vals.calp2 === 0) vals.dlam12 = -2 * this._f1 * dn1 / sbet1;
13136
- else {
13137
- nvals = this.Lengths(vals.eps, vals.sig12, vals.ssig1, vals.csig1, dn1, vals.ssig2, vals.csig2, dn2, cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
13138
- vals.dlam12 = nvals.m12b;
13139
- vals.dlam12 *= this._f1 / (vals.calp2 * cbet2);
13140
- }
13141
- }
13142
- return vals;
13143
- };
13144
- g.Geodesic.prototype.Inverse = function(lat1, lon1, lat2, lon2, outmask) {
13145
- var r, vals;
13146
- if (!outmask) outmask = g.STANDARD;
13147
- if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
13148
- outmask &= g.OUT_MASK;
13149
- r = this.InverseInt(lat1, lon1, lat2, lon2, outmask);
13150
- vals = r.vals;
13151
- if (outmask & g.AZIMUTH) {
13152
- vals.azi1 = m.atan2d(r.salp1, r.calp1);
13153
- vals.azi2 = m.atan2d(r.salp2, r.calp2);
13154
- }
13155
- return vals;
13156
- };
13157
- g.Geodesic.prototype.InverseInt = function(lat1, lon1, lat2, lon2, outmask) {
13158
- var vals = {}, lon12, lon12s, lonsign, t, swapp, latsign, sbet1, cbet1, sbet2, cbet2, s12x, m12x, dn1, dn2, lam12, slam12, clam12, sig12, calp1, salp1, calp2, salp2, C1a, C2a, C3a, meridian, nvals, ssig1, csig1, ssig2, csig2, eps, omg12, dnm, numit, salp1a, calp1a, salp1b, calp1b, tripn, tripb, v, dv, dalp1, sdalp1, cdalp1, nsalp1, lengthmask, salp0, calp0, alp12, k2, A4, C4a, B41, B42, somg12, comg12, domg12, dbet1, dbet2, salp12, calp12, sdomg12, cdomg12;
13159
- vals.lat1 = lat1 = m.LatFix(lat1);
13160
- vals.lat2 = lat2 = m.LatFix(lat2);
13161
- lat1 = m.AngRound(lat1);
13162
- lat2 = m.AngRound(lat2);
13163
- lon12 = m.AngDiff(lon1, lon2);
13164
- lon12s = lon12.e;
13165
- lon12 = lon12.d;
13166
- if (outmask & g.LONG_UNROLL) {
13167
- vals.lon1 = lon1;
13168
- vals.lon2 = lon1 + lon12 + lon12s;
13169
- } else {
13170
- vals.lon1 = m.AngNormalize(lon1);
13171
- vals.lon2 = m.AngNormalize(lon2);
13172
- }
13173
- lonsign = m.copysign(1, lon12);
13174
- lon12 *= lonsign;
13175
- lon12s *= lonsign;
13176
- lam12 = lon12 * m.degree;
13177
- t = m.sincosde(lon12, lon12s);
13178
- slam12 = t.s;
13179
- clam12 = t.c;
13180
- lon12s = 180 - lon12 - lon12s;
13181
- swapp = Math.abs(lat1) < Math.abs(lat2) || isNaN(lat2) ? -1 : 1;
13182
- if (swapp < 0) {
13183
- lonsign *= -1;
13184
- [lat2, lat1] = [lat1, lat2];
13185
- }
13186
- latsign = m.copysign(1, -lat1);
13187
- lat1 *= latsign;
13188
- lat2 *= latsign;
13189
- t = m.sincosd(lat1);
13190
- sbet1 = this._f1 * t.s;
13191
- cbet1 = t.c;
13192
- t = m.hypot(sbet1, cbet1);
13193
- sbet1 /= t;
13194
- cbet1 /= t;
13195
- cbet1 = Math.max(g.tiny_, cbet1);
13196
- t = m.sincosd(lat2);
13197
- sbet2 = this._f1 * t.s;
13198
- cbet2 = t.c;
13199
- t = m.hypot(sbet2, cbet2);
13200
- sbet2 /= t;
13201
- cbet2 /= t;
13202
- cbet2 = Math.max(g.tiny_, cbet2);
13203
- if (cbet1 < -sbet1) {
13204
- if (cbet2 === cbet1) sbet2 = m.copysign(sbet1, sbet2);
13205
- } else if (Math.abs(sbet2) === -sbet1) cbet2 = cbet1;
13206
- dn1 = Math.sqrt(1 + this._ep2 * m.sq(sbet1));
13207
- dn2 = Math.sqrt(1 + this._ep2 * m.sq(sbet2));
13208
- C1a = new Array(g.nC1_ + 1);
13209
- C2a = new Array(g.nC2_ + 1);
13210
- C3a = new Array(g.nC3_);
13211
- meridian = lat1 === -90 || slam12 === 0;
13212
- if (meridian) {
13213
- calp1 = clam12;
13214
- salp1 = slam12;
13215
- calp2 = 1;
13216
- salp2 = 0;
13217
- ssig1 = sbet1;
13218
- csig1 = calp1 * cbet1;
13219
- ssig2 = sbet2;
13220
- csig2 = calp2 * cbet2;
13221
- sig12 = Math.atan2(Math.max(0, csig1 * ssig2 - ssig1 * csig2), csig1 * csig2 + ssig1 * ssig2);
13222
- nvals = this.Lengths(this._n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask | g.DISTANCE | g.REDUCEDLENGTH, C1a, C2a);
13223
- s12x = nvals.s12b;
13224
- m12x = nvals.m12b;
13225
- if (outmask & g.GEODESICSCALE) {
13226
- vals.M12 = nvals.M12;
13227
- vals.M21 = nvals.M21;
13228
- }
13229
- if (sig12 < tol2_ || m12x >= 0) {
13230
- if (sig12 < 3 * g.tiny_ || sig12 < tol0_ && (s12x < 0 || m12x < 0)) sig12 = m12x = s12x = 0;
13231
- m12x *= this._b;
13232
- s12x *= this._b;
13233
- vals.a12 = sig12 / m.degree;
13234
- } else meridian = false;
13235
- }
13236
- somg12 = 2;
13237
- if (!meridian && sbet1 === 0 && (this.f <= 0 || lon12s >= this.f * 180)) {
13238
- calp1 = calp2 = 0;
13239
- salp1 = salp2 = 1;
13240
- s12x = this.a * lam12;
13241
- sig12 = omg12 = lam12 / this._f1;
13242
- m12x = this._b * Math.sin(sig12);
13243
- if (outmask & g.GEODESICSCALE) vals.M12 = vals.M21 = Math.cos(sig12);
13244
- vals.a12 = lon12 / this._f1;
13245
- } else if (!meridian) {
13246
- nvals = this.InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a);
11285
+ vals.calp1 = sbet12a - cbet2 * sbet1 * sq(somg12) / (1 - comg12);
11286
+ }
11287
+ }
11288
+ if (!(vals.salp1 <= 0)) {
11289
+ t = hypot(vals.salp1, vals.calp1);
11290
+ vals.salp1 /= t;
11291
+ vals.calp1 /= t;
11292
+ } else {
11293
+ vals.salp1 = 1;
11294
+ vals.calp1 = 0;
11295
+ }
11296
+ return vals;
11297
+ }
11298
+ Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam120, clam120, diffp, C1a, C2a, C3a) {
11299
+ let vals = {
11300
+ ssig1: NaN,
11301
+ csig1: NaN,
11302
+ salp2: NaN,
11303
+ calp2: NaN,
11304
+ ssig2: NaN,
11305
+ csig2: NaN,
11306
+ sig12: NaN,
11307
+ eps: NaN,
11308
+ domg12: NaN,
11309
+ lam12: NaN,
11310
+ dlam12: NaN
11311
+ }, t, salp0, calp0, somg1, comg1, somg2, comg2, somg12, comg12, B312, eta, k2, nvals;
11312
+ if (sbet1 === 0 && calp1 === 0) calp1 = -tiny_;
11313
+ salp0 = salp1 * cbet1;
11314
+ calp0 = hypot(calp1, salp1 * sbet1);
11315
+ vals.ssig1 = sbet1;
11316
+ somg1 = salp0 * sbet1;
11317
+ vals.csig1 = comg1 = calp1 * cbet1;
11318
+ t = hypot(vals.ssig1, vals.csig1);
11319
+ vals.ssig1 /= t;
11320
+ vals.csig1 /= t;
11321
+ vals.salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;
11322
+ vals.calp2 = cbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1 ? Math.sqrt(sq(calp1 * cbet1) + (cbet1 < -sbet1 ? (cbet2 - cbet1) * (cbet1 + cbet2) : (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 : Math.abs(calp1);
11323
+ vals.ssig2 = sbet2;
11324
+ somg2 = salp0 * sbet2;
11325
+ vals.csig2 = comg2 = vals.calp2 * cbet2;
11326
+ t = hypot(vals.ssig2, vals.csig2);
11327
+ vals.ssig2 /= t;
11328
+ vals.csig2 /= t;
11329
+ vals.sig12 = Math.atan2(Math.max(0, vals.csig1 * vals.ssig2 - vals.ssig1 * vals.csig2), vals.csig1 * vals.csig2 + vals.ssig1 * vals.ssig2);
11330
+ somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);
11331
+ comg12 = comg1 * comg2 + somg1 * somg2;
11332
+ eta = Math.atan2(somg12 * clam120 - comg12 * slam120, comg12 * clam120 + somg12 * slam120);
11333
+ k2 = sq(calp0) * this._ep2;
11334
+ vals.eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
11335
+ this.C3f(vals.eps, C3a);
11336
+ B312 = SinCosSeries(true, vals.ssig2, vals.csig2, C3a) - SinCosSeries(true, vals.ssig1, vals.csig1, C3a);
11337
+ vals.domg12 = -this.f * this.A3f(vals.eps) * salp0 * (vals.sig12 + B312);
11338
+ vals.lam12 = eta + vals.domg12;
11339
+ if (diffp) {
11340
+ if (vals.calp2 === 0) vals.dlam12 = -2 * this._f1 * dn1 / sbet1;
11341
+ else {
11342
+ nvals = this.Lengths(vals.eps, vals.sig12, vals.ssig1, vals.csig1, dn1, vals.ssig2, vals.csig2, dn2, cbet1, cbet2, REDUCEDLENGTH, C1a, C2a);
11343
+ vals.dlam12 = nvals.m12b;
11344
+ vals.dlam12 *= this._f1 / (vals.calp2 * cbet2);
11345
+ }
11346
+ }
11347
+ return vals;
11348
+ }
11349
+ Inverse(lat1, lon1, lat2, lon2, outmask = 0) {
11350
+ let r, vals;
11351
+ if (!outmask) outmask = STANDARD;
11352
+ if (outmask === 32768) outmask |= STANDARD;
11353
+ outmask &= OUT_MASK;
11354
+ r = this.InverseInt(lat1, lon1, lat2, lon2, outmask);
11355
+ vals = r.vals;
11356
+ if (outmask & 512) {
11357
+ vals.azi1 = atan2d(r.salp1, r.calp1);
11358
+ vals.azi2 = atan2d(r.salp2, r.calp2);
11359
+ }
11360
+ return vals;
11361
+ }
11362
+ InverseInt(lat1, lon1, lat2, lon2, outmask = 0) {
11363
+ let vals = {
11364
+ azi1: NaN,
11365
+ azi2: NaN,
11366
+ lat1: NaN,
11367
+ lat2: NaN,
11368
+ lon1: NaN,
11369
+ lon2: NaN,
11370
+ M12: NaN,
11371
+ M21: NaN,
11372
+ a12: NaN,
11373
+ s12: NaN,
11374
+ m12: NaN,
11375
+ S12: NaN
11376
+ }, lon12, lon12s, lonsign, t, swapp, latsign, sbet1, cbet1, sbet2, cbet2, s12x = NaN, m12x = NaN, dn1, dn2, lam12, slam12, clam12, sig12, calp1 = NaN, salp1 = NaN, calp2 = NaN, salp2 = NaN, C1a, C2a, C3a, meridian, nvals, ssig1 = NaN, csig1 = NaN, ssig2 = NaN, csig2 = NaN, eps, omg12 = NaN, dnm, numit, salp1a, calp1a, salp1b, calp1b, tripn, tripb, v, dv, dalp1, sdalp1, cdalp1, nsalp1, lengthmask, salp0, calp0, alp12, k2, A4, C4a, B41, B42, somg12, comg12 = NaN, domg12, dbet1, dbet2, salp12, calp12, sdomg12, cdomg12;
11377
+ vals.lat1 = lat1 = LatFix(lat1);
11378
+ vals.lat2 = lat2 = LatFix(lat2);
11379
+ lat1 = AngRound(lat1);
11380
+ lat2 = AngRound(lat2);
11381
+ lon12 = AngDiff(lon1, lon2);
11382
+ lon12s = lon12.e;
11383
+ lon12 = lon12.d;
11384
+ if (outmask & 32768) {
11385
+ vals.lon1 = lon1;
11386
+ vals.lon2 = lon1 + lon12 + lon12s;
11387
+ } else {
11388
+ vals.lon1 = AngNormalize(lon1);
11389
+ vals.lon2 = AngNormalize(lon2);
11390
+ }
11391
+ lonsign = copysign(1, lon12);
11392
+ lon12 *= lonsign;
11393
+ lon12s *= lonsign;
11394
+ lam12 = lon12 * degree;
11395
+ t = sincosde(lon12, lon12s);
11396
+ slam12 = t.s;
11397
+ clam12 = t.c;
11398
+ lon12s = 180 - lon12 - lon12s;
11399
+ swapp = Math.abs(lat1) < Math.abs(lat2) || isNaN(lat2) ? -1 : 1;
11400
+ if (swapp < 0) {
11401
+ lonsign *= -1;
11402
+ [lat2, lat1] = [lat1, lat2];
11403
+ }
11404
+ latsign = copysign(1, -lat1);
11405
+ lat1 *= latsign;
11406
+ lat2 *= latsign;
11407
+ t = sincosd(lat1);
11408
+ sbet1 = this._f1 * t.s;
11409
+ cbet1 = t.c;
11410
+ t = hypot(sbet1, cbet1);
11411
+ sbet1 /= t;
11412
+ cbet1 /= t;
11413
+ cbet1 = Math.max(tiny_, cbet1);
11414
+ t = sincosd(lat2);
11415
+ sbet2 = this._f1 * t.s;
11416
+ cbet2 = t.c;
11417
+ t = hypot(sbet2, cbet2);
11418
+ sbet2 /= t;
11419
+ cbet2 /= t;
11420
+ cbet2 = Math.max(tiny_, cbet2);
11421
+ if (cbet1 < -sbet1) {
11422
+ if (cbet2 === cbet1) sbet2 = copysign(sbet1, sbet2);
11423
+ } else if (Math.abs(sbet2) === -sbet1) cbet2 = cbet1;
11424
+ dn1 = Math.sqrt(1 + this._ep2 * sq(sbet1));
11425
+ dn2 = Math.sqrt(1 + this._ep2 * sq(sbet2));
11426
+ C1a = new Array(7);
11427
+ C2a = new Array(7);
11428
+ C3a = new Array(6);
11429
+ meridian = lat1 === -90 || slam12 === 0;
11430
+ if (meridian) {
11431
+ calp1 = clam12;
11432
+ salp1 = slam12;
11433
+ calp2 = 1;
11434
+ salp2 = 0;
11435
+ ssig1 = sbet1;
11436
+ csig1 = calp1 * cbet1;
11437
+ ssig2 = sbet2;
11438
+ csig2 = calp2 * cbet2;
11439
+ sig12 = Math.atan2(Math.max(0, csig1 * ssig2 - ssig1 * csig2), csig1 * csig2 + ssig1 * ssig2);
11440
+ nvals = this.Lengths(this._n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask | 5125, C1a, C2a);
11441
+ s12x = nvals.s12b;
11442
+ m12x = nvals.m12b;
11443
+ if (outmask & 8197) {
11444
+ vals.M12 = nvals.M12;
11445
+ vals.M21 = nvals.M21;
11446
+ }
11447
+ if (sig12 < tol2_ || m12x >= 0) {
11448
+ if (sig12 < 3 * tiny_ || sig12 < tol0_ && (s12x < 0 || m12x < 0)) sig12 = m12x = s12x = 0;
11449
+ m12x *= this._b;
11450
+ s12x *= this._b;
11451
+ vals.a12 = sig12 / degree;
11452
+ } else meridian = false;
11453
+ }
11454
+ somg12 = 2;
11455
+ if (!meridian && sbet1 === 0 && (this.f <= 0 || lon12s >= this.f * 180)) {
11456
+ calp1 = calp2 = 0;
11457
+ salp1 = salp2 = 1;
11458
+ s12x = this.a * lam12;
11459
+ sig12 = omg12 = lam12 / this._f1;
11460
+ m12x = this._b * Math.sin(sig12);
11461
+ if (outmask & 8197) vals.M12 = vals.M21 = Math.cos(sig12);
11462
+ vals.a12 = lon12 / this._f1;
11463
+ } else if (!meridian) {
11464
+ nvals = this.InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a);
11465
+ sig12 = nvals.sig12;
11466
+ salp1 = nvals.salp1;
11467
+ calp1 = nvals.calp1;
11468
+ if (sig12 >= 0) {
11469
+ salp2 = nvals.salp2;
11470
+ calp2 = nvals.calp2;
11471
+ dnm = nvals.dnm;
11472
+ s12x = sig12 * this._b * dnm;
11473
+ m12x = sq(dnm) * this._b * Math.sin(sig12 / dnm);
11474
+ if (outmask & 8197) vals.M12 = vals.M21 = Math.cos(sig12 / dnm);
11475
+ vals.a12 = sig12 / degree;
11476
+ omg12 = lam12 / (this._f1 * dnm);
11477
+ } else {
11478
+ numit = 0;
11479
+ salp1a = tiny_;
11480
+ calp1a = 1;
11481
+ salp1b = tiny_;
11482
+ calp1b = -1;
11483
+ for (tripn = false, tripb = false;; ++numit) {
11484
+ nvals = this.Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam12, clam12, numit < maxit1_, C1a, C2a, C3a);
11485
+ v = nvals.lam12;
11486
+ salp2 = nvals.salp2;
11487
+ calp2 = nvals.calp2;
13247
11488
  sig12 = nvals.sig12;
13248
- salp1 = nvals.salp1;
13249
- calp1 = nvals.calp1;
13250
- if (sig12 >= 0) {
13251
- salp2 = nvals.salp2;
13252
- calp2 = nvals.calp2;
13253
- dnm = nvals.dnm;
13254
- s12x = sig12 * this._b * dnm;
13255
- m12x = m.sq(dnm) * this._b * Math.sin(sig12 / dnm);
13256
- if (outmask & g.GEODESICSCALE) vals.M12 = vals.M21 = Math.cos(sig12 / dnm);
13257
- vals.a12 = sig12 / m.degree;
13258
- omg12 = lam12 / (this._f1 * dnm);
13259
- } else {
13260
- numit = 0;
13261
- salp1a = g.tiny_;
13262
- calp1a = 1;
13263
- salp1b = g.tiny_;
13264
- calp1b = -1;
13265
- for (tripn = false, tripb = false;; ++numit) {
13266
- nvals = this.Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam12, clam12, numit < maxit1_, C1a, C2a, C3a);
13267
- v = nvals.lam12;
13268
- salp2 = nvals.salp2;
13269
- calp2 = nvals.calp2;
13270
- sig12 = nvals.sig12;
13271
- ssig1 = nvals.ssig1;
13272
- csig1 = nvals.csig1;
13273
- ssig2 = nvals.ssig2;
13274
- csig2 = nvals.csig2;
13275
- eps = nvals.eps;
13276
- domg12 = nvals.domg12;
13277
- dv = nvals.dlam12;
13278
- if (tripb || !(Math.abs(v) >= (tripn ? 8 : 1) * tol0_) || numit == maxit2_) break;
13279
- if (v > 0 && (numit < maxit1_ || calp1 / salp1 > calp1b / salp1b)) {
13280
- salp1b = salp1;
13281
- calp1b = calp1;
13282
- } else if (v < 0 && (numit < maxit1_ || calp1 / salp1 < calp1a / salp1a)) {
13283
- salp1a = salp1;
13284
- calp1a = calp1;
13285
- }
13286
- if (numit < maxit1_ && dv > 0) {
13287
- dalp1 = -v / dv;
13288
- if (Math.abs(dalp1) < Math.PI) {
13289
- sdalp1 = Math.sin(dalp1);
13290
- cdalp1 = Math.cos(dalp1);
13291
- nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
13292
- if (nsalp1 > 0) {
13293
- calp1 = calp1 * cdalp1 - salp1 * sdalp1;
13294
- salp1 = nsalp1;
13295
- t = m.hypot(salp1, calp1);
13296
- salp1 /= t;
13297
- calp1 /= t;
13298
- tripn = Math.abs(v) <= 16 * tol0_;
13299
- continue;
13300
- }
13301
- }
13302
- }
13303
- salp1 = (salp1a + salp1b) / 2;
13304
- calp1 = (calp1a + calp1b) / 2;
13305
- t = m.hypot(salp1, calp1);
13306
- salp1 /= t;
13307
- calp1 /= t;
13308
- tripn = false;
13309
- tripb = Math.abs(salp1a - salp1) + (calp1a - calp1) < tolb_ || Math.abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_;
13310
- }
13311
- lengthmask = outmask | (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE) ? g.DISTANCE : g.NONE);
13312
- nvals = this.Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, lengthmask, C1a, C2a);
13313
- s12x = nvals.s12b;
13314
- m12x = nvals.m12b;
13315
- if (outmask & g.GEODESICSCALE) {
13316
- vals.M12 = nvals.M12;
13317
- vals.M21 = nvals.M21;
13318
- }
13319
- m12x *= this._b;
13320
- s12x *= this._b;
13321
- vals.a12 = sig12 / m.degree;
13322
- if (outmask & g.AREA) {
13323
- sdomg12 = Math.sin(domg12);
13324
- cdomg12 = Math.cos(domg12);
13325
- somg12 = slam12 * cdomg12 - clam12 * sdomg12;
13326
- comg12 = clam12 * cdomg12 + slam12 * sdomg12;
13327
- }
13328
- }
13329
- }
13330
- if (outmask & g.DISTANCE) vals.s12 = 0 + s12x;
13331
- if (outmask & g.REDUCEDLENGTH) vals.m12 = 0 + m12x;
13332
- if (outmask & g.AREA) {
13333
- salp0 = salp1 * cbet1;
13334
- calp0 = m.hypot(calp1, salp1 * sbet1);
13335
- if (calp0 !== 0 && salp0 !== 0) {
13336
- ssig1 = sbet1;
13337
- csig1 = calp1 * cbet1;
13338
- ssig2 = sbet2;
13339
- csig2 = calp2 * cbet2;
13340
- k2 = m.sq(calp0) * this._ep2;
13341
- eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
13342
- A4 = m.sq(this.a) * calp0 * salp0 * this._e2;
13343
- t = m.hypot(ssig1, csig1);
13344
- ssig1 /= t;
13345
- csig1 /= t;
13346
- t = m.hypot(ssig2, csig2);
13347
- ssig2 /= t;
13348
- csig2 /= t;
13349
- C4a = new Array(g.nC4_);
13350
- this.C4f(eps, C4a);
13351
- B41 = g.SinCosSeries(false, ssig1, csig1, C4a);
13352
- B42 = g.SinCosSeries(false, ssig2, csig2, C4a);
13353
- vals.S12 = A4 * (B42 - B41);
13354
- } else vals.S12 = 0;
13355
- if (!meridian && somg12 == 2) {
13356
- somg12 = Math.sin(omg12);
13357
- comg12 = Math.cos(omg12);
11489
+ ssig1 = nvals.ssig1;
11490
+ csig1 = nvals.csig1;
11491
+ ssig2 = nvals.ssig2;
11492
+ csig2 = nvals.csig2;
11493
+ eps = nvals.eps;
11494
+ domg12 = nvals.domg12;
11495
+ dv = nvals.dlam12;
11496
+ if (tripb || !(Math.abs(v) >= (tripn ? 8 : 1) * tol0_) || numit == maxit2_) break;
11497
+ if (v > 0 && (numit < maxit1_ || calp1 / salp1 > calp1b / salp1b)) {
11498
+ salp1b = salp1;
11499
+ calp1b = calp1;
11500
+ } else if (v < 0 && (numit < maxit1_ || calp1 / salp1 < calp1a / salp1a)) {
11501
+ salp1a = salp1;
11502
+ calp1a = calp1;
13358
11503
  }
13359
- if (!meridian && comg12 > -.7071 && sbet2 - sbet1 < 1.75) {
13360
- domg12 = 1 + comg12;
13361
- dbet1 = 1 + cbet1;
13362
- dbet2 = 1 + cbet2;
13363
- alp12 = 2 * Math.atan2(somg12 * (sbet1 * dbet2 + sbet2 * dbet1), domg12 * (sbet1 * sbet2 + dbet1 * dbet2));
13364
- } else {
13365
- salp12 = salp2 * calp1 - calp2 * salp1;
13366
- calp12 = calp2 * calp1 + salp2 * salp1;
13367
- if (salp12 === 0 && calp12 < 0) {
13368
- salp12 = g.tiny_ * calp1;
13369
- calp12 = -1;
11504
+ if (numit < maxit1_ && dv > 0) {
11505
+ dalp1 = -v / dv;
11506
+ if (Math.abs(dalp1) < Math.PI) {
11507
+ sdalp1 = Math.sin(dalp1);
11508
+ cdalp1 = Math.cos(dalp1);
11509
+ nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
11510
+ if (nsalp1 > 0) {
11511
+ calp1 = calp1 * cdalp1 - salp1 * sdalp1;
11512
+ salp1 = nsalp1;
11513
+ t = hypot(salp1, calp1);
11514
+ salp1 /= t;
11515
+ calp1 /= t;
11516
+ tripn = Math.abs(v) <= 16 * tol0_;
11517
+ continue;
11518
+ }
13370
11519
  }
13371
- alp12 = Math.atan2(salp12, calp12);
13372
11520
  }
13373
- vals.S12 += this._c2 * alp12;
13374
- vals.S12 *= swapp * lonsign * latsign;
13375
- vals.S12 += 0;
13376
- }
13377
- if (swapp < 0) {
13378
- [salp2, salp1] = [salp1, salp2];
13379
- [calp2, calp1] = [calp1, calp2];
13380
- if (outmask & g.GEODESICSCALE) [vals.M21, vals.M12] = [vals.M12, vals.M21];
13381
- }
13382
- salp1 *= swapp * lonsign;
13383
- calp1 *= swapp * latsign;
13384
- salp2 *= swapp * lonsign;
13385
- calp2 *= swapp * latsign;
13386
- return {
13387
- vals,
13388
- salp1,
13389
- calp1,
13390
- salp2,
13391
- calp2
13392
- };
13393
- };
13394
- g.Geodesic.prototype.GenDirect = function(lat1, lon1, azi1, arcmode, s12_a12, outmask) {
13395
- var line;
13396
- if (!outmask) outmask = g.STANDARD;
13397
- else if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
13398
- if (!arcmode) outmask |= g.DISTANCE_IN;
13399
- line = new l.GeodesicLine(this, lat1, lon1, azi1, outmask);
13400
- return line.GenPosition(arcmode, s12_a12, outmask);
13401
- };
13402
- g.Geodesic.prototype.Direct = function(lat1, lon1, azi1, s12, outmask) {
13403
- return this.GenDirect(lat1, lon1, azi1, false, s12, outmask);
13404
- };
13405
- g.Geodesic.prototype.ArcDirect = function(lat1, lon1, azi1, a12, outmask) {
13406
- return this.GenDirect(lat1, lon1, azi1, true, a12, outmask);
13407
- };
13408
- g.Geodesic.prototype.Line = function(lat1, lon1, azi1, caps) {
13409
- return new l.GeodesicLine(this, lat1, lon1, azi1, caps);
13410
- };
13411
- g.Geodesic.prototype.DirectLine = function(lat1, lon1, azi1, s12, caps) {
13412
- return this.GenDirectLine(lat1, lon1, azi1, false, s12, caps);
13413
- };
13414
- g.Geodesic.prototype.ArcDirectLine = function(lat1, lon1, azi1, a12, caps) {
13415
- return this.GenDirectLine(lat1, lon1, azi1, true, a12, caps);
13416
- };
13417
- g.Geodesic.prototype.GenDirectLine = function(lat1, lon1, azi1, arcmode, s12_a12, caps) {
13418
- var t;
13419
- if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
13420
- if (!arcmode) caps |= g.DISTANCE_IN;
13421
- t = new l.GeodesicLine(this, lat1, lon1, azi1, caps);
13422
- t.GenSetDistance(arcmode, s12_a12);
13423
- return t;
13424
- };
13425
- g.Geodesic.prototype.InverseLine = function(lat1, lon1, lat2, lon2, caps) {
13426
- var r, t, azi1;
13427
- if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
13428
- r = this.InverseInt(lat1, lon1, lat2, lon2, g.ARC);
13429
- azi1 = m.atan2d(r.salp1, r.calp1);
13430
- if (caps & (g.OUT_MASK & g.DISTANCE_IN)) caps |= g.DISTANCE;
13431
- t = new l.GeodesicLine(this, lat1, lon1, azi1, caps, r.salp1, r.calp1);
13432
- t.SetArc(r.vals.a12);
13433
- return t;
13434
- };
13435
- g.Geodesic.prototype.Polygon = function(polyline) {
13436
- return new p.PolygonArea(this, polyline);
13437
- };
13438
- g.WGS84 = new g.Geodesic(c.WGS84.a, c.WGS84.f);
13439
- })(geodesic.Geodesic, geodesic.GeodesicLine, geodesic.PolygonArea, geodesic.Math, geodesic.Constants);
13440
- (function(g, l, m) {
13441
- "use strict";
13442
- l.GeodesicLine = function(geod, lat1, lon1, azi1, caps, salp1, calp1) {
13443
- var t, cbet1, sbet1, eps, s, c;
13444
- if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
13445
- this.a = geod.a;
13446
- this.f = geod.f;
13447
- this._b = geod._b;
13448
- this._c2 = geod._c2;
13449
- this._f1 = geod._f1;
13450
- this.caps = caps | g.LATITUDE | g.AZIMUTH | g.LONG_UNROLL;
13451
- this.lat1 = m.LatFix(lat1);
13452
- this.lon1 = lon1;
13453
- if (typeof salp1 === "undefined" || typeof calp1 === "undefined") {
13454
- this.azi1 = m.AngNormalize(azi1);
13455
- t = m.sincosd(m.AngRound(this.azi1));
13456
- this.salp1 = t.s;
13457
- this.calp1 = t.c;
13458
- } else {
13459
- this.azi1 = azi1;
13460
- this.salp1 = salp1;
13461
- this.calp1 = calp1;
13462
- }
13463
- t = m.sincosd(m.AngRound(this.lat1));
13464
- sbet1 = this._f1 * t.s;
13465
- cbet1 = t.c;
13466
- t = m.hypot(sbet1, cbet1);
13467
- sbet1 /= t;
13468
- cbet1 /= t;
13469
- cbet1 = Math.max(g.tiny_, cbet1);
13470
- this._dn1 = Math.sqrt(1 + geod._ep2 * m.sq(sbet1));
13471
- this._salp0 = this.salp1 * cbet1;
13472
- this._calp0 = m.hypot(this.calp1, this.salp1 * sbet1);
13473
- this._ssig1 = sbet1;
13474
- this._somg1 = this._salp0 * sbet1;
13475
- this._csig1 = this._comg1 = sbet1 !== 0 || this.calp1 !== 0 ? cbet1 * this.calp1 : 1;
13476
- t = m.hypot(this._ssig1, this._csig1);
13477
- this._ssig1 /= t;
13478
- this._csig1 /= t;
13479
- this._k2 = m.sq(this._calp0) * geod._ep2;
13480
- eps = this._k2 / (2 * (1 + Math.sqrt(1 + this._k2)) + this._k2);
13481
- if (this.caps & g.CAP_C1) {
13482
- this._A1m1 = g.A1m1f(eps);
13483
- this._C1a = new Array(g.nC1_ + 1);
13484
- g.C1f(eps, this._C1a);
13485
- this._B11 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C1a);
13486
- s = Math.sin(this._B11);
13487
- c = Math.cos(this._B11);
13488
- this._stau1 = this._ssig1 * c + this._csig1 * s;
13489
- this._ctau1 = this._csig1 * c - this._ssig1 * s;
13490
- }
13491
- if (this.caps & g.CAP_C1p) {
13492
- this._C1pa = new Array(g.nC1p_ + 1);
13493
- g.C1pf(eps, this._C1pa);
13494
- }
13495
- if (this.caps & g.CAP_C2) {
13496
- this._A2m1 = g.A2m1f(eps);
13497
- this._C2a = new Array(g.nC2_ + 1);
13498
- g.C2f(eps, this._C2a);
13499
- this._B21 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C2a);
13500
- }
13501
- if (this.caps & g.CAP_C3) {
13502
- this._C3a = new Array(g.nC3_);
13503
- geod.C3f(eps, this._C3a);
13504
- this._A3c = -this.f * this._salp0 * geod.A3f(eps);
13505
- this._B31 = g.SinCosSeries(true, this._ssig1, this._csig1, this._C3a);
11521
+ salp1 = (salp1a + salp1b) / 2;
11522
+ calp1 = (calp1a + calp1b) / 2;
11523
+ t = hypot(salp1, calp1);
11524
+ salp1 /= t;
11525
+ calp1 /= t;
11526
+ tripn = false;
11527
+ tripb = Math.abs(salp1a - salp1) + (calp1a - calp1) < tolb_ || Math.abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_;
13506
11528
  }
13507
- if (this.caps & g.CAP_C4) {
13508
- this._C4a = new Array(g.nC4_);
13509
- geod.C4f(eps, this._C4a);
13510
- this._A4 = m.sq(this.a) * this._calp0 * this._salp0 * geod._e2;
13511
- this._B41 = g.SinCosSeries(false, this._ssig1, this._csig1, this._C4a);
11529
+ lengthmask = outmask | (outmask & 12293 ? DISTANCE : 0);
11530
+ nvals = this.Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, lengthmask, C1a, C2a);
11531
+ s12x = nvals.s12b;
11532
+ m12x = nvals.m12b;
11533
+ if (outmask & 8197) {
11534
+ vals.M12 = nvals.M12;
11535
+ vals.M21 = nvals.M21;
13512
11536
  }
13513
- this.a13 = this.s13 = NaN;
13514
- };
13515
- l.GeodesicLine.prototype.GenPosition = function(arcmode, s12_a12, outmask) {
13516
- var vals = {}, sig12, ssig12, csig12, B12, AB1, ssig2, csig2, tau12, s, c, serr, omg12, lam12, lon12, E, sbet2, cbet2, somg2, comg2, salp2, calp2, dn2, B22, AB2, J12, t, B42, salp12, calp12;
13517
- if (!outmask) outmask = g.STANDARD;
13518
- else if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
13519
- outmask &= this.caps & g.OUT_MASK;
13520
- vals.lat1 = this.lat1;
13521
- vals.azi1 = this.azi1;
13522
- vals.lon1 = outmask & g.LONG_UNROLL ? this.lon1 : m.AngNormalize(this.lon1);
13523
- if (arcmode) vals.a12 = s12_a12;
13524
- else vals.s12 = s12_a12;
13525
- if (!(arcmode || this.caps & g.DISTANCE_IN & g.OUT_MASK)) {
13526
- vals.a12 = NaN;
13527
- return vals;
11537
+ m12x *= this._b;
11538
+ s12x *= this._b;
11539
+ vals.a12 = sig12 / degree;
11540
+ if (outmask & 16400) {
11541
+ sdomg12 = Math.sin(domg12);
11542
+ cdomg12 = Math.cos(domg12);
11543
+ somg12 = slam12 * cdomg12 - clam12 * sdomg12;
11544
+ comg12 = clam12 * cdomg12 + slam12 * sdomg12;
13528
11545
  }
13529
- B12 = 0;
13530
- AB1 = 0;
13531
- if (arcmode) {
13532
- sig12 = s12_a12 * m.degree;
13533
- t = m.sincosd(s12_a12);
13534
- ssig12 = t.s;
13535
- csig12 = t.c;
13536
- } else {
13537
- tau12 = s12_a12 / (this._b * (1 + this._A1m1));
13538
- s = Math.sin(tau12);
13539
- c = Math.cos(tau12);
13540
- B12 = -g.SinCosSeries(true, this._stau1 * c + this._ctau1 * s, this._ctau1 * c - this._stau1 * s, this._C1pa);
13541
- sig12 = tau12 - (B12 - this._B11);
13542
- ssig12 = Math.sin(sig12);
13543
- csig12 = Math.cos(sig12);
13544
- if (Math.abs(this.f) > .01) {
13545
- ssig2 = this._ssig1 * csig12 + this._csig1 * ssig12;
13546
- csig2 = this._csig1 * csig12 - this._ssig1 * ssig12;
13547
- B12 = g.SinCosSeries(true, ssig2, csig2, this._C1a);
13548
- serr = (1 + this._A1m1) * (sig12 + (B12 - this._B11)) - s12_a12 / this._b;
13549
- sig12 = sig12 - serr / Math.sqrt(1 + this._k2 * m.sq(ssig2));
13550
- ssig12 = Math.sin(sig12);
13551
- csig12 = Math.cos(sig12);
13552
- }
11546
+ }
11547
+ }
11548
+ if (outmask & 1025) vals.s12 = 0 + s12x;
11549
+ if (outmask & 4101) vals.m12 = 0 + m12x;
11550
+ if (outmask & 16400) {
11551
+ salp0 = salp1 * cbet1;
11552
+ calp0 = hypot(calp1, salp1 * sbet1);
11553
+ if (calp0 !== 0 && salp0 !== 0) {
11554
+ ssig1 = sbet1;
11555
+ csig1 = calp1 * cbet1;
11556
+ ssig2 = sbet2;
11557
+ csig2 = calp2 * cbet2;
11558
+ k2 = sq(calp0) * this._ep2;
11559
+ eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
11560
+ A4 = sq(this.a) * calp0 * salp0 * this._e2;
11561
+ t = hypot(ssig1, csig1);
11562
+ ssig1 /= t;
11563
+ csig1 /= t;
11564
+ t = hypot(ssig2, csig2);
11565
+ ssig2 /= t;
11566
+ csig2 /= t;
11567
+ C4a = new Array(6);
11568
+ this.C4f(eps, C4a);
11569
+ B41 = SinCosSeries(false, ssig1, csig1, C4a);
11570
+ B42 = SinCosSeries(false, ssig2, csig2, C4a);
11571
+ vals.S12 = A4 * (B42 - B41);
11572
+ } else vals.S12 = 0;
11573
+ if (!meridian && somg12 == 2) {
11574
+ somg12 = Math.sin(omg12);
11575
+ comg12 = Math.cos(omg12);
11576
+ }
11577
+ if (!meridian && comg12 > -.7071 && sbet2 - sbet1 < 1.75) {
11578
+ domg12 = 1 + comg12;
11579
+ dbet1 = 1 + cbet1;
11580
+ dbet2 = 1 + cbet2;
11581
+ alp12 = 2 * Math.atan2(somg12 * (sbet1 * dbet2 + sbet2 * dbet1), domg12 * (sbet1 * sbet2 + dbet1 * dbet2));
11582
+ } else {
11583
+ salp12 = salp2 * calp1 - calp2 * salp1;
11584
+ calp12 = calp2 * calp1 + salp2 * salp1;
11585
+ if (salp12 === 0 && calp12 < 0) {
11586
+ salp12 = tiny_ * calp1;
11587
+ calp12 = -1;
13553
11588
  }
11589
+ alp12 = Math.atan2(salp12, calp12);
11590
+ }
11591
+ vals.S12 += this._c2 * alp12;
11592
+ vals.S12 *= swapp * lonsign * latsign;
11593
+ vals.S12 += 0;
11594
+ }
11595
+ if (swapp < 0) {
11596
+ [salp2, salp1] = [salp1, salp2];
11597
+ [calp2, calp1] = [calp1, calp2];
11598
+ if (outmask & 8197) [vals.M21, vals.M12] = [vals.M12, vals.M21];
11599
+ }
11600
+ salp1 *= swapp * lonsign;
11601
+ calp1 *= swapp * latsign;
11602
+ salp2 *= swapp * lonsign;
11603
+ calp2 *= swapp * latsign;
11604
+ return {
11605
+ vals,
11606
+ salp1,
11607
+ calp1,
11608
+ salp2,
11609
+ calp2
11610
+ };
11611
+ }
11612
+ GenDirect(lat1, lon1, azi1, arcmode, s12_a12, outmask = 0) {
11613
+ let line;
11614
+ if (!outmask) outmask = STANDARD;
11615
+ else if (outmask === 32768) outmask |= STANDARD;
11616
+ if (!arcmode) outmask |= DISTANCE_IN;
11617
+ line = new GeodesicLine(this, lat1, lon1, azi1, outmask);
11618
+ return line.GenPosition(arcmode, s12_a12, outmask);
11619
+ }
11620
+ Direct(lat1, lon1, azi1, s12, outmask = 0) {
11621
+ return this.GenDirect(lat1, lon1, azi1, false, s12, outmask);
11622
+ }
11623
+ ArcDirect(lat1, lon1, azi1, a12, outmask = 0) {
11624
+ return this.GenDirect(lat1, lon1, azi1, true, a12, outmask);
11625
+ }
11626
+ Line(lat1, lon1, azi1, caps = 0) {
11627
+ return new GeodesicLine(this, lat1, lon1, azi1, caps);
11628
+ }
11629
+ DirectLine(lat1, lon1, azi1, s12, caps = 0) {
11630
+ return this.GenDirectLine(lat1, lon1, azi1, false, s12, caps);
11631
+ }
11632
+ ArcDirectLine(lat1, lon1, azi1, a12, caps = 0) {
11633
+ return this.GenDirectLine(lat1, lon1, azi1, true, a12, caps);
11634
+ }
11635
+ GenDirectLine(lat1, lon1, azi1, arcmode, s12_a12, caps = 0) {
11636
+ let t;
11637
+ if (!caps) caps = 3979;
11638
+ if (!arcmode) caps |= DISTANCE_IN;
11639
+ t = new GeodesicLine(this, lat1, lon1, azi1, caps);
11640
+ t.GenSetDistance(arcmode, s12_a12);
11641
+ return t;
11642
+ }
11643
+ InverseLine(lat1, lon1, lat2, lon2, caps = 0) {
11644
+ let r, t, azi1;
11645
+ if (!caps) caps = 3979;
11646
+ r = this.InverseInt(lat1, lon1, lat2, lon2, 64);
11647
+ azi1 = atan2d(r.salp1, r.calp1);
11648
+ if (caps & 2048) caps |= DISTANCE;
11649
+ t = new GeodesicLine(this, lat1, lon1, azi1, caps, r.salp1, r.calp1);
11650
+ t.SetArc(r.vals.a12);
11651
+ return t;
11652
+ }
11653
+ };
11654
+ var GeodesicLine = class {
11655
+ a = NaN;
11656
+ f = NaN;
11657
+ _b = NaN;
11658
+ _c2 = NaN;
11659
+ _f1 = NaN;
11660
+ caps = NaN;
11661
+ lat1 = NaN;
11662
+ lon1 = NaN;
11663
+ azi1 = NaN;
11664
+ salp1 = NaN;
11665
+ calp1 = NaN;
11666
+ _dn1 = NaN;
11667
+ _salp0 = NaN;
11668
+ _calp0 = NaN;
11669
+ _ssig1 = NaN;
11670
+ _somg1 = NaN;
11671
+ _csig1 = NaN;
11672
+ _comg1 = NaN;
11673
+ _k2 = NaN;
11674
+ _A1m1 = NaN;
11675
+ _C1a = [];
11676
+ _B11 = NaN;
11677
+ _stau1 = NaN;
11678
+ _ctau1 = NaN;
11679
+ _C1pa = [];
11680
+ _A2m1 = NaN;
11681
+ _C2a = [];
11682
+ _B21 = NaN;
11683
+ _C3a = [];
11684
+ _A3c = NaN;
11685
+ _B31 = NaN;
11686
+ _C4a = [];
11687
+ _A4 = NaN;
11688
+ _B41 = NaN;
11689
+ a13 = NaN;
11690
+ s13 = NaN;
11691
+ constructor(geod, lat1, lon1, azi1, caps = 0, salp1, calp1) {
11692
+ let t, cbet1, sbet1, eps, s, c;
11693
+ if (!caps) caps = 3979;
11694
+ this.a = geod.a;
11695
+ this.f = geod.f;
11696
+ this._b = geod._b;
11697
+ this._c2 = geod._c2;
11698
+ this._f1 = geod._f1;
11699
+ this.caps = caps | 33408;
11700
+ this.lat1 = LatFix(lat1);
11701
+ this.lon1 = lon1;
11702
+ if (typeof salp1 === "undefined" || typeof calp1 === "undefined") {
11703
+ this.azi1 = AngNormalize(azi1);
11704
+ t = sincosd(AngRound(this.azi1));
11705
+ this.salp1 = t.s;
11706
+ this.calp1 = t.c;
11707
+ } else {
11708
+ this.azi1 = azi1;
11709
+ this.salp1 = salp1;
11710
+ this.calp1 = calp1;
11711
+ }
11712
+ t = sincosd(AngRound(this.lat1));
11713
+ sbet1 = this._f1 * t.s;
11714
+ cbet1 = t.c;
11715
+ t = hypot(sbet1, cbet1);
11716
+ sbet1 /= t;
11717
+ cbet1 /= t;
11718
+ cbet1 = Math.max(tiny_, cbet1);
11719
+ this._dn1 = Math.sqrt(1 + geod._ep2 * sq(sbet1));
11720
+ this._salp0 = this.salp1 * cbet1;
11721
+ this._calp0 = hypot(this.calp1, this.salp1 * sbet1);
11722
+ this._ssig1 = sbet1;
11723
+ this._somg1 = this._salp0 * sbet1;
11724
+ this._csig1 = this._comg1 = sbet1 !== 0 || this.calp1 !== 0 ? cbet1 * this.calp1 : 1;
11725
+ t = hypot(this._ssig1, this._csig1);
11726
+ this._ssig1 /= t;
11727
+ this._csig1 /= t;
11728
+ this._k2 = sq(this._calp0) * geod._ep2;
11729
+ eps = this._k2 / (2 * (1 + Math.sqrt(1 + this._k2)) + this._k2);
11730
+ if (this.caps & 1) {
11731
+ this._A1m1 = A1m1f(eps);
11732
+ this._C1a = new Array(7);
11733
+ C1f(eps, this._C1a);
11734
+ this._B11 = SinCosSeries(true, this._ssig1, this._csig1, this._C1a);
11735
+ s = Math.sin(this._B11);
11736
+ c = Math.cos(this._B11);
11737
+ this._stau1 = this._ssig1 * c + this._csig1 * s;
11738
+ this._ctau1 = this._csig1 * c - this._ssig1 * s;
11739
+ }
11740
+ if (this.caps & 2) {
11741
+ this._C1pa = new Array(7);
11742
+ C1pf(eps, this._C1pa);
11743
+ }
11744
+ if (this.caps & 4) {
11745
+ this._A2m1 = A2m1f(eps);
11746
+ this._C2a = new Array(7);
11747
+ C2f(eps, this._C2a);
11748
+ this._B21 = SinCosSeries(true, this._ssig1, this._csig1, this._C2a);
11749
+ }
11750
+ if (this.caps & 8) {
11751
+ this._C3a = new Array(6);
11752
+ geod.C3f(eps, this._C3a);
11753
+ this._A3c = -this.f * this._salp0 * geod.A3f(eps);
11754
+ this._B31 = SinCosSeries(true, this._ssig1, this._csig1, this._C3a);
11755
+ }
11756
+ if (this.caps & 16) {
11757
+ this._C4a = new Array(6);
11758
+ geod.C4f(eps, this._C4a);
11759
+ this._A4 = sq(this.a) * this._calp0 * this._salp0 * geod._e2;
11760
+ this._B41 = SinCosSeries(false, this._ssig1, this._csig1, this._C4a);
11761
+ }
11762
+ this.a13 = this.s13 = NaN;
11763
+ }
11764
+ GenPosition(arcmode, s12_a12, outmask = 0) {
11765
+ let vals = {
11766
+ lat1: NaN,
11767
+ azi1: NaN,
11768
+ lon1: NaN,
11769
+ a12: NaN,
11770
+ s12: NaN,
11771
+ lon2: NaN,
11772
+ lat2: NaN,
11773
+ azi2: NaN,
11774
+ m12: NaN,
11775
+ M12: NaN,
11776
+ M21: NaN,
11777
+ S12: NaN
11778
+ }, sig12, ssig12, csig12, B12, AB1, ssig2, csig2, tau12, s, c, serr, omg12, lam12, lon12, E, sbet2, cbet2, somg2, comg2, salp2, calp2, dn2, B22, AB2, J12, t, B42, salp12, calp12;
11779
+ if (!outmask) outmask = STANDARD;
11780
+ else if (outmask === 32768) outmask |= STANDARD;
11781
+ outmask &= this.caps & OUT_MASK;
11782
+ vals.lat1 = this.lat1;
11783
+ vals.azi1 = this.azi1;
11784
+ vals.lon1 = outmask & 32768 ? this.lon1 : AngNormalize(this.lon1);
11785
+ if (arcmode) vals.a12 = s12_a12;
11786
+ else vals.s12 = s12_a12;
11787
+ if (!(arcmode || this.caps & 2048)) {
11788
+ vals.a12 = NaN;
11789
+ return vals;
11790
+ }
11791
+ B12 = 0;
11792
+ AB1 = 0;
11793
+ if (arcmode) {
11794
+ sig12 = s12_a12 * degree;
11795
+ t = sincosd(s12_a12);
11796
+ ssig12 = t.s;
11797
+ csig12 = t.c;
11798
+ } else {
11799
+ tau12 = s12_a12 / (this._b * (1 + this._A1m1));
11800
+ s = Math.sin(tau12);
11801
+ c = Math.cos(tau12);
11802
+ B12 = -SinCosSeries(true, this._stau1 * c + this._ctau1 * s, this._ctau1 * c - this._stau1 * s, this._C1pa);
11803
+ sig12 = tau12 - (B12 - this._B11);
11804
+ ssig12 = Math.sin(sig12);
11805
+ csig12 = Math.cos(sig12);
11806
+ if (Math.abs(this.f) > .01) {
13554
11807
  ssig2 = this._ssig1 * csig12 + this._csig1 * ssig12;
13555
11808
  csig2 = this._csig1 * csig12 - this._ssig1 * ssig12;
13556
- dn2 = Math.sqrt(1 + this._k2 * m.sq(ssig2));
13557
- if (outmask & (g.DISTANCE | g.REDUCEDLENGTH | g.GEODESICSCALE)) {
13558
- if (arcmode || Math.abs(this.f) > .01) B12 = g.SinCosSeries(true, ssig2, csig2, this._C1a);
13559
- AB1 = (1 + this._A1m1) * (B12 - this._B11);
13560
- }
13561
- sbet2 = this._calp0 * ssig2;
13562
- cbet2 = m.hypot(this._salp0, this._calp0 * csig2);
13563
- if (cbet2 === 0) cbet2 = csig2 = g.tiny_;
13564
- salp2 = this._salp0;
13565
- calp2 = this._calp0 * csig2;
13566
- if (arcmode && outmask & g.DISTANCE) vals.s12 = this._b * ((1 + this._A1m1) * sig12 + AB1);
13567
- if (outmask & g.LONGITUDE) {
13568
- somg2 = this._salp0 * ssig2;
13569
- comg2 = csig2;
13570
- E = m.copysign(1, this._salp0);
13571
- omg12 = outmask & g.LONG_UNROLL ? E * (sig12 - (Math.atan2(ssig2, csig2) - Math.atan2(this._ssig1, this._csig1)) + (Math.atan2(E * somg2, comg2) - Math.atan2(E * this._somg1, this._comg1))) : Math.atan2(somg2 * this._comg1 - comg2 * this._somg1, comg2 * this._comg1 + somg2 * this._somg1);
13572
- lam12 = omg12 + this._A3c * (sig12 + (g.SinCosSeries(true, ssig2, csig2, this._C3a) - this._B31));
13573
- lon12 = lam12 / m.degree;
13574
- vals.lon2 = outmask & g.LONG_UNROLL ? this.lon1 + lon12 : m.AngNormalize(m.AngNormalize(this.lon1) + m.AngNormalize(lon12));
13575
- }
13576
- if (outmask & g.LATITUDE) vals.lat2 = m.atan2d(sbet2, this._f1 * cbet2);
13577
- if (outmask & g.AZIMUTH) vals.azi2 = m.atan2d(salp2, calp2);
13578
- if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
13579
- B22 = g.SinCosSeries(true, ssig2, csig2, this._C2a);
13580
- AB2 = (1 + this._A2m1) * (B22 - this._B21);
13581
- J12 = (this._A1m1 - this._A2m1) * sig12 + (AB1 - AB2);
13582
- if (outmask & g.REDUCEDLENGTH) vals.m12 = this._b * (dn2 * (this._csig1 * ssig2) - this._dn1 * (this._ssig1 * csig2) - this._csig1 * csig2 * J12);
13583
- if (outmask & g.GEODESICSCALE) {
13584
- t = this._k2 * (ssig2 - this._ssig1) * (ssig2 + this._ssig1) / (this._dn1 + dn2);
13585
- vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * this._ssig1 / this._dn1;
13586
- vals.M21 = csig12 - (t * this._ssig1 - this._csig1 * J12) * ssig2 / dn2;
13587
- }
13588
- }
13589
- if (outmask & g.AREA) {
13590
- B42 = g.SinCosSeries(false, ssig2, csig2, this._C4a);
13591
- if (this._calp0 === 0 || this._salp0 === 0) {
13592
- salp12 = salp2 * this.calp1 - calp2 * this.salp1;
13593
- calp12 = calp2 * this.calp1 + salp2 * this.salp1;
13594
- } else {
13595
- salp12 = this._calp0 * this._salp0 * (csig12 <= 0 ? this._csig1 * (1 - csig12) + ssig12 * this._ssig1 : ssig12 * (this._csig1 * ssig12 / (1 + csig12) + this._ssig1));
13596
- calp12 = m.sq(this._salp0) + m.sq(this._calp0) * this._csig1 * csig2;
13597
- }
13598
- vals.S12 = this._c2 * Math.atan2(salp12, calp12) + this._A4 * (B42 - this._B41);
13599
- }
13600
- if (!arcmode) vals.a12 = sig12 / m.degree;
13601
- return vals;
13602
- };
13603
- l.GeodesicLine.prototype.Position = function(s12, outmask) {
13604
- return this.GenPosition(false, s12, outmask);
13605
- };
13606
- l.GeodesicLine.prototype.ArcPosition = function(a12, outmask) {
13607
- return this.GenPosition(true, a12, outmask);
13608
- };
13609
- l.GeodesicLine.prototype.GenSetDistance = function(arcmode, s13_a13) {
13610
- if (arcmode) this.SetArc(s13_a13);
13611
- else this.SetDistance(s13_a13);
13612
- };
13613
- l.GeodesicLine.prototype.SetDistance = function(s13) {
13614
- var r;
13615
- this.s13 = s13;
13616
- r = this.GenPosition(false, this.s13, g.ARC);
13617
- this.a13 = 0 + r.a12;
13618
- };
13619
- l.GeodesicLine.prototype.SetArc = function(a13) {
13620
- var r;
13621
- this.a13 = a13;
13622
- r = this.GenPosition(true, this.a13, g.DISTANCE);
13623
- this.s13 = 0 + r.s12;
13624
- };
13625
- })(geodesic.Geodesic, geodesic.GeodesicLine, geodesic.Math);
13626
- (function(p, g, m, a) {
13627
- "use strict";
13628
- var transit = function(lon1, lon2) {
13629
- var lon12 = m.AngDiff(lon1, lon2).d;
13630
- lon1 = m.AngNormalize(lon1);
13631
- lon2 = m.AngNormalize(lon2);
13632
- return lon12 > 0 && (lon1 < 0 && lon2 >= 0 || lon1 > 0 && lon2 === 0) ? 1 : lon12 < 0 && lon1 >= 0 && lon2 < 0 ? -1 : 0;
13633
- }, transitdirect = function(lon1, lon2) {
13634
- lon1 = lon1 % 720;
13635
- lon2 = lon2 % 720;
13636
- return (0 <= lon2 && lon2 < 360 || lon2 < -360 ? 0 : 1) - (0 <= lon1 && lon1 < 360 || lon1 < -360 ? 0 : 1);
13637
- }, AreaReduceA = function(area, area0, crossings, reverse, sign) {
13638
- area.Remainder(area0);
13639
- if (crossings & 1) area.Add((area.Sum() < 0 ? 1 : -1) * area0 / 2);
13640
- if (!reverse) area.Negate();
13641
- if (sign) {
13642
- if (area.Sum() > area0 / 2) area.Add(-area0);
13643
- else if (area.Sum() <= -area0 / 2) area.Add(+area0);
13644
- } else if (area.Sum() >= area0) area.Add(-area0);
13645
- else if (area.Sum() < 0) area.Add(+area0);
13646
- return 0 + area.Sum();
13647
- }, AreaReduceB = function(area, area0, crossings, reverse, sign) {
13648
- area = m.remainder(area, area0);
13649
- if (crossings & 1) area += (area < 0 ? 1 : -1) * area0 / 2;
13650
- if (!reverse) area *= -1;
13651
- if (sign) {
13652
- if (area > area0 / 2) area -= area0;
13653
- else if (area <= -area0 / 2) area += area0;
13654
- } else if (area >= area0) area -= area0;
13655
- else if (area < 0) area += area0;
13656
- return 0 + area;
13657
- };
13658
- p.PolygonArea = function(geod, polyline) {
13659
- this._geod = geod;
13660
- this.a = this._geod.a;
13661
- this.f = this._geod.f;
13662
- this._area0 = 4 * Math.PI * geod._c2;
13663
- this.polyline = !polyline ? false : polyline;
13664
- this._mask = g.LATITUDE | g.LONGITUDE | g.DISTANCE | (this.polyline ? g.NONE : g.AREA | g.LONG_UNROLL);
13665
- if (!this.polyline) this._areasum = new a.Accumulator(0);
13666
- this._perimetersum = new a.Accumulator(0);
13667
- this.Clear();
13668
- };
13669
- p.PolygonArea.prototype.Clear = function() {
13670
- this.num = 0;
13671
- this._crossings = 0;
13672
- if (!this.polyline) this._areasum.Set(0);
13673
- this._perimetersum.Set(0);
13674
- this._lat0 = this._lon0 = this.lat = this.lon = NaN;
13675
- };
13676
- p.PolygonArea.prototype.AddPoint = function(lat, lon) {
13677
- var t;
13678
- if (this.num === 0) {
13679
- this._lat0 = this.lat = lat;
13680
- this._lon0 = this.lon = lon;
13681
- } else {
13682
- t = this._geod.Inverse(this.lat, this.lon, lat, lon, this._mask);
13683
- this._perimetersum.Add(t.s12);
13684
- if (!this.polyline) {
13685
- this._areasum.Add(t.S12);
13686
- this._crossings += transit(this.lon, lon);
13687
- }
13688
- this.lat = lat;
13689
- this.lon = lon;
13690
- }
13691
- ++this.num;
13692
- };
13693
- p.PolygonArea.prototype.AddEdge = function(azi, s) {
13694
- var t;
13695
- if (this.num) {
13696
- t = this._geod.Direct(this.lat, this.lon, azi, s, this._mask);
13697
- this._perimetersum.Add(s);
13698
- if (!this.polyline) {
13699
- this._areasum.Add(t.S12);
13700
- this._crossings += transitdirect(this.lon, t.lon2);
13701
- }
13702
- this.lat = t.lat2;
13703
- this.lon = t.lon2;
13704
- }
13705
- ++this.num;
13706
- };
13707
- p.PolygonArea.prototype.Compute = function(reverse, sign) {
13708
- var vals = { number: this.num }, t, tempsum;
13709
- if (this.num < 2) {
13710
- vals.perimeter = 0;
13711
- if (!this.polyline) vals.area = 0;
13712
- return vals;
13713
- }
13714
- if (this.polyline) {
13715
- vals.perimeter = this._perimetersum.Sum();
13716
- return vals;
13717
- }
13718
- t = this._geod.Inverse(this.lat, this.lon, this._lat0, this._lon0, this._mask);
13719
- vals.perimeter = this._perimetersum.Sum(t.s12);
13720
- tempsum = new a.Accumulator(this._areasum);
13721
- tempsum.Add(t.S12);
13722
- vals.area = AreaReduceA(tempsum, this._area0, this._crossings + transit(this.lon, this._lon0), reverse, sign);
13723
- return vals;
13724
- };
13725
- p.PolygonArea.prototype.TestPoint = function(lat, lon, reverse, sign) {
13726
- var vals = { number: this.num + 1 }, t, tempsum, crossings, i;
13727
- if (this.num === 0) {
13728
- vals.perimeter = 0;
13729
- if (!this.polyline) vals.area = 0;
13730
- return vals;
13731
- }
13732
- vals.perimeter = this._perimetersum.Sum();
13733
- tempsum = this.polyline ? 0 : this._areasum.Sum();
13734
- crossings = this._crossings;
13735
- for (i = 0; i < (this.polyline ? 1 : 2); ++i) {
13736
- t = this._geod.Inverse(i === 0 ? this.lat : lat, i === 0 ? this.lon : lon, i !== 0 ? this._lat0 : lat, i !== 0 ? this._lon0 : lon, this._mask);
13737
- vals.perimeter += t.s12;
13738
- if (!this.polyline) {
13739
- tempsum += t.S12;
13740
- crossings += transit(i === 0 ? this.lon : lon, i !== 0 ? this._lon0 : lon);
13741
- }
13742
- }
13743
- if (this.polyline) return vals;
13744
- vals.area = AreaReduceB(tempsum, this._area0, crossings, reverse, sign);
13745
- return vals;
13746
- };
13747
- p.PolygonArea.prototype.TestEdge = function(azi, s, reverse, sign) {
13748
- var vals = { number: this.num ? this.num + 1 : 0 }, t, tempsum, crossings;
13749
- if (this.num === 0) return vals;
13750
- vals.perimeter = this._perimetersum.Sum() + s;
13751
- if (this.polyline) return vals;
13752
- tempsum = this._areasum.Sum();
13753
- crossings = this._crossings;
13754
- t = this._geod.Direct(this.lat, this.lon, azi, s, this._mask);
13755
- tempsum += t.S12;
13756
- crossings += transitdirect(this.lon, t.lon2);
13757
- crossings += transit(t.lon2, this._lon0);
13758
- t = this._geod.Inverse(t.lat2, t.lon2, this._lat0, this._lon0, this._mask);
13759
- vals.perimeter += t.s12;
13760
- tempsum += t.S12;
13761
- vals.area = AreaReduceB(tempsum, this._area0, crossings, reverse, sign);
13762
- return vals;
13763
- };
13764
- })(geodesic.PolygonArea, geodesic.Geodesic, geodesic.Math, geodesic.Accumulator);
13765
- cb(geodesic);
13766
- })(function(geo) {
13767
- if (typeof module === "object" && module.exports) module.exports = geo;
13768
- else if (typeof define === "function" && define.amd) define("geographiclib-geodesic", [], function() {
13769
- return geo;
13770
- });
13771
- else window.geodesic = geo;
13772
- });
13773
- })))(), 1);
13774
- /** Karney geodesics via GeographicLib; antipodal inputs are supported. */
11809
+ B12 = SinCosSeries(true, ssig2, csig2, this._C1a);
11810
+ serr = (1 + this._A1m1) * (sig12 + (B12 - this._B11)) - s12_a12 / this._b;
11811
+ sig12 = sig12 - serr / Math.sqrt(1 + this._k2 * sq(ssig2));
11812
+ ssig12 = Math.sin(sig12);
11813
+ csig12 = Math.cos(sig12);
11814
+ }
11815
+ }
11816
+ ssig2 = this._ssig1 * csig12 + this._csig1 * ssig12;
11817
+ csig2 = this._csig1 * csig12 - this._ssig1 * ssig12;
11818
+ dn2 = Math.sqrt(1 + this._k2 * sq(ssig2));
11819
+ if (outmask & 13317) {
11820
+ if (arcmode || Math.abs(this.f) > .01) B12 = SinCosSeries(true, ssig2, csig2, this._C1a);
11821
+ AB1 = (1 + this._A1m1) * (B12 - this._B11);
11822
+ }
11823
+ sbet2 = this._calp0 * ssig2;
11824
+ cbet2 = hypot(this._salp0, this._calp0 * csig2);
11825
+ if (cbet2 === 0) cbet2 = csig2 = tiny_;
11826
+ salp2 = this._salp0;
11827
+ calp2 = this._calp0 * csig2;
11828
+ if (arcmode && outmask & 1025) vals.s12 = this._b * ((1 + this._A1m1) * sig12 + AB1);
11829
+ if (outmask & 264) {
11830
+ somg2 = this._salp0 * ssig2;
11831
+ comg2 = csig2;
11832
+ E = copysign(1, this._salp0);
11833
+ omg12 = outmask & 32768 ? E * (sig12 - (Math.atan2(ssig2, csig2) - Math.atan2(this._ssig1, this._csig1)) + (Math.atan2(E * somg2, comg2) - Math.atan2(E * this._somg1, this._comg1))) : Math.atan2(somg2 * this._comg1 - comg2 * this._somg1, comg2 * this._comg1 + somg2 * this._somg1);
11834
+ lam12 = omg12 + this._A3c * (sig12 + (SinCosSeries(true, ssig2, csig2, this._C3a) - this._B31));
11835
+ lon12 = lam12 / degree;
11836
+ vals.lon2 = outmask & 32768 ? this.lon1 + lon12 : AngNormalize(AngNormalize(this.lon1) + AngNormalize(lon12));
11837
+ }
11838
+ if (outmask & 128) vals.lat2 = atan2d(sbet2, this._f1 * cbet2);
11839
+ if (outmask & 512) vals.azi2 = atan2d(salp2, calp2);
11840
+ if (outmask & 12293) {
11841
+ B22 = SinCosSeries(true, ssig2, csig2, this._C2a);
11842
+ AB2 = (1 + this._A2m1) * (B22 - this._B21);
11843
+ J12 = (this._A1m1 - this._A2m1) * sig12 + (AB1 - AB2);
11844
+ if (outmask & 4101) vals.m12 = this._b * (dn2 * (this._csig1 * ssig2) - this._dn1 * (this._ssig1 * csig2) - this._csig1 * csig2 * J12);
11845
+ if (outmask & 8197) {
11846
+ t = this._k2 * (ssig2 - this._ssig1) * (ssig2 + this._ssig1) / (this._dn1 + dn2);
11847
+ vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * this._ssig1 / this._dn1;
11848
+ vals.M21 = csig12 - (t * this._ssig1 - this._csig1 * J12) * ssig2 / dn2;
11849
+ }
11850
+ }
11851
+ if (outmask & 16400) {
11852
+ B42 = SinCosSeries(false, ssig2, csig2, this._C4a);
11853
+ if (this._calp0 === 0 || this._salp0 === 0) {
11854
+ salp12 = salp2 * this.calp1 - calp2 * this.salp1;
11855
+ calp12 = calp2 * this.calp1 + salp2 * this.salp1;
11856
+ } else {
11857
+ salp12 = this._calp0 * this._salp0 * (csig12 <= 0 ? this._csig1 * (1 - csig12) + ssig12 * this._ssig1 : ssig12 * (this._csig1 * ssig12 / (1 + csig12) + this._ssig1));
11858
+ calp12 = sq(this._salp0) + sq(this._calp0) * this._csig1 * csig2;
11859
+ }
11860
+ vals.S12 = this._c2 * Math.atan2(salp12, calp12) + this._A4 * (B42 - this._B41);
11861
+ }
11862
+ if (!arcmode) vals.a12 = sig12 / degree;
11863
+ return vals;
11864
+ }
11865
+ Position(s12, outmask = 0) {
11866
+ return this.GenPosition(false, s12, outmask);
11867
+ }
11868
+ ArcPosition(a12, outmask = 0) {
11869
+ return this.GenPosition(true, a12, outmask);
11870
+ }
11871
+ GenSetDistance(arcmode, s13_a13) {
11872
+ if (arcmode) this.SetArc(s13_a13);
11873
+ else this.SetDistance(s13_a13);
11874
+ }
11875
+ SetDistance(s13) {
11876
+ let r;
11877
+ this.s13 = s13;
11878
+ r = this.GenPosition(false, this.s13, 64);
11879
+ this.a13 = 0 + r.a12;
11880
+ }
11881
+ SetArc(a13) {
11882
+ let r;
11883
+ this.a13 = a13;
11884
+ r = this.GenPosition(true, this.a13, DISTANCE);
11885
+ this.s13 = 0 + r.s12;
11886
+ }
11887
+ };
11888
+ // src-gis/core/EllipsoidGeodesic.ts
11889
+ /** Internal TypeScript Karney geodesics; antipodal inputs are supported. */
13775
11890
  var EllipsoidGeodesic = class {
13776
11891
  ellipsoid;
13777
11892
  start = new Cartographic();
@@ -13787,7 +11902,7 @@ var EllipsoidGeodesic = class {
13787
11902
  }
13788
11903
  createGeodesic(e) {
13789
11904
  if (e.x !== e.y) throw new RangeError("Geodesics require an ellipsoid of revolution about Z");
13790
- return new import_geographiclib_geodesic_min.default.Geodesic.Geodesic(e.x, (e.x - e.z) / e.x);
11905
+ return new Geodesic(e.x, (e.x - e.z) / e.x);
13791
11906
  }
13792
11907
  setEndPoints(start, end) {
13793
11908
  this.start = start.clone().validate();
@@ -13801,6 +11916,11 @@ var EllipsoidGeodesic = class {
13801
11916
  this.surfaceDistance = r.s12;
13802
11917
  this.startHeading = r.azi1 * Math.PI / 180;
13803
11918
  this.endHeading = r.azi2 * Math.PI / 180;
11919
+ if (![
11920
+ this.surfaceDistance,
11921
+ this.startHeading,
11922
+ this.endHeading
11923
+ ].every(Number.isFinite)) throw new RangeError("Geodesic solver could not produce finite properties");
13804
11924
  return this;
13805
11925
  }
13806
11926
  interpolateUsingSurfaceDistance(distance, result) {
@@ -15010,6 +13130,6 @@ var DelaunaySlow = class {
15010
13130
  return [u, v];
15011
13131
  }
15012
13132
  };
15013
- export { ArrayObject, BSP, BTree, Box, BufferAttribute, BufferGeometry, csg_exports as CSG, Capsule, Circle, ClipType, Color, ConvexHull, Curve, DEGREES_PER_RADIAN, Delaunator, Delaunay, DelaunaySlow, Disk, Distance, EndType, Euler, EventHandler, Extrude, Float32BufferAttribute, Float64BufferAttribute, Frustum, src_gis_exports as GIS, HVec3, IKanimation_exports as IK, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntersectType, JoinType, KdTree, Line, Mat3, Mat4, MeshTool, ONE_OVER_PI, ONE_OVER_TWO_PI, Orientation, PI, PI_OVER_FOUR, PI_OVER_SIX, PI_OVER_THREE, PI_OVER_TWO, PI_TWO, Path, Plane, Point, PolyTree, Polygon, Polyline, QuadTree, QuadTree as QuatTree, Quat, RADIANS_PER_ARCSECOND, RADIANS_PER_DEGREE, Ray, Rectangle, robust_exports as Robust, Segment, Shape, Sphere, THREE_PI_OVER_TWO, ToDegrees, Tree, Triangle, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Vec2, Vec3, Vec4, Voronoi, angle, applyMatrix4, applyQuat, approximateEqual, boundingBox, calcCircleFromThreePoint, calculateVolume, ceilPowerOfTwo, circle, circleDistance, clamp, classify, cleanPolygon, clipPolygons, clone, closestPair, compose, convexHull, convexHull3D, delta4, delta5, delta6, delta7, delta8, delta9, disk, diskDistance, distance, euler, extrude, extrudeNext, extrudeToGeometryBuffer, extrude_obsolete, flat, floorPowerOfTwo, forall, geometryFromJSON, intersects, isInOnePlane, isPowerOfTwo, lerp, line, linkSide, linkSides, linkToGeometry, linksToGeometry, m3, m4, offsetPaths, pointsCollinear, projectOnPlane, quat, randFloat, randInt, recognitionPlane, reverseOnPlane, rotate, rotateByUnitVectors, scale, segment, sign, simplifyPointList, simplifyPolygon, smootherstep, smoothstep, splitPlaneGeometry, toFixed, toFixedAry, toGeometryBuffer, toRadians, translate, triangulation, unique, v2, v3, v4, vecs, vectorCompare };
13133
+ export { ArrayObject, BSP, BTree, Box, BufferAttribute, BufferGeometry, csg_exports as CSG, Capsule, Circle, ClipType, Color, ConvexHull, Curve, DEGREES_PER_RADIAN, Decimal, Delaunator, Delaunay, DelaunaySlow, Disk, Distance, EndType, Euler, EventHandler, Extrude, Float32BufferAttribute, Float64BufferAttribute, Frustum, src_gis_exports as GIS, HVec3, IKanimation_exports as IK, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntersectType, JoinType, KdTree, Line, Mat3, Mat4, MeshTool, ONE_OVER_PI, ONE_OVER_TWO_PI, Orientation, PI, PI_OVER_FOUR, PI_OVER_SIX, PI_OVER_THREE, PI_OVER_TWO, PI_TWO, Path, Plane, Point, PolyTree, Polygon, Polyline, QuadTree, QuadTree as QuatTree, Quat, RADIANS_PER_ARCSECOND, RADIANS_PER_DEGREE, Ray, Rectangle, robust_exports as Robust, Segment, Shape, Sphere, THREE_PI_OVER_TWO, ToDegrees, Tree, Triangle, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Vec2, Vec3, Vec4, Voronoi, angle, applyMatrix4, applyQuat, approximateEqual, boundingBox, calcCircleFromThreePoint, calculateVolume, ceilPowerOfTwo, circle, circleDistance, clamp, classify, cleanPolygon, clipPolygons, clone, closestPair, compose, convexHull, convexHull3D, delta4, delta5, delta6, delta7, delta8, delta9, disk, diskDistance, distance, euler, extrude, extrudeNext, extrudeToGeometryBuffer, extrude_obsolete, flat, floorPowerOfTwo, forall, geometryFromJSON, intersects, isInOnePlane, isPowerOfTwo, lerp, line, linkSide, linkSides, linkToGeometry, linksToGeometry, m3, m4, offsetPaths, pointsCollinear, projectOnPlane, quat, randFloat, randInt, recognitionPlane, reverseOnPlane, rotate, rotateByUnitVectors, scale, segment, sign, simplifyPointList, simplifyPolygon, smootherstep, smoothstep, splitPlaneGeometry, toFixed, toFixedAry, toGeometryBuffer, toRadians, translate, triangulation, unique, v2, v3, v4, vecs, vectorCompare };
15014
13134
 
15015
13135
  //# sourceMappingURL=index.js.map