@ac-kit/math-map-projection 0.0.0-stage → 0.2.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.
- package/CHANGELOG.md +126 -0
- package/LICENSE +28 -0
- package/README.md +126 -2
- package/dist/_array-length.d.ts +7 -0
- package/dist/_array-length.d.ts.map +1 -0
- package/dist/_array-length.js +13 -0
- package/dist/_array-length.js.map +1 -0
- package/dist/_isometric.d.ts +8 -0
- package/dist/_isometric.d.ts.map +1 -0
- package/dist/_isometric.js +19 -0
- package/dist/_isometric.js.map +1 -0
- package/dist/azimuthal/azimuthal-equal-area.d.ts +55 -0
- package/dist/azimuthal/azimuthal-equal-area.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-equal-area.js +155 -0
- package/dist/azimuthal/azimuthal-equal-area.js.map +1 -0
- package/dist/azimuthal/azimuthal-equidistant.d.ts +55 -0
- package/dist/azimuthal/azimuthal-equidistant.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-equidistant.js +164 -0
- package/dist/azimuthal/azimuthal-equidistant.js.map +1 -0
- package/dist/azimuthal/azimuthal-projection-kind.d.ts +28 -0
- package/dist/azimuthal/azimuthal-projection-kind.d.ts.map +1 -0
- package/dist/azimuthal/azimuthal-projection-kind.js +70 -0
- package/dist/azimuthal/azimuthal-projection-kind.js.map +1 -0
- package/dist/azimuthal/gnomonic.d.ts +61 -0
- package/dist/azimuthal/gnomonic.d.ts.map +1 -0
- package/dist/azimuthal/gnomonic.js +140 -0
- package/dist/azimuthal/gnomonic.js.map +1 -0
- package/dist/azimuthal/index.d.ts +7 -0
- package/dist/azimuthal/index.d.ts.map +1 -0
- package/dist/azimuthal/index.js +7 -0
- package/dist/azimuthal/index.js.map +1 -0
- package/dist/azimuthal/orthographic.d.ts +59 -0
- package/dist/azimuthal/orthographic.d.ts.map +1 -0
- package/dist/azimuthal/orthographic.js +145 -0
- package/dist/azimuthal/orthographic.js.map +1 -0
- package/dist/azimuthal/stereographic.d.ts +59 -0
- package/dist/azimuthal/stereographic.d.ts.map +1 -0
- package/dist/azimuthal/stereographic.js +168 -0
- package/dist/azimuthal/stereographic.js.map +1 -0
- package/dist/conic/_conic.d.ts +55 -0
- package/dist/conic/_conic.d.ts.map +1 -0
- package/dist/conic/_conic.js +68 -0
- package/dist/conic/_conic.js.map +1 -0
- package/dist/conic/conic-conformal.d.ts +52 -0
- package/dist/conic/conic-conformal.d.ts.map +1 -0
- package/dist/conic/conic-conformal.js +144 -0
- package/dist/conic/conic-conformal.js.map +1 -0
- package/dist/conic/conic-equal-area.d.ts +55 -0
- package/dist/conic/conic-equal-area.d.ts.map +1 -0
- package/dist/conic/conic-equal-area.js +122 -0
- package/dist/conic/conic-equal-area.js.map +1 -0
- package/dist/conic/conic-equidistant.d.ts +50 -0
- package/dist/conic/conic-equidistant.d.ts.map +1 -0
- package/dist/conic/conic-equidistant.js +113 -0
- package/dist/conic/conic-equidistant.js.map +1 -0
- package/dist/conic/index.d.ts +5 -0
- package/dist/conic/index.d.ts.map +1 -0
- package/dist/conic/index.js +4 -0
- package/dist/conic/index.js.map +1 -0
- package/dist/cylindrical/equirectangular.d.ts +37 -0
- package/dist/cylindrical/equirectangular.d.ts.map +1 -0
- package/dist/cylindrical/equirectangular.js +67 -0
- package/dist/cylindrical/equirectangular.js.map +1 -0
- package/dist/cylindrical/index.d.ts +4 -0
- package/dist/cylindrical/index.d.ts.map +1 -0
- package/dist/cylindrical/index.js +4 -0
- package/dist/cylindrical/index.js.map +1 -0
- package/dist/cylindrical/mercator.d.ts +38 -0
- package/dist/cylindrical/mercator.d.ts.map +1 -0
- package/dist/cylindrical/mercator.js +67 -0
- package/dist/cylindrical/mercator.js.map +1 -0
- package/dist/cylindrical/transverse-mercator.d.ts +32 -0
- package/dist/cylindrical/transverse-mercator.d.ts.map +1 -0
- package/dist/cylindrical/transverse-mercator.js +103 -0
- package/dist/cylindrical/transverse-mercator.js.map +1 -0
- package/dist/geometry/_cut-antimeridian.d.ts +24 -0
- package/dist/geometry/_cut-antimeridian.d.ts.map +1 -0
- package/dist/geometry/_cut-antimeridian.js +204 -0
- package/dist/geometry/_cut-antimeridian.js.map +1 -0
- package/dist/geometry/_cut-cap.d.ts +29 -0
- package/dist/geometry/_cut-cap.d.ts.map +1 -0
- package/dist/geometry/_cut-cap.js +258 -0
- package/dist/geometry/_cut-cap.js.map +1 -0
- package/dist/geometry/_path.d.ts +36 -0
- package/dist/geometry/_path.d.ts.map +1 -0
- package/dist/geometry/_path.js +57 -0
- package/dist/geometry/_path.js.map +1 -0
- package/dist/geometry/_resample.d.ts +21 -0
- package/dist/geometry/_resample.d.ts.map +1 -0
- package/dist/geometry/_resample.js +190 -0
- package/dist/geometry/_resample.js.map +1 -0
- package/dist/geometry/graticule.d.ts +30 -0
- package/dist/geometry/graticule.d.ts.map +1 -0
- package/dist/geometry/graticule.js +78 -0
- package/dist/geometry/graticule.js.map +1 -0
- package/dist/geometry/index.d.ts +4 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/geometry/index.js +4 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/project-geometry.d.ts +86 -0
- package/dist/geometry/project-geometry.d.ts.map +1 -0
- package/dist/geometry/project-geometry.js +269 -0
- package/dist/geometry/project-geometry.js.map +1 -0
- package/dist/geometry/vertex-runs.d.ts +37 -0
- package/dist/geometry/vertex-runs.d.ts.map +1 -0
- package/dist/geometry/vertex-runs.js +61 -0
- package/dist/geometry/vertex-runs.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/projection.d.ts +116 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +408 -0
- package/dist/projection.js.map +1 -0
- package/dist/pseudo-cylindrical/equal-earth.d.ts +28 -0
- package/dist/pseudo-cylindrical/equal-earth.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/equal-earth.js +124 -0
- package/dist/pseudo-cylindrical/equal-earth.js.map +1 -0
- package/dist/pseudo-cylindrical/index.d.ts +3 -0
- package/dist/pseudo-cylindrical/index.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/index.js +3 -0
- package/dist/pseudo-cylindrical/index.js.map +1 -0
- package/dist/pseudo-cylindrical/natural-earth.d.ts +28 -0
- package/dist/pseudo-cylindrical/natural-earth.d.ts.map +1 -0
- package/dist/pseudo-cylindrical/natural-earth.js +118 -0
- package/dist/pseudo-cylindrical/natural-earth.js.map +1 -0
- package/package.json +70 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# @ac-kit/math-map-projection
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0b4fe43: `projectionCreate` builds `transverse-mercator`, the spherical transverse
|
|
8
|
+
Mercator (as d3-geo's `geoTransverseMercator`; `rotate: [−λ₀, 0]` puts the
|
|
9
|
+
central meridian on `λ₀`), and the geometry functions cut its lines and
|
|
10
|
+
polygons at its own seam, the far half of the equator. The dedicated
|
|
11
|
+
`transverseMercatorProject`, `…Unproject`, `…ProjectArray` and
|
|
12
|
+
`…UnprojectArray` (Snyder §8) map longitude–latitude pairs centred on longitude
|
|
13
|
+
0, with x evaluated through `asinh` so that it stays finite and accurate up to
|
|
14
|
+
the two singular points (`(π/2, 10⁻⁹)` gives 21.4164, not ∞). `projectionCreate` throws `UnsupportedError` from `@ac-kit/core` for the one
|
|
15
|
+
kind of `ProjectionKind` still without an implementation, the composite
|
|
16
|
+
`albers-usa`, and a `RangeError` only for an unknown kind (it threw a
|
|
17
|
+
`RangeError` for both).
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [0b4fe43]
|
|
22
|
+
- Updated dependencies [0b4fe43]
|
|
23
|
+
- Updated dependencies [0b4fe43]
|
|
24
|
+
- Updated dependencies [0b4fe43]
|
|
25
|
+
- Updated dependencies [0b4fe43]
|
|
26
|
+
- Updated dependencies [0b4fe43]
|
|
27
|
+
- Updated dependencies [0b4fe43]
|
|
28
|
+
- Updated dependencies [0b4fe43]
|
|
29
|
+
- Updated dependencies [0b4fe43]
|
|
30
|
+
- Updated dependencies [0b4fe43]
|
|
31
|
+
- Updated dependencies [0b4fe43]
|
|
32
|
+
- Updated dependencies [0b4fe43]
|
|
33
|
+
- Updated dependencies [0b4fe43]
|
|
34
|
+
- Updated dependencies [0b4fe43]
|
|
35
|
+
- Updated dependencies [0b4fe43]
|
|
36
|
+
- Updated dependencies [0b4fe43]
|
|
37
|
+
- Updated dependencies [0b4fe43]
|
|
38
|
+
- Updated dependencies [0b4fe43]
|
|
39
|
+
- Updated dependencies [0b4fe43]
|
|
40
|
+
- Updated dependencies [0b4fe43]
|
|
41
|
+
- Updated dependencies [0b4fe43]
|
|
42
|
+
- Updated dependencies [0b4fe43]
|
|
43
|
+
- Updated dependencies [0b4fe43]
|
|
44
|
+
- Updated dependencies [0b4fe43]
|
|
45
|
+
- Updated dependencies [0b4fe43]
|
|
46
|
+
- Updated dependencies [0b4fe43]
|
|
47
|
+
- Updated dependencies [0b4fe43]
|
|
48
|
+
- Updated dependencies [0b4fe43]
|
|
49
|
+
- Updated dependencies [0b4fe43]
|
|
50
|
+
- Updated dependencies [0b4fe43]
|
|
51
|
+
- Updated dependencies [0b4fe43]
|
|
52
|
+
- Updated dependencies [0b4fe43]
|
|
53
|
+
- Updated dependencies [0b4fe43]
|
|
54
|
+
- Updated dependencies [0b4fe43]
|
|
55
|
+
- Updated dependencies [0b4fe43]
|
|
56
|
+
- @ac-kit/core@0.13.0
|
|
57
|
+
- @ac-kit/math-geometry@0.4.0
|
|
58
|
+
- @ac-kit/math-linear@0.4.0
|
|
59
|
+
- @ac-kit/math-scalar@0.4.0
|
|
60
|
+
|
|
61
|
+
## 0.1.0
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- 34e8cfa: First release: point maps between the sphere and the plane, for maps and sky
|
|
66
|
+
charts. The five azimuthal projections (`stereographic…`, `orthographic…`,
|
|
67
|
+
`gnomonic…`, `azimuthalEquidistant…`, `azimuthalEqualArea…`) take unit vectors
|
|
68
|
+
and give plane points (`…Project`, `…Unproject`, `…Radius`, `…Angle`,
|
|
69
|
+
`…_DOMAIN_ANGLE`), their array forms fusing a view rotation in one pass
|
|
70
|
+
(120 000 stars in about 0.16 ms); `AzimuthalProjectionKind` with
|
|
71
|
+
`azimuthalRadius`, `azimuthalAngle` and `azimuthalDomainAngle` picks one from
|
|
72
|
+
data. Equirectangular, Mercator, Equal Earth, Natural Earth and the Albers,
|
|
73
|
+
Lambert conformal and equidistant cones (`conic…Create` once, then the same four
|
|
74
|
+
functions) take longitude and latitude in radians. `projectionCreate(spec)`
|
|
75
|
+
builds a closure from a `model-chart` `ProjectionSpec` (rotation, parallels,
|
|
76
|
+
centre), and `projectionPolygonProject`, `projectionPolylineProject`,
|
|
77
|
+
`projectionGraticule` and `projectionOutline` cut lines and polygons at the
|
|
78
|
+
antimeridian or the clip circle, close them along the cut and sample them until
|
|
79
|
+
they are straight (an arc over a pole runs up one meridian and down the other,
|
|
80
|
+
breaking where the pole has no image); a result or graticule holds at most
|
|
81
|
+
`PROJECTION_MAXIMUM_VERTICES` (`2²⁴`) vertices, more throwing `RangeError`
|
|
82
|
+
before any is allocated. `projectionCreate` rejects a latitude (`center[1]`,
|
|
83
|
+
`rotate[1]`, `parallels`) outside `[−90, 90]` and a `center` longitude outside
|
|
84
|
+
`[−180, 180]` rather than fold it. A point outside a projection's domain gives
|
|
85
|
+
`NaN`, never a throw; the sphere has radius 1, x is east and y north.
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [34e8cfa]
|
|
90
|
+
- Updated dependencies [34e8cfa]
|
|
91
|
+
- Updated dependencies [34e8cfa]
|
|
92
|
+
- Updated dependencies [34e8cfa]
|
|
93
|
+
- Updated dependencies [34e8cfa]
|
|
94
|
+
- Updated dependencies [34e8cfa]
|
|
95
|
+
- Updated dependencies [34e8cfa]
|
|
96
|
+
- Updated dependencies [34e8cfa]
|
|
97
|
+
- Updated dependencies [34e8cfa]
|
|
98
|
+
- Updated dependencies [34e8cfa]
|
|
99
|
+
- Updated dependencies [34e8cfa]
|
|
100
|
+
- Updated dependencies [34e8cfa]
|
|
101
|
+
- Updated dependencies [34e8cfa]
|
|
102
|
+
- Updated dependencies [34e8cfa]
|
|
103
|
+
- Updated dependencies [34e8cfa]
|
|
104
|
+
- Updated dependencies [34e8cfa]
|
|
105
|
+
- Updated dependencies [34e8cfa]
|
|
106
|
+
- Updated dependencies [34e8cfa]
|
|
107
|
+
- Updated dependencies [34e8cfa]
|
|
108
|
+
- Updated dependencies [34e8cfa]
|
|
109
|
+
- Updated dependencies [34e8cfa]
|
|
110
|
+
- Updated dependencies [34e8cfa]
|
|
111
|
+
- Updated dependencies [34e8cfa]
|
|
112
|
+
- Updated dependencies [34e8cfa]
|
|
113
|
+
- Updated dependencies [34e8cfa]
|
|
114
|
+
- Updated dependencies [34e8cfa]
|
|
115
|
+
- Updated dependencies [34e8cfa]
|
|
116
|
+
- Updated dependencies [34e8cfa]
|
|
117
|
+
- Updated dependencies [34e8cfa]
|
|
118
|
+
- Updated dependencies [34e8cfa]
|
|
119
|
+
- Updated dependencies [34e8cfa]
|
|
120
|
+
- Updated dependencies [34e8cfa]
|
|
121
|
+
- Updated dependencies [34e8cfa]
|
|
122
|
+
- Updated dependencies [34e8cfa]
|
|
123
|
+
- @ac-kit/core@0.12.0
|
|
124
|
+
- @ac-kit/math-scalar@0.3.0
|
|
125
|
+
- @ac-kit/math-linear@0.3.0
|
|
126
|
+
- @ac-kit/math-geometry@0.3.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ac-kit/math-map-projection
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Point maps between the sphere and the plane — map and sky projections, and the
|
|
4
|
+
cutting, resampling and graticules a map needs; styling and GeoJSON path
|
|
5
|
+
building are not here. Earth or sky: a star chart is a map of the celestial
|
|
6
|
+
sphere, and `stereographicProjectArray` projects 120 000 stars in about
|
|
7
|
+
0.16 ms.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import {
|
|
11
|
+
projectionCreate,
|
|
12
|
+
projectionGraticule,
|
|
13
|
+
projectionPolygonProject,
|
|
14
|
+
stereographicProject,
|
|
15
|
+
vertexRunsFromArrays,
|
|
16
|
+
} from "@ac-kit/math-map-projection";
|
|
17
|
+
import { longitudeLatitudeOf } from "@ac-kit/math-geometry";
|
|
18
|
+
import { vec2Create, vec3Of } from "@ac-kit/math-linear";
|
|
19
|
+
|
|
20
|
+
// One point: a unit vector, the centre on +X, plane x east (+Y), y north (+Z).
|
|
21
|
+
const point = stereographicProject(vec2Create(), vec3Of(0.6, 0.64, 0.48));
|
|
22
|
+
|
|
23
|
+
// A map from data, as `model-chart`'s ProjectionSpec describes it (degrees).
|
|
24
|
+
const projection = projectionCreate({
|
|
25
|
+
kind: "orthographic",
|
|
26
|
+
rotate: [-2.35, -48.85], // centred on Paris
|
|
27
|
+
});
|
|
28
|
+
projection.project(vec2Create(), longitudeLatitudeOf(0.1, 0.8)); // radians in
|
|
29
|
+
|
|
30
|
+
// Polygons and lines come out cut at the horizon (or at the antimeridian).
|
|
31
|
+
const rings = projectionPolygonProject(
|
|
32
|
+
projection,
|
|
33
|
+
vertexRunsFromArrays([[0, 0.8, 0.2, 0.8, 0.1, 1]]), // longitude, latitude
|
|
34
|
+
);
|
|
35
|
+
const lines = projectionGraticule(projection);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Conventions
|
|
39
|
+
|
|
40
|
+
- **Radians in, plane units out.** The sphere has radius 1. A view is a
|
|
41
|
+
`Mat3x3` that rotates the sphere first and an `Affine2` that scales and flips
|
|
42
|
+
after (the plane's y is north; a screen's is down); single-value functions
|
|
43
|
+
hold neither.
|
|
44
|
+
- **The canonical frame.** The projection centre is longitude 0, latitude 0
|
|
45
|
+
(`+X`); plane x is east (`+Y`) and y north (`+Z`). The azimuthal functions
|
|
46
|
+
take unit vectors, the others longitude–latitude pairs.
|
|
47
|
+
- **Domains give `NaN`.** The antipode of a stereographic view, the far side of
|
|
48
|
+
an orthographic one, the horizon of a gnomonic one; a latitude beyond the
|
|
49
|
+
poles; `NaN` in, `NaN` out; never a throw (a creator of a parameter record, or
|
|
50
|
+
a bulk length mismatch, throws `RangeError`). The poles of Mercator are
|
|
51
|
+
`±∞`; the transverse Mercator's two singular points are not doubles, so its
|
|
52
|
+
x stays finite and accurate up to them (±38.03 at `(±Math.PI / 2, 0)`).
|
|
53
|
+
- **Huge and tiny scales hold.** An inverse of a point at `1e300` or `1e-300`
|
|
54
|
+
gives a unit vector, not `NaN` or a zero (the scale is kept in range).
|
|
55
|
+
- **One container type per parameter** (a `Vec2`, a `Float64Array`), as in
|
|
56
|
+
`@ac-kit/math-linear`.
|
|
57
|
+
|
|
58
|
+
## Contents
|
|
59
|
+
|
|
60
|
+
| Symbol | Description |
|
|
61
|
+
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| `stereographic…`, `orthographic…`, `gnomonic…`, `azimuthalEquidistant…`, `azimuthalEqualArea…` (`Project`, `Unproject`, `ProjectArray`, `UnprojectArray`, `Radius`, `Angle`, `…_DOMAIN_ANGLE`) | The five azimuthal projections of unit vectors; the array forms fuse a view rotation (one pass) |
|
|
63
|
+
| `AzimuthalProjectionKind`, `azimuthalRadius`, `azimuthalAngle`, `azimuthalDomainAngle` | The same by name, for a chart that picks its projection from data |
|
|
64
|
+
| `equirectangular…`, `mercator…`, `transverseMercator…`, `equalEarth…`, `naturalEarth…` (`Project`, `Unproject`, `ProjectArray`, `UnprojectArray`) | Longitude–latitude projections (the transverse Mercator on the sphere); in-place arrays |
|
|
65
|
+
| `conicEqualAreaCreate`, `conicConformalCreate`, `conicEquidistantCreate`, `ALBERS_PARALLELS`, `conic…Project`, `…Unproject`, `…Array` | The conics: constants computed once into a `ConicProjection`, then the same four functions |
|
|
66
|
+
| `projectionCreate(spec, options?)` | A closure from a `ProjectionSpec` (rotation, parallels, centre) with `project`, `unproject` and their array forms |
|
|
67
|
+
| `projectionPolylineProject`, `projectionPolygonProject` | Lines and polygons cut at the antimeridian or the clip circle, then sampled until straight |
|
|
68
|
+
| `graticuleCreate`, `projectionGraticule`, `projectionOutline` | The graticule and the outline of a map |
|
|
69
|
+
| `VertexRuns`, `vertexRunsFromArrays`, `PROJECTION_MAXIMUM_VERTICES` | The packed layout of lines and rings, and the most vertices a result holds |
|
|
70
|
+
|
|
71
|
+
Which projection for what: the **stereographic** keeps angles and turns circles
|
|
72
|
+
into circles (sky charts, polar maps); the **orthographic** is the globe seen
|
|
73
|
+
from far away; the **gnomonic** turns great circles into lines (navigation);
|
|
74
|
+
the **azimuthal equidistant** keeps distances from the centre; the
|
|
75
|
+
**azimuthal equal-area**, **Albers** (`conicEqualArea`), and **Equal Earth** keep
|
|
76
|
+
areas; **Mercator** and the **Lambert conformal conic** keep angles;
|
|
77
|
+
**equirectangular** and **Natural Earth** compromise.
|
|
78
|
+
|
|
79
|
+
## Cutting, resampling, graticules
|
|
80
|
+
|
|
81
|
+
`projectionPolygonProject` and `projectionPolylineProject` take the packed
|
|
82
|
+
longitude–latitude runs (`VertexRuns`; edges are great-circle arcs) and give
|
|
83
|
+
plane runs. A polyline is cut where the map tears (the antimeridian of the
|
|
84
|
+
rotated sphere for a longitude–latitude projection, the clip circle of an
|
|
85
|
+
azimuthal one; `ProjectionOptions.clipAngle`), and each arc is sampled until
|
|
86
|
+
its midpoint is within `tolerance` of its chord. A polygon (first ring the
|
|
87
|
+
exterior, interior on the left, so counter-clockwise outside, clockwise holes —
|
|
88
|
+
RFC 7946) is closed along the cut, through a pole's edge where it encloses a
|
|
89
|
+
pole, and its rings are for a non-zero winding fill. An arc over a pole runs up
|
|
90
|
+
one meridian and down the other; points a projection cannot map (Mercator's
|
|
91
|
+
poles) are dropped, a line breaking there. A result, like a graticule, holds at
|
|
92
|
+
most `PROJECTION_MAXIMUM_VERTICES` (`2²⁴`) vertices: settings that would sample
|
|
93
|
+
more throw `RangeError` before allocating them. No styling and no GeoJSON path
|
|
94
|
+
building: that is a map renderer's.
|
|
95
|
+
|
|
96
|
+
## Accuracy
|
|
97
|
+
|
|
98
|
+
Measured on the unit sphere, over 20 000 seeded points each:
|
|
99
|
+
|
|
100
|
+
- Against `d3-geo`'s raw projections (dev oracle, a pinned `devDependency`):
|
|
101
|
+
the five azimuthal, Mercator, Equal Earth and Natural Earth agree within
|
|
102
|
+
`2e−15` (relative to `max(1, |value|)`); the three conics within `9e−15`.
|
|
103
|
+
Against `proj4` (also a dev oracle): the three conics within `8e−15`, Equal
|
|
104
|
+
Earth within `1e−9` (its published constants are six digits).
|
|
105
|
+
`projectionCreate` matches `d3-geo`'s projections, rotation (three angles),
|
|
106
|
+
centre and parallels included, within `1e−9`.
|
|
107
|
+
- Round trips: azimuthal within `2e−12` of the unit vector, the others within
|
|
108
|
+
`1e−11` radians (Equal Earth's Newton solve), conics within `5e−9` at the far
|
|
109
|
+
parallels.
|
|
110
|
+
- Properties: equal-area maps have an area element of `cos φ`, conformal maps
|
|
111
|
+
have orthogonal, equal-scale directions, the equidistant ones true meridians
|
|
112
|
+
(checked by finite differences), stereographic maps small circles to circles.
|
|
113
|
+
|
|
114
|
+
## Credits
|
|
115
|
+
|
|
116
|
+
Written from J. P. Snyder, _Map Projections — A Working Manual_, USGS
|
|
117
|
+
Professional Paper 1395 (1987), public domain (azimuthal projections §20–25,
|
|
118
|
+
Mercator §7, Albers §14, Lambert conformal §15, equidistant conic §16); B.
|
|
119
|
+
Šavrič, T. Patterson and B. Jenny, "The Equal Earth map projection", Int. J.
|
|
120
|
+
Geogr. Inf. Sci. 33(3) (2019); and B. Šavrič, B. Jenny, T. Patterson, D. Petrović
|
|
121
|
+
and L. Hurni, "A polynomial equation for the Natural Earth projection",
|
|
122
|
+
Cartography and Geographic Information Science 38(4) (2011). `d3-geo` and
|
|
123
|
+
`proj4` are test oracles only; no code of either is used.
|
|
124
|
+
|
|
125
|
+
See the
|
|
126
|
+
[generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/math-map-projection/)
|
|
127
|
+
for the full reference.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The element count of a bulk map from `inputStride` to `outputStride` numbers
|
|
3
|
+
* per element, which throws the `RangeError` the kernels share when the two
|
|
4
|
+
* buffers do not describe the same number of elements.
|
|
5
|
+
*/
|
|
6
|
+
export declare function elementCount_(name: string, out: Float64Array, input: Float64Array, inputStride: number, outputStride: number): number;
|
|
7
|
+
//# sourceMappingURL=_array-length.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_array-length.d.ts","sourceRoot":"","sources":["../src/_array-length.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GAClB,MAAM,CAUR"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The element count of a bulk map from `inputStride` to `outputStride` numbers
|
|
3
|
+
* per element, which throws the `RangeError` the kernels share when the two
|
|
4
|
+
* buffers do not describe the same number of elements.
|
|
5
|
+
*/
|
|
6
|
+
export function elementCount_(name, out, input, inputStride, outputStride) {
|
|
7
|
+
if (input.length % inputStride !== 0 ||
|
|
8
|
+
out.length !== (input.length / inputStride) * outputStride) {
|
|
9
|
+
throw new RangeError(`${name}: input has ${input.length} numbers and out has ${out.length}, which are not the same count of elements (${inputStride} in, ${outputStride} out).`);
|
|
10
|
+
}
|
|
11
|
+
return input.length / inputStride;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=_array-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_array-length.js","sourceRoot":"","sources":["../src/_array-length.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC5B,IAAY,EACZ,GAAiB,EACjB,KAAmB,EACnB,WAAmB,EACnB,YAAoB;IAEpB,IACC,KAAK,CAAC,MAAM,GAAG,WAAW,KAAK,CAAC;QAChC,GAAG,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,YAAY,EACzD,CAAC;QACF,MAAM,IAAI,UAAU,CACnB,GAAG,IAAI,eAAe,KAAK,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAM,+CAA+C,WAAW,QAAQ,YAAY,QAAQ,CAC1J,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The isometric latitude `ψ = ln tan(π/4 + φ/2)`, as `asinh(tan φ)`: it keeps
|
|
3
|
+
* its digits where `atanh(sin φ)` saturates (`sin φ` rounds to `1` a hair of
|
|
4
|
+
* `1.5e−8` rad below the pole), and the poles (`φ` exactly `±π/2`) go to `±∞`.
|
|
5
|
+
* `NaN` outside `[−π/2, π/2]`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isometricLatitude_(latitude: number): number;
|
|
8
|
+
//# sourceMappingURL=_isometric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_isometric.d.ts","sourceRoot":"","sources":["../src/_isometric.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAW3D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The isometric latitude `ψ = ln tan(π/4 + φ/2)`, as `asinh(tan φ)`: it keeps
|
|
3
|
+
* its digits where `atanh(sin φ)` saturates (`sin φ` rounds to `1` a hair of
|
|
4
|
+
* `1.5e−8` rad below the pole), and the poles (`φ` exactly `±π/2`) go to `±∞`.
|
|
5
|
+
* `NaN` outside `[−π/2, π/2]`.
|
|
6
|
+
*/
|
|
7
|
+
export function isometricLatitude_(latitude) {
|
|
8
|
+
const half = Math.PI / 2;
|
|
9
|
+
if (latitude === half) {
|
|
10
|
+
return Number.POSITIVE_INFINITY;
|
|
11
|
+
}
|
|
12
|
+
if (latitude === -half) {
|
|
13
|
+
return Number.NEGATIVE_INFINITY;
|
|
14
|
+
}
|
|
15
|
+
return Math.abs(latitude) < half
|
|
16
|
+
? Math.asinh(Math.tan(latitude))
|
|
17
|
+
: Number.NaN;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=_isometric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_isometric.js","sourceRoot":"","sources":["../src/_isometric.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IAClD,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACzB,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,iBAAiB,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,iBAAiB,CAAC;IACjC,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI;QAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ReadonlyMat3x3, type ReadonlyVec2, type ReadonlyVec3, type Vec2, type Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
/**
|
|
3
|
+
* The Lambert azimuthal equal-area projection (Snyder, _Map Projections — A
|
|
4
|
+
* Working Manual_, 1987, §24, spherical form): areas are true, the point at
|
|
5
|
+
* angular distance `c` from the centre landing at plane distance `2·sin(c /
|
|
6
|
+
* 2)`, so the whole sphere fills the disk of radius `2`. On unit vectors in the
|
|
7
|
+
* canonical frame (centre `+X`, plane x east `+Y`, plane y north `+Z`) it is
|
|
8
|
+
* `(y, z) · √(2 / (1 + x))`. The antipode is the circle of radius `2` and has
|
|
9
|
+
* no single image: it gives `NaN`.
|
|
10
|
+
*
|
|
11
|
+
* Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
|
|
12
|
+
* in each output it feeds.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The angular radius around the centre where the projection stops: `π`
|
|
16
|
+
* (exclusive).
|
|
17
|
+
*/
|
|
18
|
+
export declare const AZIMUTHAL_EQUAL_AREA_DOMAIN_ANGLE: number;
|
|
19
|
+
/** Writes the plane point of the unit vector `point` into `out`. */
|
|
20
|
+
export declare function azimuthalEqualAreaProject(out: Vec2, point: ReadonlyVec3): Vec2;
|
|
21
|
+
/**
|
|
22
|
+
* Writes the unit vector of the plane point `point` into `out`. A point at
|
|
23
|
+
* distance `2` or more, or with a non-finite coordinate, gives `NaN`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function azimuthalEqualAreaUnproject(out: Vec3, point: ReadonlyVec2): Vec3;
|
|
26
|
+
/**
|
|
27
|
+
* Rotates every unit vector of `input` (three numbers each) by `rotation`, then
|
|
28
|
+
* writes its plane point into `out` (two numbers each), in one pass: the sphere
|
|
29
|
+
* turns first, as for a view. `out` and `input` do not overlap. O(n).
|
|
30
|
+
*
|
|
31
|
+
* @returns `out`.
|
|
32
|
+
* @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
|
|
33
|
+
*/
|
|
34
|
+
export declare function azimuthalEqualAreaProjectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
|
|
35
|
+
/**
|
|
36
|
+
* Writes the unit vector of every plane point of `input` (two numbers each)
|
|
37
|
+
* into `out` (three numbers each), then turns it by the transpose of
|
|
38
|
+
* `rotation`: the inverse of {@link azimuthalEqualAreaProjectArray}. O(n).
|
|
39
|
+
*
|
|
40
|
+
* @returns `out`.
|
|
41
|
+
* @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
|
|
42
|
+
*/
|
|
43
|
+
export declare function azimuthalEqualAreaUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
|
|
44
|
+
/**
|
|
45
|
+
* The plane distance from the centre of a point at angular distance `angle`:
|
|
46
|
+
* `2·sin(angle / 2)`. `NaN` for an angle outside `[0, π)`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function azimuthalEqualAreaRadius(angle: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* The angular distance of a point at plane distance `radius`: `2·asin(radius /
|
|
51
|
+
* 2)`, the inverse of {@link azimuthalEqualAreaRadius}. `NaN` for a radius
|
|
52
|
+
* outside `[0, 2)`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function azimuthalEqualAreaAngle(radius: number): number;
|
|
55
|
+
//# sourceMappingURL=azimuthal-equal-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azimuthal-equal-area.d.ts","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-equal-area.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,IAAI,EAIT,MAAM,qBAAqB,CAAC;AAO7B;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAgB,CAAC;AAEjE,oEAAoE;AACpE,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,GACjB,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,GACjB,IAAI,CAeN;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,YAAY,EACpE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAuCH;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,YAAY,EACtE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CA2BH;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { vec2Create, vec2Load, vec3Create, } from "@ac-kit/math-linear";
|
|
2
|
+
import { elementCount_ } from "../_array-length.js";
|
|
3
|
+
const POINT_ = vec2Create();
|
|
4
|
+
const VECTOR_ = vec3Create();
|
|
5
|
+
/**
|
|
6
|
+
* The Lambert azimuthal equal-area projection (Snyder, _Map Projections — A
|
|
7
|
+
* Working Manual_, 1987, §24, spherical form): areas are true, the point at
|
|
8
|
+
* angular distance `c` from the centre landing at plane distance `2·sin(c /
|
|
9
|
+
* 2)`, so the whole sphere fills the disk of radius `2`. On unit vectors in the
|
|
10
|
+
* canonical frame (centre `+X`, plane x east `+Y`, plane y north `+Z`) it is
|
|
11
|
+
* `(y, z) · √(2 / (1 + x))`. The antipode is the circle of radius `2` and has
|
|
12
|
+
* no single image: it gives `NaN`.
|
|
13
|
+
*
|
|
14
|
+
* Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
|
|
15
|
+
* in each output it feeds.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The angular radius around the centre where the projection stops: `π`
|
|
19
|
+
* (exclusive).
|
|
20
|
+
*/
|
|
21
|
+
export const AZIMUTHAL_EQUAL_AREA_DOMAIN_ANGLE = Math.PI;
|
|
22
|
+
/** Writes the plane point of the unit vector `point` into `out`. */
|
|
23
|
+
export function azimuthalEqualAreaProject(out, point) {
|
|
24
|
+
const x = point[0];
|
|
25
|
+
const y = point[1];
|
|
26
|
+
const z = point[2];
|
|
27
|
+
if (x > -0.9999) {
|
|
28
|
+
const scale = Math.sqrt(2 / (1 + x));
|
|
29
|
+
out[0] = y * scale;
|
|
30
|
+
out[1] = z * scale;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
// Beyond x = −0.9999 (0.005% of the sphere, so the branch predicts well, and
|
|
34
|
+
// the plain form is good to 1e−12 before it) 1 + x
|
|
35
|
+
// cancels: on the unit sphere √(2 / (1 + x)) is √(2·(1 − x)) / √(y² + z²),
|
|
36
|
+
// with the transverse part scaled by its larger component so that it
|
|
37
|
+
// neither underflows nor overflows.
|
|
38
|
+
const largest = Math.max(Math.abs(y), Math.abs(z));
|
|
39
|
+
const a = y / largest;
|
|
40
|
+
const b = z / largest;
|
|
41
|
+
const scale = Math.sqrt((2 * (1 - x)) / (a * a + b * b));
|
|
42
|
+
out[0] = a * scale;
|
|
43
|
+
out[1] = b * scale;
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Writes the unit vector of the plane point `point` into `out`. A point at
|
|
48
|
+
* distance `2` or more, or with a non-finite coordinate, gives `NaN`.
|
|
49
|
+
*/
|
|
50
|
+
export function azimuthalEqualAreaUnproject(out, point) {
|
|
51
|
+
const x = point[0];
|
|
52
|
+
const y = point[1];
|
|
53
|
+
const squared = x * x + y * y;
|
|
54
|
+
if (squared < 4) {
|
|
55
|
+
const scale = Math.sqrt(1 - squared / 4);
|
|
56
|
+
out[0] = 1 - squared / 2;
|
|
57
|
+
out[1] = x * scale;
|
|
58
|
+
out[2] = y * scale;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
out[0] = Number.NaN;
|
|
62
|
+
out[1] = Number.NaN;
|
|
63
|
+
out[2] = Number.NaN;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Rotates every unit vector of `input` (three numbers each) by `rotation`, then
|
|
69
|
+
* writes its plane point into `out` (two numbers each), in one pass: the sphere
|
|
70
|
+
* turns first, as for a view. `out` and `input` do not overlap. O(n).
|
|
71
|
+
*
|
|
72
|
+
* @returns `out`.
|
|
73
|
+
* @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
|
|
74
|
+
*/
|
|
75
|
+
export function azimuthalEqualAreaProjectArray(out, input, rotation) {
|
|
76
|
+
const count = elementCount_("azimuthalEqualAreaProjectArray", out, input, 3, 2);
|
|
77
|
+
const m0 = rotation[0];
|
|
78
|
+
const m1 = rotation[1];
|
|
79
|
+
const m2 = rotation[2];
|
|
80
|
+
const m3 = rotation[3];
|
|
81
|
+
const m4 = rotation[4];
|
|
82
|
+
const m5 = rotation[5];
|
|
83
|
+
const m6 = rotation[6];
|
|
84
|
+
const m7 = rotation[7];
|
|
85
|
+
const m8 = rotation[8];
|
|
86
|
+
for (let index = 0; index < count; index++) {
|
|
87
|
+
const x = input[3 * index];
|
|
88
|
+
const y = input[3 * index + 1];
|
|
89
|
+
const z = input[3 * index + 2];
|
|
90
|
+
const depth = m0 * x + m3 * y + m6 * z;
|
|
91
|
+
const east = m1 * x + m4 * y + m7 * z;
|
|
92
|
+
const north = m2 * x + m5 * y + m8 * z;
|
|
93
|
+
if (depth > -0.9999) {
|
|
94
|
+
const scale = Math.sqrt(2 / (1 + depth));
|
|
95
|
+
out[2 * index] = east * scale;
|
|
96
|
+
out[2 * index + 1] = north * scale;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// The back half, as azimuthalEqualAreaProject writes it.
|
|
100
|
+
const largest = Math.max(Math.abs(east), Math.abs(north));
|
|
101
|
+
const a = east / largest;
|
|
102
|
+
const b = north / largest;
|
|
103
|
+
const scale = Math.sqrt((2 * (1 - depth)) / (a * a + b * b));
|
|
104
|
+
out[2 * index] = a * scale;
|
|
105
|
+
out[2 * index + 1] = b * scale;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Writes the unit vector of every plane point of `input` (two numbers each)
|
|
112
|
+
* into `out` (three numbers each), then turns it by the transpose of
|
|
113
|
+
* `rotation`: the inverse of {@link azimuthalEqualAreaProjectArray}. O(n).
|
|
114
|
+
*
|
|
115
|
+
* @returns `out`.
|
|
116
|
+
* @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
|
|
117
|
+
*/
|
|
118
|
+
export function azimuthalEqualAreaUnprojectArray(out, input, rotation) {
|
|
119
|
+
const count = elementCount_("azimuthalEqualAreaUnprojectArray", out, input, 2, 3);
|
|
120
|
+
const m0 = rotation[0];
|
|
121
|
+
const m1 = rotation[1];
|
|
122
|
+
const m2 = rotation[2];
|
|
123
|
+
const m3 = rotation[3];
|
|
124
|
+
const m4 = rotation[4];
|
|
125
|
+
const m5 = rotation[5];
|
|
126
|
+
const m6 = rotation[6];
|
|
127
|
+
const m7 = rotation[7];
|
|
128
|
+
const m8 = rotation[8];
|
|
129
|
+
for (let index = 0; index < count; index++) {
|
|
130
|
+
azimuthalEqualAreaUnproject(VECTOR_, vec2Load(POINT_, input, index));
|
|
131
|
+
const x = VECTOR_[0];
|
|
132
|
+
const y = VECTOR_[1];
|
|
133
|
+
const z = VECTOR_[2];
|
|
134
|
+
out[3 * index] = m0 * x + m1 * y + m2 * z;
|
|
135
|
+
out[3 * index + 1] = m3 * x + m4 * y + m5 * z;
|
|
136
|
+
out[3 * index + 2] = m6 * x + m7 * y + m8 * z;
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The plane distance from the centre of a point at angular distance `angle`:
|
|
142
|
+
* `2·sin(angle / 2)`. `NaN` for an angle outside `[0, π)`.
|
|
143
|
+
*/
|
|
144
|
+
export function azimuthalEqualAreaRadius(angle) {
|
|
145
|
+
return angle >= 0 && angle < Math.PI ? 2 * Math.sin(angle / 2) : Number.NaN;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The angular distance of a point at plane distance `radius`: `2·asin(radius /
|
|
149
|
+
* 2)`, the inverse of {@link azimuthalEqualAreaRadius}. `NaN` for a radius
|
|
150
|
+
* outside `[0, 2)`.
|
|
151
|
+
*/
|
|
152
|
+
export function azimuthalEqualAreaAngle(radius) {
|
|
153
|
+
return radius >= 0 && radius < 2 ? 2 * Math.asin(radius / 2) : Number.NaN;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=azimuthal-equal-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azimuthal-equal-area.js","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-equal-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,UAAU,EACV,QAAQ,EACR,UAAU,GACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAE7B;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAW,IAAI,CAAC,EAAE,CAAC;AAEjE,oEAAoE;AACpE,MAAM,UAAU,yBAAyB,CACxC,GAAS,EACT,KAAmB;IAEnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC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ReadonlyVec2, type ReadonlyVec3, type Vec2, type Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
/**
|
|
3
|
+
* The azimuthal equidistant projection (Snyder, _Map Projections — A Working
|
|
4
|
+
* Manual_, 1987, §25, spherical form): distances and directions from the centre
|
|
5
|
+
* are true, the point at angular distance `c` landing at plane distance `c`. On
|
|
6
|
+
* unit vectors in the canonical frame (centre `+X`, plane x east `+Y`, plane y
|
|
7
|
+
* north `+Z`) the angle is `atan2(√(y² + z²), x)`, which keeps its digits near
|
|
8
|
+
* the centre and near the antipode, where `acos(x)` loses them. The antipode is
|
|
9
|
+
* the circle of radius `π` and has no single image: it gives `NaN`.
|
|
10
|
+
*
|
|
11
|
+
* Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
|
|
12
|
+
* in each output it feeds.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The angular radius around the centre where the projection stops: `π`
|
|
16
|
+
* (exclusive).
|
|
17
|
+
*/
|
|
18
|
+
export declare const AZIMUTHAL_EQUIDISTANT_DOMAIN_ANGLE: number;
|
|
19
|
+
/** Writes the plane point of the unit vector `point` into `out`. */
|
|
20
|
+
export declare function azimuthalEquidistantProject(out: Vec2, point: ReadonlyVec3): Vec2;
|
|
21
|
+
/**
|
|
22
|
+
* Writes the unit vector of the plane point `point` into `out`. A point at
|
|
23
|
+
* distance `π` or more, or with a non-finite coordinate, gives `NaN`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function azimuthalEquidistantUnproject(out: Vec3, point: ReadonlyVec2): Vec3;
|
|
26
|
+
/**
|
|
27
|
+
* Rotates every unit vector of `input` (three numbers each) by `rotation`, then
|
|
28
|
+
* writes its plane point into `out` (two numbers each), in one pass: the sphere
|
|
29
|
+
* turns first, as for a view. `out` and `input` do not overlap. O(n).
|
|
30
|
+
*
|
|
31
|
+
* @returns `out`.
|
|
32
|
+
* @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
|
|
33
|
+
*/
|
|
34
|
+
export declare function azimuthalEquidistantProjectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
|
|
35
|
+
/**
|
|
36
|
+
* Writes the unit vector of every plane point of `input` (two numbers each)
|
|
37
|
+
* into `out` (three numbers each), then turns it by the transpose of
|
|
38
|
+
* `rotation`: the inverse of {@link azimuthalEquidistantProjectArray}. O(n).
|
|
39
|
+
*
|
|
40
|
+
* @returns `out`.
|
|
41
|
+
* @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
|
|
42
|
+
*/
|
|
43
|
+
export declare function azimuthalEquidistantUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
|
|
44
|
+
/**
|
|
45
|
+
* The plane distance from the centre of a point at angular distance `angle`:
|
|
46
|
+
* `angle` itself. `NaN` for an angle outside `[0, π)`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function azimuthalEquidistantRadius(angle: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* The angular distance of a point at plane distance `radius`: `radius`, the
|
|
51
|
+
* inverse of {@link azimuthalEquidistantRadius}. `NaN` for a radius outside `[0,
|
|
52
|
+
* π)`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function azimuthalEquidistantAngle(radius: number): number;
|
|
55
|
+
//# sourceMappingURL=azimuthal-equidistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azimuthal-equidistant.d.ts","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-equidistant.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,IAAI,EAIT,MAAM,qBAAqB,CAAC;AAoC7B;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,kCAAkC,EAAE,MAAgB,CAAC;AAElE,oEAAoE;AACpE,wBAAgB,2BAA2B,CAC1C,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,GACjB,IAAI,CAeN;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC5C,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,GACjB,IAAI,CAeN;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,YAAY,EACtE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAkCH;AAED;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,CAAC,SAAS,YAAY,EACxE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CA2BH;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|