nodes2ts 1.1.9 → 3.0.0

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.
Files changed (105) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.cjs +11 -0
  3. package/.github/workflows/lint.js.yml +22 -0
  4. package/.github/workflows/node.js.yml +22 -0
  5. package/.mocharc.js +7 -0
  6. package/README.md +22 -5
  7. package/dist/Interval.d.ts +7 -8
  8. package/dist/Interval.js +12 -12
  9. package/dist/Interval.js.map +1 -1
  10. package/dist/MutableInteger.js +5 -4
  11. package/dist/MutableInteger.js.map +1 -1
  12. package/dist/Platform.d.ts +15 -0
  13. package/dist/Platform.js +53 -0
  14. package/dist/Platform.js.map +1 -0
  15. package/dist/R1Interval.d.ts +8 -9
  16. package/dist/R1Interval.js +59 -78
  17. package/dist/R1Interval.js.map +1 -1
  18. package/dist/R2Vector.d.ts +12 -13
  19. package/dist/R2Vector.js +65 -85
  20. package/dist/R2Vector.js.map +1 -1
  21. package/dist/S1Angle.d.ts +38 -5
  22. package/dist/S1Angle.js +89 -37
  23. package/dist/S1Angle.js.map +1 -1
  24. package/dist/S1ChordAngle.d.ts +166 -0
  25. package/dist/S1ChordAngle.js +318 -0
  26. package/dist/S1ChordAngle.js.map +1 -0
  27. package/dist/S1Interval.d.ts +11 -12
  28. package/dist/S1Interval.js +134 -140
  29. package/dist/S1Interval.js.map +1 -1
  30. package/dist/S2.d.ts +8 -5
  31. package/dist/S2.js +91 -108
  32. package/dist/S2.js.map +1 -1
  33. package/dist/S2Cap.d.ts +33 -25
  34. package/dist/S2Cap.js +199 -203
  35. package/dist/S2Cap.js.map +1 -1
  36. package/dist/S2Cell.d.ts +15 -13
  37. package/dist/S2Cell.js +196 -206
  38. package/dist/S2Cell.js.map +1 -1
  39. package/dist/S2CellId.d.ts +37 -14
  40. package/dist/S2CellId.js +407 -359
  41. package/dist/S2CellId.js.map +1 -1
  42. package/dist/S2CellUnion.d.ts +1 -2
  43. package/dist/S2CellUnion.js +137 -133
  44. package/dist/S2CellUnion.js.map +1 -1
  45. package/dist/S2EdgeUtil.js +14 -17
  46. package/dist/S2EdgeUtil.js.map +1 -1
  47. package/dist/S2LatLng.d.ts +15 -11
  48. package/dist/S2LatLng.js +100 -114
  49. package/dist/S2LatLng.js.map +1 -1
  50. package/dist/S2LatLngRect.d.ts +8 -4
  51. package/dist/S2LatLngRect.js +215 -197
  52. package/dist/S2LatLngRect.js.map +1 -1
  53. package/dist/S2Metric.d.ts +4 -5
  54. package/dist/S2Metric.js +30 -27
  55. package/dist/S2Metric.js.map +1 -1
  56. package/dist/S2Point.d.ts +48 -14
  57. package/dist/S2Point.js +156 -109
  58. package/dist/S2Point.js.map +1 -1
  59. package/dist/S2Projections.d.ts +43 -9
  60. package/dist/S2Projections.js +226 -47
  61. package/dist/S2Projections.js.map +1 -1
  62. package/dist/S2Region.js +2 -1
  63. package/dist/S2Region.js.map +1 -1
  64. package/dist/S2RegionCoverer.d.ts +21 -6
  65. package/dist/S2RegionCoverer.js +144 -109
  66. package/dist/S2RegionCoverer.js.map +1 -1
  67. package/dist/export.d.ts +0 -1
  68. package/dist/export.js +42 -32
  69. package/dist/export.js.map +1 -1
  70. package/dist/utils/preconditions.d.ts +2 -0
  71. package/dist/utils/preconditions.js +16 -0
  72. package/dist/utils/preconditions.js.map +1 -0
  73. package/package.json +28 -34
  74. package/.npmignore +0 -8
  75. package/.nyc_output/1eb1f420a13c15f529aac41a40bcaa21.json +0 -1
  76. package/.nyc_output/5ff62256eb1c111254ba0b469fb547da.json +0 -1
  77. package/.nyc_output/949d6e8c2061067f3bdfd27dfff5ba83.json +0 -1
  78. package/coverage/Interval.ts.html +0 -203
  79. package/coverage/MutableInteger.ts.html +0 -77
  80. package/coverage/R1Interval.ts.html +0 -647
  81. package/coverage/R2Vector.ts.html +0 -587
  82. package/coverage/S1Angle.ts.html +0 -344
  83. package/coverage/S1Interval.ts.html +0 -1349
  84. package/coverage/S2.ts.html +0 -1178
  85. package/coverage/S2Cap.ts.html +0 -1433
  86. package/coverage/S2Cell.ts.html +0 -1415
  87. package/coverage/S2CellId.ts.html +0 -3329
  88. package/coverage/S2EdgeUtil.ts.html +0 -2534
  89. package/coverage/S2LatLng.ts.html +0 -848
  90. package/coverage/S2LatLngRect.ts.html +0 -2222
  91. package/coverage/S2Point.ts.html +0 -758
  92. package/coverage/S2Projections.ts.html +0 -518
  93. package/coverage/base.css +0 -212
  94. package/coverage/decimal.ts.html +0 -68
  95. package/coverage/index.html +0 -288
  96. package/coverage/prettify.css +0 -1
  97. package/coverage/prettify.js +0 -1
  98. package/coverage/sort-arrow-sprite.png +0 -0
  99. package/coverage/sorter.js +0 -158
  100. package/dist/decimal.d.ts +0 -3
  101. package/dist/decimal.js +0 -4
  102. package/dist/decimal.js.map +0 -1
  103. package/dist/decimal_augmentation.d.ts +0 -24
  104. package/dist/decimal_augmentation.js +0 -2
  105. package/dist/decimal_augmentation.js.map +0 -1
