nodes2ts 3.0.0 → 4.0.1
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/LICENSE +21 -0
- package/README.md +102 -15
- package/dist/export.cjs +5350 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +1847 -0
- package/dist/export.d.ts +1837 -20
- package/dist/export.js +5299 -62
- package/dist/export.js.map +1 -1
- package/package.json +34 -55
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -11
- package/.github/workflows/lint.js.yml +0 -22
- package/.github/workflows/node.js.yml +0 -22
- package/.mocharc.js +0 -7
- package/dist/Interval.d.ts +0 -24
- package/dist/Interval.js +0 -23
- package/dist/Interval.js.map +0 -1
- package/dist/MutableInteger.d.ts +0 -4
- package/dist/MutableInteger.js +0 -10
- package/dist/MutableInteger.js.map +0 -1
- package/dist/Platform.d.ts +0 -15
- package/dist/Platform.js +0 -53
- package/dist/Platform.js.map +0 -1
- package/dist/R1Interval.d.ts +0 -76
- package/dist/R1Interval.js +0 -158
- package/dist/R1Interval.js.map +0 -1
- package/dist/R2Vector.d.ts +0 -34
- package/dist/R2Vector.js +0 -131
- package/dist/R2Vector.js.map +0 -1
- package/dist/S1Angle.d.ts +0 -60
- package/dist/S1Angle.js +0 -133
- package/dist/S1Angle.js.map +0 -1
- package/dist/S1ChordAngle.d.ts +0 -166
- package/dist/S1ChordAngle.js +0 -318
- package/dist/S1ChordAngle.js.map +0 -1
- package/dist/S1Interval.d.ts +0 -109
- package/dist/S1Interval.js +0 -398
- package/dist/S1Interval.js.map +0 -1
- package/dist/S2.d.ts +0 -96
- package/dist/S2.js +0 -231
- package/dist/S2.js.map +0 -1
- package/dist/S2Cap.d.ts +0 -122
- package/dist/S2Cap.js +0 -399
- package/dist/S2Cap.js.map +0 -1
- package/dist/S2Cell.d.ts +0 -106
- package/dist/S2Cell.js +0 -358
- package/dist/S2Cell.js.map +0 -1
- package/dist/S2CellId.d.ts +0 -290
- package/dist/S2CellId.js +0 -983
- package/dist/S2CellId.js.map +0 -1
- package/dist/S2CellUnion.d.ts +0 -179
- package/dist/S2CellUnion.js +0 -523
- package/dist/S2CellUnion.js.map +0 -1
- package/dist/S2EdgeUtil.d.ts +0 -17
- package/dist/S2EdgeUtil.js +0 -785
- package/dist/S2EdgeUtil.js.map +0 -1
- package/dist/S2LatLng.d.ts +0 -77
- package/dist/S2LatLng.js +0 -186
- package/dist/S2LatLng.js.map +0 -1
- package/dist/S2LatLngRect.d.ts +0 -190
- package/dist/S2LatLngRect.js +0 -624
- package/dist/S2LatLngRect.js.map +0 -1
- package/dist/S2Metric.d.ts +0 -38
- package/dist/S2Metric.js +0 -79
- package/dist/S2Metric.js.map +0 -1
- package/dist/S2Point.d.ts +0 -78
- package/dist/S2Point.js +0 -250
- package/dist/S2Point.js.map +0 -1
- package/dist/S2Projections.d.ts +0 -102
- package/dist/S2Projections.js +0 -331
- package/dist/S2Projections.js.map +0 -1
- package/dist/S2Region.d.ts +0 -31
- package/dist/S2Region.js +0 -18
- package/dist/S2Region.js.map +0 -1
- package/dist/S2RegionCoverer.d.ts +0 -186
- package/dist/S2RegionCoverer.js +0 -471
- package/dist/S2RegionCoverer.js.map +0 -1
- package/dist/utils/preconditions.d.ts +0 -2
- package/dist/utils/preconditions.js +0 -16
- package/dist/utils/preconditions.js.map +0 -1
package/dist/S2.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S2Metric = exports.S2 = void 0;
|
|
4
|
-
const S2Point_1 = require("./S2Point");
|
|
5
|
-
const S2Metric_1 = require("./S2Metric");
|
|
6
|
-
Object.defineProperty(exports, "S2Metric", { enumerable: true, get: function () { return S2Metric_1.S2Metric; } });
|
|
7
|
-
const Platform_1 = require("./Platform");
|
|
8
|
-
const Long = require("long");
|
|
9
|
-
class S2 {
|
|
10
|
-
static IEEEremainder(f1, f2) {
|
|
11
|
-
return Platform_1.Platform.IEEEremainder(f1, f2);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Return true if the given point is approximately unit length (this is mainly
|
|
15
|
-
* useful for assertions).
|
|
16
|
-
*/
|
|
17
|
-
static isUnitLength(p) {
|
|
18
|
-
return Math.abs(p.norm2() - 1) <= (1e-15);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* If v is non-zero, return an integer {@code exp} such that
|
|
22
|
-
* {@code (0.5 <= |v|*2^(-exp) < 1)}. If v is zero, return 0.
|
|
23
|
-
*
|
|
24
|
-
* <p>Note that this arguably a bad definition of exponent because it makes
|
|
25
|
-
* {@code exp(9) == 4}. In decimal this would be like saying that the
|
|
26
|
-
* exponent of 1234 is 4, when in scientific 'exponent' notation 1234 is
|
|
27
|
-
* {@code 1.234 x 10^3}.
|
|
28
|
-
*
|
|
29
|
-
* TODO(dbeaumont): Replace this with "DoubleUtils.getExponent(v) - 1" ?
|
|
30
|
-
*/
|
|
31
|
-
static exp(v /*double*/) {
|
|
32
|
-
return Platform_1.Platform.getExponent(v);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Return a vector "c" that is orthogonal to the given unit-length vectors "a"
|
|
36
|
-
* and "b". This function is similar to a.CrossProd(b) except that it does a
|
|
37
|
-
* better job of ensuring orthogonality when "a" is nearly parallel to "b",
|
|
38
|
-
* and it returns a non-zero result even when a == b or a == -b.
|
|
39
|
-
*
|
|
40
|
-
* It satisfies the following properties (RCP == RobustCrossProd):
|
|
41
|
-
*
|
|
42
|
-
* (1) RCP(a,b) != 0 for all a, b (2) RCP(b,a) == -RCP(a,b) unless a == b or
|
|
43
|
-
* a == -b (3) RCP(-a,b) == -RCP(a,b) unless a == b or a == -b (4) RCP(a,-b)
|
|
44
|
-
* == -RCP(a,b) unless a == b or a == -b
|
|
45
|
-
*/
|
|
46
|
-
static robustCrossProd(a, b) {
|
|
47
|
-
// The direction of a.CrossProd(b) becomes unstable as (a + b) or (a - b)
|
|
48
|
-
// approaches zero. This leads to situations where a.CrossProd(b) is not
|
|
49
|
-
// very orthogonal to "a" and/or "b". We could fix this using Gram-Schmidt,
|
|
50
|
-
// but we also want b.RobustCrossProd(a) == -b.RobustCrossProd(a).
|
|
51
|
-
//
|
|
52
|
-
// The easiest fix is to just compute the cross product of (b+a) and (b-a).
|
|
53
|
-
// Given that "a" and "b" are unit-length, this has good orthogonality to
|
|
54
|
-
// "a" and "b" even if they differ only in the lowest bit of one component.
|
|
55
|
-
// assert (isUnitLength(a) && isUnitLength(b));
|
|
56
|
-
const x = S2Point_1.S2Point.crossProd(S2Point_1.S2Point.add(b, a), S2Point_1.S2Point.sub(b, a));
|
|
57
|
-
if (!x.equals(new S2Point_1.S2Point(0, 0, 0))) {
|
|
58
|
-
return x;
|
|
59
|
-
}
|
|
60
|
-
// The only result that makes sense mathematically is to return zero, but
|
|
61
|
-
// we find it more convenient to return an arbitrary orthogonal vector.
|
|
62
|
-
return a.ortho();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Return the area of triangle ABC. The method used is about twice as
|
|
66
|
-
* expensive as Girard's formula, but it is numerically stable for both large
|
|
67
|
-
* and very small triangles. The points do not need to be normalized. The area
|
|
68
|
-
* is always positive.
|
|
69
|
-
*
|
|
70
|
-
* The triangle area is undefined if it contains two antipodal points, and
|
|
71
|
-
* becomes numerically unstable as the length of any edge approaches 180
|
|
72
|
-
* degrees.
|
|
73
|
-
*/
|
|
74
|
-
static area(a, b, c) {
|
|
75
|
-
// This method is based on l'Huilier's theorem,
|
|
76
|
-
//
|
|
77
|
-
// tan(E/4) = sqrt(tan(s/2) tan((s-a)/2) tan((s-b)/2) tan((s-c)/2))
|
|
78
|
-
//
|
|
79
|
-
// where E is the spherical excess of the triangle (i.e. its area),
|
|
80
|
-
// a, b, c, are the side lengths, and
|
|
81
|
-
// s is the semiperimeter (a + b + c) / 2 .
|
|
82
|
-
//
|
|
83
|
-
// The only significant source of error using l'Huilier's method is the
|
|
84
|
-
// cancellation error of the terms (s-a), (s-b), (s-c). This leads to a
|
|
85
|
-
// *relative* error of about 1e-16 * s / min(s-a, s-b, s-c). This compares
|
|
86
|
-
// to a relative error of about 1e-15 / E using Girard's formula, where E is
|
|
87
|
-
// the true area of the triangle. Girard's formula can be even worse than
|
|
88
|
-
// this for very small triangles, e.g. a triangle with a true area of 1e-30
|
|
89
|
-
// might evaluate to 1e-5.
|
|
90
|
-
//
|
|
91
|
-
// So, we prefer l'Huilier's formula unless dmin < s * (0.1 * E), where
|
|
92
|
-
// dmin = min(s-a, s-b, s-c). This basically includes all triangles
|
|
93
|
-
// except for extremely long and skinny ones.
|
|
94
|
-
//
|
|
95
|
-
// Since we don't know E, we would like a conservative upper bound on
|
|
96
|
-
// the triangle area in terms of s and dmin. It's possible to show that
|
|
97
|
-
// E <= k1 * s * sqrt(s * dmin), where k1 = 2*sqrt(3)/Pi (about 1).
|
|
98
|
-
// Using this, it's easy to show that we should always use l'Huilier's
|
|
99
|
-
// method if dmin >= k2 * s^5, where k2 is about 1e-2. Furthermore,
|
|
100
|
-
// if dmin < k2 * s^5, the triangle area is at most k3 * s^4, where
|
|
101
|
-
// k3 is about 0.1. Since the best case error using Girard's formula
|
|
102
|
-
// is about 1e-15, this means that we shouldn't even consider it unless
|
|
103
|
-
// s >= 3e-4 or so.
|
|
104
|
-
// We use volatile doubles to force the compiler to truncate all of these
|
|
105
|
-
// quantities to 64 bits. Otherwise it may compute a value of dmin > 0
|
|
106
|
-
// simply because it chose to spill one of the intermediate values to
|
|
107
|
-
// memory but not one of the others.
|
|
108
|
-
const sa = b.angle(c);
|
|
109
|
-
const sb = c.angle(a);
|
|
110
|
-
const sc = a.angle(b);
|
|
111
|
-
const s = sa + (sb) + (sc) * (0.5);
|
|
112
|
-
// 0.5 * (sa + sb + sc);
|
|
113
|
-
if (s >= (3e-4)) {
|
|
114
|
-
// Consider whether Girard's formula might be more accurate.
|
|
115
|
-
const s2 = s * 2;
|
|
116
|
-
const dmin = s - Math.max(sa, sb, sc);
|
|
117
|
-
if (dmin < (s2 * s2 * (s) * (1e-2))) {
|
|
118
|
-
// This triangle is skinny enough to consider Girard's formula.
|
|
119
|
-
const area = S2.girardArea(a, b, c);
|
|
120
|
-
if (dmin < (s * (area * (0.1)))) {
|
|
121
|
-
return area;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Use l'Huilier's formula.
|
|
126
|
-
return 4 * (Math.atan(Math.sqrt(Math.max(0.0, Math.tan(s * (0.5))
|
|
127
|
-
* (Math.tan(s - (sa) * (0.5)))
|
|
128
|
-
* (Math.tan(s - (sb) * (0.5)))
|
|
129
|
-
* (Math.tan(s - (sc) * (0.5)))))));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Return the area of the triangle computed using Girard's formula. This is
|
|
133
|
-
* slightly faster than the Area() method above is not accurate for very small
|
|
134
|
-
* triangles.
|
|
135
|
-
*/
|
|
136
|
-
static girardArea(a, b, c) {
|
|
137
|
-
// This is equivalent to the usual Girard's formula but is slightly
|
|
138
|
-
// more accurate, faster to compute, and handles a == b == c without
|
|
139
|
-
// a special case.
|
|
140
|
-
const ab = S2Point_1.S2Point.crossProd(a, b);
|
|
141
|
-
const bc = S2Point_1.S2Point.crossProd(b, c);
|
|
142
|
-
const ac = S2Point_1.S2Point.crossProd(a, c);
|
|
143
|
-
return Math.max(0, ab.angle(ac) - ab.angle(bc) + bc.angle(ac));
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Return true if the points A, B, C are strictly counterclockwise. Return
|
|
147
|
-
* false if the points are clockwise or colinear (i.e. if they are all
|
|
148
|
-
* contained on some great circle).
|
|
149
|
-
*
|
|
150
|
-
* Due to numerical errors, situations may arise that are mathematically
|
|
151
|
-
* impossible, e.g. ABC may be considered strictly CCW while BCA is not.
|
|
152
|
-
* However, the implementation guarantees the following:
|
|
153
|
-
*
|
|
154
|
-
* If SimpleCCW(a,b,c), then !SimpleCCW(c,b,a) for all a,b,c.
|
|
155
|
-
*
|
|
156
|
-
* In other words, ABC and CBA are guaranteed not to be both CCW
|
|
157
|
-
*/
|
|
158
|
-
static simpleCCW(a, b, c) {
|
|
159
|
-
// We compute the signed volume of the parallelepiped ABC. The usual
|
|
160
|
-
// formula for this is (AxB).C, but we compute it here using (CxA).B
|
|
161
|
-
// in order to ensure that ABC and CBA are not both CCW. This follows
|
|
162
|
-
// from the following identities (which are true numerically, not just
|
|
163
|
-
// mathematically):
|
|
164
|
-
//
|
|
165
|
-
// (1) x.CrossProd(y) == -(y.CrossProd(x))
|
|
166
|
-
// (2) (-x).DotProd(y) == -(x.DotProd(y))
|
|
167
|
-
return S2Point_1.S2Point.crossProd(c, a).dotProd(b) > 0;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
*
|
|
171
|
-
* Return true if edge AB crosses CD at a point that is interior to both
|
|
172
|
-
* edges. Properties:
|
|
173
|
-
*
|
|
174
|
-
* (1) SimpleCrossing(b,a,c,d) == SimpleCrossing(a,b,c,d) (2)
|
|
175
|
-
* SimpleCrossing(c,d,a,b) == SimpleCrossing(a,b,c,d)
|
|
176
|
-
*/
|
|
177
|
-
static simpleCrossing(a, b, c, d) {
|
|
178
|
-
// We compute SimpleCCW() for triangles ACB, CBD, BDA, and DAC. All
|
|
179
|
-
// of these triangles need to have the same orientation (CW or CCW)
|
|
180
|
-
// for an intersection to exist. Note that this is slightly more
|
|
181
|
-
// restrictive than the corresponding definition for planar edges,
|
|
182
|
-
// since we need to exclude pairs of line segments that would
|
|
183
|
-
// otherwise "intersect" by crossing two antipodal points.
|
|
184
|
-
const ab = S2Point_1.S2Point.crossProd(a, b);
|
|
185
|
-
const cd = S2Point_1.S2Point.crossProd(c, d);
|
|
186
|
-
const acb = ab.dotProd(c) * -1;
|
|
187
|
-
const cbd = cd.dotProd(b) * -1;
|
|
188
|
-
const bda = ab.dotProd(d);
|
|
189
|
-
const dac = cd.dotProd(a);
|
|
190
|
-
return (acb * (cbd) > (0)) && (cbd * (bda) > (0)) && (bda * (dac) > (0));
|
|
191
|
-
}
|
|
192
|
-
static approxEqualsPointError(a, b, maxError) {
|
|
193
|
-
return a.angle(b) <= maxError;
|
|
194
|
-
}
|
|
195
|
-
static approxEqualsPoint(a, b) {
|
|
196
|
-
return this.approxEqualsPointError(a, b, 1e-15);
|
|
197
|
-
}
|
|
198
|
-
static approxEqualsNumberError(a, b, maxError) {
|
|
199
|
-
return Math.abs(a - b) <= maxError;
|
|
200
|
-
}
|
|
201
|
-
static approxEqualsNumber(a, b) {
|
|
202
|
-
return this.approxEqualsNumberError(a, b, 1e-15);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
exports.S2 = S2;
|
|
206
|
-
S2.M_PI = Math.PI;
|
|
207
|
-
S2.M_1_PI = 1.0 / Math.PI;
|
|
208
|
-
S2.M_PI_2 = Math.PI / 2.0;
|
|
209
|
-
S2.M_PI_4 = Math.PI / 4.0;
|
|
210
|
-
S2.M_SQRT2 = Math.sqrt(2);
|
|
211
|
-
S2.M_E = Math.E;
|
|
212
|
-
// the axis directions are reversed).
|
|
213
|
-
S2.SWAP_MASK = 0x01;
|
|
214
|
-
S2.INVERT_MASK = 0x02;
|
|
215
|
-
// Number of bits in the mantissa of a double.
|
|
216
|
-
S2.EXPONENT_SHIFT = 52;
|
|
217
|
-
// Mask to extract the exponent from a double.
|
|
218
|
-
S2.EXPONENT_MASK = Long.fromString('0x7ff0000000000000', true, 16);
|
|
219
|
-
/** Mapping from cell orientation + Hilbert traversal to IJ-index. */
|
|
220
|
-
S2.POS_TO_ORIENTATION = [S2.SWAP_MASK, 0, 0, S2.INVERT_MASK + S2.SWAP_MASK];
|
|
221
|
-
S2.DBL_EPSILON = 2 * Number.EPSILON;
|
|
222
|
-
S2.POS_TO_IJ = [
|
|
223
|
-
// 0 1 2 3
|
|
224
|
-
[0, 1, 3, 2],
|
|
225
|
-
[0, 2, 3, 1],
|
|
226
|
-
[3, 2, 0, 1],
|
|
227
|
-
[3, 1, 0, 2], // swapped & inverted: (1,1), (0,1), (0,0), (1,0)
|
|
228
|
-
];
|
|
229
|
-
S2.MAX_LEVEL = 30;
|
|
230
|
-
S2.Metric = S2Metric_1.S2Metric;
|
|
231
|
-
//# sourceMappingURL=S2.js.map
|
package/dist/S2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2.js","sourceRoot":"","sources":["../src/S2.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,yCAAoC;AA2Q3B,yFA3QD,mBAAQ,OA2QC;AA1QjB,yCAAsC;AAEtC,6BAA8B;AAG9B,MAAa,EAAE;IA6BN,MAAM,CAAC,aAAa,CAAC,EAAS,EAAE,EAAS;QAC9C,OAAO,mBAAQ,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,CAAS;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,GAAG,CAAC,CAAQ,CAAC,UAAU;QAC5B,OAAO,mBAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,eAAe,CAAC,CAAS,EAAE,CAAS;QACzC,yEAAyE;QACzE,wEAAwE;QACxE,2EAA2E;QAC3E,kEAAkE;QAClE,EAAE;QACF,2EAA2E;QAC3E,yEAAyE;QACzE,2EAA2E;QAE3E,+CAA+C;QAC/C,MAAM,CAAC,GAAG,iBAAO,CAAC,SAAS,CAAC,iBAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC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EjC,8CAA8C;AAC/B,iBAAc,GAAG,EAAE,CAAC;AACnC,8CAA8C;AAC/B,gBAAa,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/E,qEAAqE;AACvD,qBAAkB,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACzE,cAAW,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;AAEjC,YAAS,GAAG;IACxB,UAAU;IACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,iDAAiD;CAChE,CAAC;AACK,YAAS,GAAG,EAAE,CAAC;AAuOf,SAAM,GAAG,mBAAQ,CAAA"}
|
package/dist/S2Cap.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { S2Region } from "./S2Region";
|
|
2
|
-
import { S2Point } from "./S2Point";
|
|
3
|
-
import { S1Angle } from "./S1Angle";
|
|
4
|
-
import { S2LatLngRect } from "./S2LatLngRect";
|
|
5
|
-
import { S2Cell } from "./S2Cell";
|
|
6
|
-
import { S1ChordAngle } from "./S1ChordAngle";
|
|
7
|
-
/**
|
|
8
|
-
* This class represents a spherical cap, i.e. a portion of a sphere cut off by
|
|
9
|
-
* a plane. The cap is defined by its axis and height. This representation has
|
|
10
|
-
* good numerical accuracy for very small caps (unlike the (axis,
|
|
11
|
-
* min-distance-from-origin) representation), and is also efficient for
|
|
12
|
-
* containment tests (unlike the (axis, angle) representation).
|
|
13
|
-
*
|
|
14
|
-
* Here are some useful relationships between the cap height (h), the cap
|
|
15
|
-
* opening angle (theta), the maximum chord length from the cap's center (d),
|
|
16
|
-
* and the radius of cap's base (a). All formulas assume a unit radius.
|
|
17
|
-
*
|
|
18
|
-
* h = 1 - cos(theta) = 2 sin^2(theta/2) d^2 = 2 h = a^2 + h^2
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export declare class S2Cap implements S2Region {
|
|
22
|
-
/**
|
|
23
|
-
* Multiply a positive number by this constant to ensure that the result of a
|
|
24
|
-
* floating point operation is at least as large as the true
|
|
25
|
-
* infinite-precision result.
|
|
26
|
-
*/
|
|
27
|
-
private static ROUND_UP;
|
|
28
|
-
axis: S2Point;
|
|
29
|
-
radius: S1ChordAngle;
|
|
30
|
-
/**
|
|
31
|
-
* Create a cap given its axis and the cap height, i.e. the maximum projected
|
|
32
|
-
* distance along the cap axis from the cap center. 'axis' should be a
|
|
33
|
-
* unit-length vector.
|
|
34
|
-
*/
|
|
35
|
-
constructor(axis: S2Point, radius: S1ChordAngle);
|
|
36
|
-
static fromAxisChord(center: S2Point, radius: S1ChordAngle): S2Cap;
|
|
37
|
-
/**
|
|
38
|
-
* Create a cap given its axis and the cap height, i.e. the maximum projected distance along the
|
|
39
|
-
* cap axis from the cap center. 'axis' should be a unit-length vector.
|
|
40
|
-
*/
|
|
41
|
-
static fromAxisHeight(axis: S2Point, height: number): S2Cap;
|
|
42
|
-
/**
|
|
43
|
-
* Create a cap given its axis and the cap opening angle, i.e. maximum angle
|
|
44
|
-
* between the axis and a point on the cap. 'axis' should be a unit-length
|
|
45
|
-
* vector, and 'angle' should be between 0 and 180 degrees.
|
|
46
|
-
*/
|
|
47
|
-
static fromAxisAngle(axis: S2Point, angle: S1Angle): S2Cap;
|
|
48
|
-
/**
|
|
49
|
-
* Create a cap given its axis and its area in steradians. 'axis' should be a unit-length vector,
|
|
50
|
-
* and 'area' should be between 0 and 4 * M_PI.
|
|
51
|
-
*/
|
|
52
|
-
static fromAxisArea(axis: S2Point, area: number): S2Cap;
|
|
53
|
-
/** Return an empty cap, i.e. a cap that contains no points. */
|
|
54
|
-
static empty(): S2Cap;
|
|
55
|
-
/** Return a full cap, i.e. a cap that contains all points. */
|
|
56
|
-
static full(): S2Cap;
|
|
57
|
-
getCapBound(): S2Cap;
|
|
58
|
-
height(): number;
|
|
59
|
-
area(): number;
|
|
60
|
-
/**
|
|
61
|
-
* Returns the cap radius as an S1Angle. Since the cap angle is stored internally as an
|
|
62
|
-
* S1ChordAngle, this method requires a trigonometric operation and may yield a slightly different
|
|
63
|
-
* result than the value passed to {@link #fromAxisAngle(S2Point, S1Angle)}.
|
|
64
|
-
*/
|
|
65
|
-
angle(): S1Angle;
|
|
66
|
-
/**
|
|
67
|
-
* Returns true if the axis is {@link S2#isUnitLength unit length}, and the angle is less than Pi.
|
|
68
|
-
*
|
|
69
|
-
* <p>Negative angles or heights are valid, and represent empty caps.
|
|
70
|
-
*/
|
|
71
|
-
isValid(): boolean;
|
|
72
|
-
/** Return true if the cap is empty, i.e. it contains no points. */
|
|
73
|
-
isEmpty(): boolean;
|
|
74
|
-
/** Return true if the cap is full, i.e. it contains all points. */
|
|
75
|
-
isFull(): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Return the complement of the interior of the cap. A cap and its complement have the same
|
|
78
|
-
* boundary but do not share any interior points. The complement operator is not a bijection,
|
|
79
|
-
* since the complement of a singleton cap (containing a single point) is the same as the
|
|
80
|
-
* complement of an empty cap.
|
|
81
|
-
*/
|
|
82
|
-
complement(): S2Cap;
|
|
83
|
-
/**
|
|
84
|
-
* Return true if and only if this cap contains the given other cap (in a set
|
|
85
|
-
* containment sense, e.g. every cap contains the empty cap).
|
|
86
|
-
*/
|
|
87
|
-
containsCap(other: S2Cap): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Return true if and only if the interior of this cap intersects the given other cap. (This
|
|
90
|
-
* relationship is not symmetric, since only the interior of this cap is used.)
|
|
91
|
-
*/
|
|
92
|
-
interiorIntersects(other: S2Cap): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Return true if and only if the given point is contained in the interior of the region (i.e. the
|
|
95
|
-
* region excluding its boundary). 'p' should be a unit-length vector.
|
|
96
|
-
*/
|
|
97
|
-
interiorContains(p: S2Point): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Increase the cap radius if necessary to include the given point. If the cap is empty the axis
|
|
100
|
-
* is set to the given point, but otherwise it is left unchanged.
|
|
101
|
-
*
|
|
102
|
-
* @param p must be {@link S2#isUnitLength unit length}
|
|
103
|
-
*/
|
|
104
|
-
addPoint(p: S2Point): S2Cap;
|
|
105
|
-
addCap(other: S2Cap): S2Cap;
|
|
106
|
-
getRectBound(): S2LatLngRect;
|
|
107
|
-
mayIntersectC(cell: S2Cell): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Return true if the cap intersects 'cell', given that the cap vertices have
|
|
110
|
-
* alrady been checked.
|
|
111
|
-
*/
|
|
112
|
-
intersects(cell: S2Cell, vertices: S2Point[]): boolean;
|
|
113
|
-
contains(p: S2Point): boolean;
|
|
114
|
-
containsC(cell: S2Cell): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Return true if the cap axis and height differ by at most "max_error" from
|
|
117
|
-
* the given cap "other".
|
|
118
|
-
*/
|
|
119
|
-
approxEquals(other: S2Cap, maxError?: number): boolean;
|
|
120
|
-
toString(): string;
|
|
121
|
-
toGEOJSON(): any;
|
|
122
|
-
}
|