| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.default = void 0;
|
|---|
| 7 | var epsilon2 = 1e-12;
|
|---|
| 8 | function cosh(x) {
|
|---|
| 9 | return ((x = Math.exp(x)) + 1 / x) / 2;
|
|---|
| 10 | }
|
|---|
| 11 | function sinh(x) {
|
|---|
| 12 | return ((x = Math.exp(x)) - 1 / x) / 2;
|
|---|
| 13 | }
|
|---|
| 14 | function tanh(x) {
|
|---|
| 15 | return ((x = Math.exp(2 * x)) - 1) / (x + 1);
|
|---|
| 16 | }
|
|---|
| 17 | var _default = exports.default = function zoomRho(rho, rho2, rho4) {
|
|---|
| 18 | // p0 = [ux0, uy0, w0]
|
|---|
| 19 | // p1 = [ux1, uy1, w1]
|
|---|
| 20 | function zoom(p0, p1) {
|
|---|
| 21 | var ux0 = p0[0],
|
|---|
| 22 | uy0 = p0[1],
|
|---|
| 23 | w0 = p0[2],
|
|---|
| 24 | ux1 = p1[0],
|
|---|
| 25 | uy1 = p1[1],
|
|---|
| 26 | w1 = p1[2],
|
|---|
| 27 | dx = ux1 - ux0,
|
|---|
| 28 | dy = uy1 - uy0,
|
|---|
| 29 | d2 = dx * dx + dy * dy,
|
|---|
| 30 | i,
|
|---|
| 31 | S;
|
|---|
| 32 |
|
|---|
| 33 | // Special case for u0 ≅ u1.
|
|---|
| 34 | if (d2 < epsilon2) {
|
|---|
| 35 | S = Math.log(w1 / w0) / rho;
|
|---|
| 36 | i = function (t) {
|
|---|
| 37 | return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
|
|---|
| 38 | };
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | // General case.
|
|---|
| 42 | else {
|
|---|
| 43 | var d1 = Math.sqrt(d2),
|
|---|
| 44 | b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
|
|---|
| 45 | b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
|
|---|
| 46 | r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
|
|---|
| 47 | r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
|
|---|
| 48 | S = (r1 - r0) / rho;
|
|---|
| 49 | i = function (t) {
|
|---|
| 50 | var s = t * S,
|
|---|
| 51 | coshr0 = cosh(r0),
|
|---|
| 52 | u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
|
|---|
| 53 | return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
|
|---|
| 54 | };
|
|---|
| 55 | }
|
|---|
| 56 | i.duration = S * 1000 * rho / Math.SQRT2;
|
|---|
| 57 | return i;
|
|---|
| 58 | }
|
|---|
| 59 | zoom.rho = function (_) {
|
|---|
| 60 | var _1 = Math.max(1e-3, +_),
|
|---|
| 61 | _2 = _1 * _1,
|
|---|
| 62 | _4 = _2 * _2;
|
|---|
| 63 | return zoomRho(_1, _2, _4);
|
|---|
| 64 | };
|
|---|
| 65 | return zoom;
|
|---|
| 66 | }(Math.SQRT2, 2, 4); |
|---|