package/dist/R2Vector.js CHANGED
@@ -1,74 +1,63 @@
1
1
  "use strict";
2
- var S2Point_1 = require("./S2Point");
3
- var decimal_1 = require('./decimal');
4
- var S2_1 = require("./S2");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.R2Vector = void 0;
4
+ const S2Point_1 = require("./S2Point");
5
5
  /**
6
6
  * R2Vector represents a vector in the two-dimensional space. It defines the
7
7
  * basic geometrical operations for 2D vectors, e.g. cross product, addition,
8
8
  * norm, comparison etc.
9
9
  *
10
10
  */
11
- var R2Vector = (function () {
12
- function R2Vector(_x, _y) {
13
- this._x = new decimal_1.Decimal(_x);
14
- this._y = new decimal_1.Decimal(_y);
15
- // this._x = new Decimal(_x) as decimal.Decimal;
16
- // this._y = new Decimal(_y) as decimal.Decimal;
17
- }
18
- Object.defineProperty(R2Vector.prototype, "x", {
19
- get: function () {
20
- return this._x;
21
- },
22
- enumerable: true,
23
- configurable: true
24
- });
25
- Object.defineProperty(R2Vector.prototype, "y", {
26
- get: function () {
27
- return this._y;
28
- },
29
- enumerable: true,
30
- configurable: true
31
- });
32
- R2Vector.prototype.get = function (index) {
33
- if (index > 1) {
34
- throw new Error("Index out fo bounds error " + index);
11
+ class R2Vector {
12
+ constructor(_x, _y) {
13
+ this._x = _x;
14
+ this._y = _y;
15
+ }
16
+ get x() {
17
+ return this._x;
18
+ }
19
+ get y() {
20
+ return this._y;
21
+ }
22
+ get(index) {
23
+ if (index < 0 || index > 1) {
24
+ throw new Error(`Index out fo bounds error ${index}`);
35
25
  }
36
26
  return index == 0 ? this._x : this._y;
37
- };
38
- R2Vector.fromPointFace = function (p, face) {
27
+ }
28
+ static fromPointFace(p, face) {
39
29
  return p.toR2Vector(face);
40
- };
41
- R2Vector.add = function (p1, p2) {
42
- return new R2Vector(p1._x.plus(p2._x), p1._y.plus(p2._y));
43
- };
44
- R2Vector.mul = function (p, _m) {
45
- var m = new decimal_1.Decimal(_m);
46
- return new R2Vector(m.times(p._x), m.times(p._y));
47
- };
48
- R2Vector.prototype.norm2 = function () {
49
- return this.x.pow(2).plus(this.y.pow(2));
50
- };
51
- R2Vector.dotProd = function (p1, p2) {
52
- return p1.x.times(p2.x).plus(p1.y.times(p2.y));
53
- };
54
- R2Vector.prototype.dotProd = function (that) {
30
+ }
31
+ static add(p1, p2) {
32
+ return new R2Vector(p1._x + (p2._x), p1._y + (p2._y));
33
+ }
34
+ static mul(p, m) {
35
+ return new R2Vector(m * (p._x), m * (p._y));
36
+ }
37
+ norm2() {
38
+ return this.x * this.x + this.y * this.y;
39
+ }
40
+ static dotProd(p1, p2) {
41
+ return p1.x * (p2.x) + (p1.y * (p2.y));
42
+ }
43
+ dotProd(that) {
55
44
  return R2Vector.dotProd(this, that);
56
- };
57
- R2Vector.prototype.crossProd = function (that) {
58
- return this.x.times(that.y).minus(this.y.times(that.x));
59
- };
60
- R2Vector.prototype.lessThan = function (vb) {
61
- if (this.x.lt(vb.x)) {
45
+ }
46
+ crossProd(that) {
47
+ return this.x * (that.y) - (this.y * (that.x));
48
+ }
49
+ lessThan(vb) {
50
+ if (this.x < (vb.x)) {
62
51
  return true;
63
52
  }
64
- if (vb.x.lt(this.x)) {
53
+ if (vb.x < (this.x)) {
65
54
  return false;
66
55
  }
67
- if (this.y.lt(vb.y)) {
56
+ if (this.y < (vb.y)) {
68
57
  return true;
69
58
  }
70
59
  return false;
71
- };
60
+ }
72
61
  //
73
62
  // @Override
74
63
  // public boolean equals(Object that) {
@@ -90,62 +79,53 @@ var R2Vector = (function () {
90
79
  // return (int) (value ^ (value >>> 32));
91
80
  // }
92
81
  //
93
- R2Vector.fromSTVector = function (stVector) {
82
+ static fromSTVector(stVector) {
94
83
  return new R2Vector(R2Vector.singleStTOUV(stVector.x), R2Vector.singleStTOUV(stVector.y));
95
- };
84
+ }
96
85
  // from S2Projections.stToUV (QUADRATIC)
97
- R2Vector.singleStTOUV = function (_s) {
98
- var s = S2_1.S2.toDecimal(_s);
99
- if (s.gte(0)) {
100
- return S2_1.S2.toDecimal(1)
101
- .dividedBy(3)
102
- .times(s.plus(1).pow(2).minus(1));
86
+ static singleStTOUV(s) {
87
+ if (s >= 0.5) {
88
+ return (1 / 3) * (4 * s * s - 1);
103
89
  }
104
90
  else {
105
- return S2_1.S2.toDecimal(1)
106
- .dividedBy(3)
107
- .times(S2_1.S2.toDecimal(1)
108
- .minus(S2_1.S2.toDecimal(1).minus(s).pow(2)));
91
+ return (1 / 3) * (1 - 4 * (1 - s) * (1 - s));
109
92
  }
110
- };
111
- R2Vector.singleUVToST = function (_x) {
112
- var x = S2_1.S2.toDecimal(_x);
113
- if (x.gte(0)) {
114
- return decimal_1.Decimal.sqrt(x.times(3).plus(1)).minus(1);
93
+ }
94
+ static singleUVToST(u) {
95
+ if (u >= 0) {
96
+ return 0.5 * Math.sqrt(1 + 3 * u);
115
97
  }
116
98
  else {
117
- return S2_1.S2.toDecimal(1)
118
- .minus(decimal_1.Decimal.sqrt(S2_1.S2.toDecimal(1).minus(x.times(3))));
99
+ return 1 - 0.5 * Math.sqrt(1 - 3 * u);
119
100
  }
120
- };
101
+ }
121
102
  /**
122
103
  * To be used only if this vector is representing uv.
123
104
  * @param face
124
105
  * @returns {S2Point}
125
106
  */
126
- R2Vector.prototype.toPoint = function (face) {
107
+ toPoint(face) {
127
108
  switch (face) {
128
109
  case 0:
129
110
  return new S2Point_1.S2Point(1, this.x, this.y);
130
111
  case 1:
131
- return new S2Point_1.S2Point(this.x.neg(), 1, this.y);
112
+ return new S2Point_1.S2Point(this.x * -1, 1, this.y);
132
113
  case 2:
133
- return new S2Point_1.S2Point(this.x.neg(), this.y.neg(), 1);
114
+ return new S2Point_1.S2Point(this.x * -1, this.y * -1, 1);
134
115
  case 3:
135
- return new S2Point_1.S2Point(-1, this.y.neg(), this.x.neg());
116
+ return new S2Point_1.S2Point(-1, this.y * -1, this.x * -1);
136
117
  case 4:
137
- return new S2Point_1.S2Point(this.y, -1, this.x.neg());
118
+ return new S2Point_1.S2Point(this.y, -1, this.x * -1);
138
119
  default:
139
120
  return new S2Point_1.S2Point(this.y, this.x, -1);
140
121
  }
141
- };
142
- R2Vector.prototype.toSt = function (which) {
122
+ }
123
+ toSt(which) {
143
124
  return which == 0 ? R2Vector.singleUVToST(this.x) : R2Vector.singleUVToST(this.y);
144
- };
145
- R2Vector.prototype.toString = function () {
125
+ }
126
+ toString() {
146
127
  return "(" + this.x.toString() + ", " + this.y.toString() + ")";
147
- };
148
- return R2Vector;
149
- }());
128
+ }
129
+ }
150
130
  exports.R2Vector = R2Vector;
151
131
  //# sourceMappingURL=R2Vector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"R2Vector.js","sourceRoot":"","sources":["../src/R2Vector.ts"],"names":[],"mappings":";AAAA,wBAAsB,WAAW,CAAC,CAAA;AAClC,wBAAsB,WAAW,CAAC,CAAA;AAClC,mBAAiB,MAAM,CAAC,CAAA;AAExB;;;;;GAKG;AACH;IAGE,kBAAY,EAAyB,EAAE,EAAyB;QAC9D,IAAI,CAAC,EAA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,CAAC,CAAC,CAAC;SAC1C;IACH,CAAC;IAEM,IAAI,CAAC,KAAK;QACf,OAAO,KAAK,IAAI,CAAC,CAAA,CAAC,CAAA,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IACM,QAAQ;QACb,OAAO,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC;IAClE,CAAC;CAEF;AA7ID,4BA6IC"}
package/dist/S1Angle.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- /// <reference types="decimal.js" />
2
1
  import { S2Point } from "./S2Point";
3
2
  export declare class S1Angle {
4
- radians: decimal.Decimal;
5
- constructor(radians: number | decimal.Decimal);
6
- degrees(): decimal.Decimal;
3
+ static INFINITY: S1Angle;
4
+ static ZERO: S1Angle;
5
+ radians: number;
6
+ constructor(radians: number);
7
+ degrees(): number;
7
8
  /**
8
9
  * Return the angle between two points, which is also equal to the distance
9
10
  * between these points on the unit sphere. The points do not need to be
@@ -16,7 +17,38 @@ export declare class S1Angle {
16
17
  greaterOrEquals(that: S1Angle): boolean;
17
18
  static max(left: S1Angle, right: S1Angle): S1Angle;
18
19
  static min(left: S1Angle, right: S1Angle): S1Angle;
19
- static degrees(degrees: number | decimal.Decimal): S1Angle;
20
+ static radians(radians: number): S1Angle;
21
+ static degrees(degrees: number): S1Angle;
22
+ /**
23
+ * Retuns an {@link S1Angle} whose angle is <code>(this + a)</code>.
24
+ */
25
+ add(a: S1Angle): S1Angle;
26
+ /**
27
+ * Retuns an {@link S1Angle} whose angle is <code>(this - a)</code>.
28
+ */
29
+ sub(a: S1Angle): S1Angle;
30
+ /**
31
+ * Retuns an {@link S1Angle} whose angle is <code>(this * m)</code>.
32
+ */
33
+ mul(m: number): S1Angle;
34
+ /**
35
+ * Retuns an {@link S1Angle} whose angle is <code>(this / d)</code>.
36
+ */
37
+ div(d: number): S1Angle;
38
+ /**
39
+ * Returns the trigonometric cosine of the angle.
40
+ */
41
+ cos(): number;
42
+ /**
43
+ * Returns the trigonometric sine of the angle.
44
+ */
45
+ sin(): number;
46
+ /**
47
+ * Returns the trigonometric tangent of the angle.
48
+ */
49
+ tan(): number;
50
+ /** Returns the distance along the surface of a sphere of the given radius. */
51
+ distance(radius: number): number;
20
52
  /**
21
53
  * Writes the angle in degrees with a "d" suffix, e.g. "17.3745d". By default
22
54
  * 6 digits are printed; this can be changed using setprecision(). Up to 17
@@ -24,4 +56,5 @@ export declare class S1Angle {
24
56
  */
25
57
  toString(): string;
26
58
  compareTo(that: S1Angle): number;
59
+ equals(that: S1Angle): boolean;
27
60
  }
package/dist/S1Angle.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- var decimal_1 = require('./decimal');
3
- var S2_1 = require("./S2");
4
- var S1Angle = (function () {
5
- function S1Angle(radians) {
6
- this.radians = new decimal_1.Decimal(radians);
7
- }
8
- S1Angle.prototype.degrees = function () {
9
- return S2_1.S2.toDecimal(this.radians).times((180 / Math.PI));
10
- };
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.S1Angle = void 0;
4
+ class S1Angle {
5
+ constructor(radians) {
6
+ this.radians = radians;
7
+ }
8
+ degrees() {
9
+ return this.radians * 180 / Math.PI;
10
+ }
11
11
  //
12
12
  // public long e5() {
13
13
  // return Math.round(degrees() * 1e5);
@@ -25,31 +25,79 @@ var S1Angle = (function () {
25
25
  * between these points on the unit sphere. The points do not need to be
26
26
  * normalized.
27
27
  */
28
- S1Angle.fromPoints = function (x, y) {
28
+ static fromPoints(x, y) {
29
29
  return new S1Angle(x.angle(y));
30
- };
31
- S1Angle.prototype.lessThan = function (that) {
32
- return this.radians.lt(that.radians);
33
- };
34
- S1Angle.prototype.greaterThan = function (that) {
35
- return this.radians.gt(that.radians);
36
- };
37
- S1Angle.prototype.lessOrEquals = function (that) {
38
- return this.radians.lte(that.radians);
39
- };
40
- S1Angle.prototype.greaterOrEquals = function (that) {
41
- return this.radians.gte(that.radians);
42
- };
43
- S1Angle.max = function (left, right) {
30
+ }
31
+ lessThan(that) {
32
+ return this.radians < (that.radians);
33
+ }
34
+ greaterThan(that) {
35
+ return this.radians > (that.radians);
36
+ }
37
+ lessOrEquals(that) {
38
+ return this.radians <= (that.radians);
39
+ }
40
+ greaterOrEquals(that) {
41
+ return this.radians >= (that.radians);
42
+ }
43
+ static max(left, right) {
44
44
  return right.greaterThan(left) ? right : left;
45
- };
46
- S1Angle.min = function (left, right) {
45
+ }
46
+ static min(left, right) {
47
47
  return right.greaterThan(left) ? left : right;
48
- };
49
- S1Angle.degrees = function (degrees) {
50
- var d = new decimal_1.Decimal(degrees);
51
- return new S1Angle(d.times(Math.PI / 180));
52
- };
48
+ }
49
+ static radians(radians) {
50
+ return new S1Angle(radians);
51
+ }
52
+ static degrees(degrees) {
53
+ return new S1Angle(degrees * (Math.PI / 180));
54
+ }
55
+ /**
56
+ * Retuns an {@link S1Angle} whose angle is <code>(this + a)</code>.
57
+ */
58
+ add(a) {
59
+ return new S1Angle(this.radians + a.radians);
60
+ }
61
+ /**
62
+ * Retuns an {@link S1Angle} whose angle is <code>(this - a)</code>.
63
+ */
64
+ sub(a) {
65
+ return new S1Angle(this.radians - a.radians);
66
+ }
67
+ /**
68
+ * Retuns an {@link S1Angle} whose angle is <code>(this * m)</code>.
69
+ */
70
+ mul(m) {
71
+ return new S1Angle(this.radians * m);
72
+ }
73
+ /**
74
+ * Retuns an {@link S1Angle} whose angle is <code>(this / d)</code>.
75
+ */
76
+ div(d) {
77
+ return new S1Angle(this.radians / d);
78
+ }
79
+ /**
80
+ * Returns the trigonometric cosine of the angle.
81
+ */
82
+ cos() {
83
+ return Math.cos(this.radians);
84
+ }
85
+ /**
86
+ * Returns the trigonometric sine of the angle.
87
+ */
88
+ sin() {
89
+ return Math.sin(this.radians);
90
+ }
91
+ /**
92
+ * Returns the trigonometric tangent of the angle.
93
+ */
94
+ tan() {
95
+ return Math.tan(this.radians);
96
+ }
97
+ /** Returns the distance along the surface of a sphere of the given radius. */
98
+ distance(radius) {
99
+ return this.radians * radius;
100
+ }
53
101
  //
54
102
  // public static S1Angle e5(long e5) {
55
103
  // return degrees(e5 * 1e-5);
@@ -69,13 +117,17 @@ var S1Angle = (function () {
69
117
  * 6 digits are printed; this can be changed using setprecision(). Up to 17
70
118
  * digits are required to distinguish one angle from another.
71
119
  */
72
- S1Angle.prototype.toString = function () {
120
+ toString() {
73
121
  return this.degrees() + "d";
74
- };
75
- S1Angle.prototype.compareTo = function (that) {
122
+ }
123
+ compareTo(that) {
76
124
  return this.radians < that.radians ? -1 : this.radians > that.radians ? 1 : 0;
77
- };
78
- return S1Angle;
79
- }());
125
+ }
126
+ equals(that) {
127
+ return this.compareTo(that) === 0;
128
+ }
129
+ }
80
130
  exports.S1Angle = S1Angle;
131
+ S1Angle.INFINITY = new S1Angle(Number.POSITIVE_INFINITY);
132
+ S1Angle.ZERO = new S1Angle(0);
81
133
  //# sourceMappingURL=S1Angle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"S1Angle.js","sourceRoot":"","sources":["../src/S1Angle.ts"],"names":[],"mappings":";AACA,wBAAsB,WAAW,CAAC,CAAA;AAClC,mBAAiB,MAAM,CAAC,CAAA;AACxB;IAGE,iBAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAGM,yBAAO,GAAd;QACE,MAAM,CAAC,OAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,EAAE;IACF,qBAAqB;IACrB,wCAAwC;IACxC,IAAI;IACJ,EAAE;IACF,qBAAqB;I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JH,0BA0JC;AAzJe,gBAAQ,GAAY,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC1D,YAAI,GAAY,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * S1ChordAngle represents the angle subtended by a chord (i.e., the straight 3D Cartesian line
3
+ * segment connecting two points on the unit sphere). Its representation makes it very efficient for
4
+ * computing and comparing distances, but unlike S1Angle it is only capable of representing angles
5
+ * between 0 and Pi radians. Generally, S1ChordAngle should only be used in loops where many angles
6
+ * need to be calculated and compared. Otherwise it is simpler to use S1Angle.
7
+ *
8
+ * <p>S1ChordAngle also loses some accuracy as the angle approaches Pi radians. Specifically, the
9
+ * representation of (Pi - x) radians can be expected to have an error of about (1e-15 / x), with a
10
+ * maximum error of about 1e-7.
11
+ */
12
+ import { S1Angle } from './S1Angle';
13
+ import { S2Point } from './S2Point';
14
+ export declare class S1ChordAngle {
15
+ /** Max value that can be returned from {@link #getLength2()}. */
16
+ static MAX_LENGTH2: number;
17
+ /** The zero chord angle. */
18
+ static ZERO: S1ChordAngle;
19
+ /** The chord angle of 90 degrees (a "right angle"). */
20
+ static RIGHT: S1ChordAngle;
21
+ /** The chord angle of 180 degrees (a "straight angle"). This is the max finite chord angle. */
22
+ static STRAIGHT: S1ChordAngle;
23
+ /**
24
+ * A chord angle larger than any finite chord angle. The only valid operations on {@code INFINITY}
25
+ * are comparisons and {@link S1Angle} conversions.
26
+ */
27
+ static INFINITY: S1ChordAngle;
28
+ /**
29
+ * A chord angle smaller than {@link #ZERO}. The only valid operations on {@code NEGATIVE} are
30
+ * comparisons and {@link S1Angle} conversions.
31
+ */
32
+ static NEGATIVE: S1ChordAngle;
33
+ private length2;
34
+ /**
35
+ * S1ChordAngles are represented by the squared chord length, which can range from 0 to {@code
36
+ * MAX_LENGTH2}. {@link #INFINITY} uses an infinite squared length.
37
+ */
38
+ constructor(length2: number);
39
+ /**
40
+ * Constructs the S1ChordAngle corresponding to the distance between the two given points. The
41
+ * points must be unit length.
42
+ */
43
+ static fromS2Point(x: S2Point, y: S2Point): S1ChordAngle;
44
+ /**
45
+ * Returns a new chord angle approximated from {@code angle} (see {@link
46
+ * #getS1AngleConstructorMaxError()} for the max magnitude of the error).
47
+ *
48
+ * <p>Angles outside the range [0, Pi] are handled as follows:
49
+ *
50
+ * <ul>
51
+ * <li>{@link S1Angle#INFINITY} is mapped to {@link #INFINITY}
52
+ * <li>negative angles are mapped to {@link #NEGATIVE}
53
+ * <li>finite angles larger than Pi are mapped to {@link #STRAIGHT}
54
+ * </ul>
55
+ *
56
+ * <p>Note that this operation is relatively expensive and should be avoided. To use {@link
57
+ * S1ChordAngle} effectively, you should structure your code so that input arguments are converted
58
+ * to S1ChordAngles at the beginning of your algorithm, and results are converted back to {@link
59
+ * S1Angle}s only at the end.
60
+ */
61
+ static fromS1Angle(angle: S1Angle): S1ChordAngle;
62
+ /**
63
+ * Construct an S1ChordAngle from the squared chord length. Note that the argument is
64
+ * automatically clamped to a maximum of {@code MAX_LENGTH2} to handle possible roundoff errors.
65
+ * The argument must be non-negative.
66
+ */
67
+ static fromLength2(length2: number): S1ChordAngle;
68
+ /** Returns whether the chord distance is exactly 0. */
69
+ isZero(): boolean;
70
+ /** Returns whether the chord distance is negative. */
71
+ isNegative(): boolean;
72
+ /** Returns whether the chord distance is exactly (positive) infinity. */
73
+ isInfinity(): boolean;
74
+ /** Returns true if the angle is negative or infinity. */
75
+ isSpecial(): boolean;
76
+ /**
77
+ * Returns true if getLength2() is within the normal range of 0 to 4 (inclusive) or the angle is
78
+ * special.
79
+ */
80
+ isValid(): boolean;
81
+ /**
82
+ * Convert the chord angle to an {@link S1Angle}. {@link #INFINITY} is converted to {@link
83
+ * S1Angle#INFINITY}, and {@link #NEGATIVE} is converted to a negative {@link S1Angle}. This
84
+ * operation is relatively expensive.
85
+ */
86
+ toAngle(): S1Angle;
87
+ /** The squared length of the chord. (Most clients will not need this.) */
88
+ getLength2(): number;
89
+ /**
90
+ * Returns the smallest representable S1ChordAngle larger than this object. This can be used to
91
+ * convert a "<" comparison to a "<=" comparison.
92
+ *
93
+ * <p>Note the following special cases:
94
+ *
95
+ * <ul>
96
+ * <li>NEGATIVE.successor() == ZERO
97
+ * <li>STRAIGHT.successor() == INFINITY
98
+ * <li>INFINITY.Successor() == INFINITY
99
+ * </ul>
100
+ */
101
+ /**
102
+ * As {@link #successor}, but returns the largest representable S1ChordAngle less than this
103
+ * object.
104
+ *
105
+ * <p>Note the following special cases:
106
+ *
107
+ * <ul>
108
+ * <li>INFINITY.predecessor() == STRAIGHT
109
+ * <li>ZERO.predecessor() == NEGATIVE
110
+ * <li>NEGATIVE.predecessor() == NEGATIVE
111
+ * </ul>
112
+ */
113
+ /**
114
+ * Returns a new S1ChordAngle whose chord distance represents the sum of the angular distances
115
+ * represented by the 'a' and 'b' chord angles.
116
+ *
117
+ * <p>Note that this method is much more efficient than converting the chord angles to S1Angles
118
+ * and adding those. It requires only one square root plus a few additions and multiplications.
119
+ */
120
+ static add(a: S1ChordAngle, b: S1ChordAngle): S1ChordAngle;
121
+ /**
122
+ * Subtract one S1ChordAngle from another.
123
+ *
124
+ * <p>Note that this method is much more efficient than converting the chord angles to S1Angles
125
+ * and adding those. It requires only one square root plus a few additions and multiplications.
126
+ */
127
+ static sub(a: S1ChordAngle, b: S1ChordAngle): S1ChordAngle;
128
+ /** Returns the smaller of the given instances. */
129
+ static min(a: S1ChordAngle, b: S1ChordAngle): S1ChordAngle;
130
+ /** Returns the larger of the given instances. */
131
+ static max(a: S1ChordAngle, b: S1ChordAngle): S1ChordAngle;
132
+ /** Returns the square of Math.sin(toAngle().radians()), but computed more efficiently. */
133
+ static sin2(a: S1ChordAngle): number;
134
+ /** Returns Math.sin(toAngle().radians()), but computed more efficiently. */
135
+ static sin(a: S1ChordAngle): number;
136
+ /** Returns Math.cos(toAngle().radians()), but computed more efficiently. */
137
+ static cos(a: S1ChordAngle): number;
138
+ /** Returns Math.tan(toAngle().radians()), but computed more efficiently. */
139
+ static tan(a: S1ChordAngle): number;
140
+ /**
141
+ * Returns a new S1ChordAngle that has been adjusted by the given error bound (which can be
142
+ * positive or negative). {@code error} should be the value returned by one of the error bound
143
+ * methods below. For example:
144
+ *
145
+ * <pre>
146
+ * {@code S1ChordAngle a = new S1ChordAngle(x, y);}
147
+ * {@code S1ChordAngle a1 = a.plusError(a.getS2PointConstructorMaxError());}
148
+ * </pre>
149
+ *
150
+ * <p>If this {@link #isSpecial}, we return {@code this}.
151
+ */
152
+ plusError(error: number): S1ChordAngle;
153
+ /** Returns the error in {@link #fromS1Angle}. */
154
+ getS1AngleConstructorMaxError(): number;
155
+ /**
156
+ * There is a relative error of {@code 2.5 * DBL_EPSILON} when computing the squared distance,
157
+ * plus a relative error of {@code 2 * DBL_EPSILON} and an absolute error of {@code 16 *
158
+ * DBL_EPSILON^2} because the lengths of the input points may differ from 1 by up to {@code 2 *
159
+ * DBL_EPSILON} each. (This is the maximum length error in {@link S2Point#normalize}).
160
+ */
161
+ getS2PointConstructorMaxError(): number;
162
+ /** Returns the string of the closest {@link S1Angle} to this chord distance. */
163
+ toString(): string;
164
+ compareTo(that: S1ChordAngle): number;
165
+ equals(that: S1ChordAngle): boolean;
166
+ }