@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.
Files changed (128) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/LICENSE +28 -0
  3. package/README.md +126 -2
  4. package/dist/_array-length.d.ts +7 -0
  5. package/dist/_array-length.d.ts.map +1 -0
  6. package/dist/_array-length.js +13 -0
  7. package/dist/_array-length.js.map +1 -0
  8. package/dist/_isometric.d.ts +8 -0
  9. package/dist/_isometric.d.ts.map +1 -0
  10. package/dist/_isometric.js +19 -0
  11. package/dist/_isometric.js.map +1 -0
  12. package/dist/azimuthal/azimuthal-equal-area.d.ts +55 -0
  13. package/dist/azimuthal/azimuthal-equal-area.d.ts.map +1 -0
  14. package/dist/azimuthal/azimuthal-equal-area.js +155 -0
  15. package/dist/azimuthal/azimuthal-equal-area.js.map +1 -0
  16. package/dist/azimuthal/azimuthal-equidistant.d.ts +55 -0
  17. package/dist/azimuthal/azimuthal-equidistant.d.ts.map +1 -0
  18. package/dist/azimuthal/azimuthal-equidistant.js +164 -0
  19. package/dist/azimuthal/azimuthal-equidistant.js.map +1 -0
  20. package/dist/azimuthal/azimuthal-projection-kind.d.ts +28 -0
  21. package/dist/azimuthal/azimuthal-projection-kind.d.ts.map +1 -0
  22. package/dist/azimuthal/azimuthal-projection-kind.js +70 -0
  23. package/dist/azimuthal/azimuthal-projection-kind.js.map +1 -0
  24. package/dist/azimuthal/gnomonic.d.ts +61 -0
  25. package/dist/azimuthal/gnomonic.d.ts.map +1 -0
  26. package/dist/azimuthal/gnomonic.js +140 -0
  27. package/dist/azimuthal/gnomonic.js.map +1 -0
  28. package/dist/azimuthal/index.d.ts +7 -0
  29. package/dist/azimuthal/index.d.ts.map +1 -0
  30. package/dist/azimuthal/index.js +7 -0
  31. package/dist/azimuthal/index.js.map +1 -0
  32. package/dist/azimuthal/orthographic.d.ts +59 -0
  33. package/dist/azimuthal/orthographic.d.ts.map +1 -0
  34. package/dist/azimuthal/orthographic.js +145 -0
  35. package/dist/azimuthal/orthographic.js.map +1 -0
  36. package/dist/azimuthal/stereographic.d.ts +59 -0
  37. package/dist/azimuthal/stereographic.d.ts.map +1 -0
  38. package/dist/azimuthal/stereographic.js +168 -0
  39. package/dist/azimuthal/stereographic.js.map +1 -0
  40. package/dist/conic/_conic.d.ts +55 -0
  41. package/dist/conic/_conic.d.ts.map +1 -0
  42. package/dist/conic/_conic.js +68 -0
  43. package/dist/conic/_conic.js.map +1 -0
  44. package/dist/conic/conic-conformal.d.ts +52 -0
  45. package/dist/conic/conic-conformal.d.ts.map +1 -0
  46. package/dist/conic/conic-conformal.js +144 -0
  47. package/dist/conic/conic-conformal.js.map +1 -0
  48. package/dist/conic/conic-equal-area.d.ts +55 -0
  49. package/dist/conic/conic-equal-area.d.ts.map +1 -0
  50. package/dist/conic/conic-equal-area.js +122 -0
  51. package/dist/conic/conic-equal-area.js.map +1 -0
  52. package/dist/conic/conic-equidistant.d.ts +50 -0
  53. package/dist/conic/conic-equidistant.d.ts.map +1 -0
  54. package/dist/conic/conic-equidistant.js +113 -0
  55. package/dist/conic/conic-equidistant.js.map +1 -0
  56. package/dist/conic/index.d.ts +5 -0
  57. package/dist/conic/index.d.ts.map +1 -0
  58. package/dist/conic/index.js +4 -0
  59. package/dist/conic/index.js.map +1 -0
  60. package/dist/cylindrical/equirectangular.d.ts +37 -0
  61. package/dist/cylindrical/equirectangular.d.ts.map +1 -0
  62. package/dist/cylindrical/equirectangular.js +67 -0
  63. package/dist/cylindrical/equirectangular.js.map +1 -0
  64. package/dist/cylindrical/index.d.ts +4 -0
  65. package/dist/cylindrical/index.d.ts.map +1 -0
  66. package/dist/cylindrical/index.js +4 -0
  67. package/dist/cylindrical/index.js.map +1 -0
  68. package/dist/cylindrical/mercator.d.ts +38 -0
  69. package/dist/cylindrical/mercator.d.ts.map +1 -0
  70. package/dist/cylindrical/mercator.js +67 -0
  71. package/dist/cylindrical/mercator.js.map +1 -0
  72. package/dist/cylindrical/transverse-mercator.d.ts +32 -0
  73. package/dist/cylindrical/transverse-mercator.d.ts.map +1 -0
  74. package/dist/cylindrical/transverse-mercator.js +103 -0
  75. package/dist/cylindrical/transverse-mercator.js.map +1 -0
  76. package/dist/geometry/_cut-antimeridian.d.ts +24 -0
  77. package/dist/geometry/_cut-antimeridian.d.ts.map +1 -0
  78. package/dist/geometry/_cut-antimeridian.js +204 -0
  79. package/dist/geometry/_cut-antimeridian.js.map +1 -0
  80. package/dist/geometry/_cut-cap.d.ts +29 -0
  81. package/dist/geometry/_cut-cap.d.ts.map +1 -0
  82. package/dist/geometry/_cut-cap.js +258 -0
  83. package/dist/geometry/_cut-cap.js.map +1 -0
  84. package/dist/geometry/_path.d.ts +36 -0
  85. package/dist/geometry/_path.d.ts.map +1 -0
  86. package/dist/geometry/_path.js +57 -0
  87. package/dist/geometry/_path.js.map +1 -0
  88. package/dist/geometry/_resample.d.ts +21 -0
  89. package/dist/geometry/_resample.d.ts.map +1 -0
  90. package/dist/geometry/_resample.js +190 -0
  91. package/dist/geometry/_resample.js.map +1 -0
  92. package/dist/geometry/graticule.d.ts +30 -0
  93. package/dist/geometry/graticule.d.ts.map +1 -0
  94. package/dist/geometry/graticule.js +78 -0
  95. package/dist/geometry/graticule.js.map +1 -0
  96. package/dist/geometry/index.d.ts +4 -0
  97. package/dist/geometry/index.d.ts.map +1 -0
  98. package/dist/geometry/index.js +4 -0
  99. package/dist/geometry/index.js.map +1 -0
  100. package/dist/geometry/project-geometry.d.ts +86 -0
  101. package/dist/geometry/project-geometry.d.ts.map +1 -0
  102. package/dist/geometry/project-geometry.js +269 -0
  103. package/dist/geometry/project-geometry.js.map +1 -0
  104. package/dist/geometry/vertex-runs.d.ts +37 -0
  105. package/dist/geometry/vertex-runs.d.ts.map +1 -0
  106. package/dist/geometry/vertex-runs.js +61 -0
  107. package/dist/geometry/vertex-runs.js.map +1 -0
  108. package/dist/index.d.ts +7 -0
  109. package/dist/index.d.ts.map +1 -0
  110. package/dist/index.js +7 -0
  111. package/dist/index.js.map +1 -0
  112. package/dist/projection.d.ts +116 -0
  113. package/dist/projection.d.ts.map +1 -0
  114. package/dist/projection.js +408 -0
  115. package/dist/projection.js.map +1 -0
  116. package/dist/pseudo-cylindrical/equal-earth.d.ts +28 -0
  117. package/dist/pseudo-cylindrical/equal-earth.d.ts.map +1 -0
  118. package/dist/pseudo-cylindrical/equal-earth.js +124 -0
  119. package/dist/pseudo-cylindrical/equal-earth.js.map +1 -0
  120. package/dist/pseudo-cylindrical/index.d.ts +3 -0
  121. package/dist/pseudo-cylindrical/index.d.ts.map +1 -0
  122. package/dist/pseudo-cylindrical/index.js +3 -0
  123. package/dist/pseudo-cylindrical/index.js.map +1 -0
  124. package/dist/pseudo-cylindrical/natural-earth.d.ts +28 -0
  125. package/dist/pseudo-cylindrical/natural-earth.d.ts.map +1 -0
  126. package/dist/pseudo-cylindrical/natural-earth.js +118 -0
  127. package/dist/pseudo-cylindrical/natural-earth.js.map +1 -0
  128. package/package.json +70 -3
@@ -0,0 +1,164 @@
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
+ /** The near-axis writer's output for a single value (S23: it only sees buffers). */
6
+ const PAIR_ = new Float64Array(2);
7
+ /**
8
+ * Writes the plane point of a vector whose transverse part `(y, z)` is too
9
+ * small to square (below `1e-150`): scaled by its larger component, the angle
10
+ * stays exact next to the centre and the antipode, which is `NaN` at `y = z =
11
+ * 0` and the origin at the centre.
12
+ */
13
+ function projectNearAxis_(out, offset, x, y, z) {
14
+ const largest = Math.max(Math.abs(y), Math.abs(z));
15
+ if (largest === 0) {
16
+ out[offset] = x > 0 ? y : Number.NaN;
17
+ out[offset + 1] = x > 0 ? z : Number.NaN;
18
+ return;
19
+ }
20
+ const a = y / largest;
21
+ const b = z / largest;
22
+ const norm = Math.sqrt(a * a + b * b);
23
+ const angle = Math.atan2(largest * norm, x) / norm;
24
+ out[offset] = a * angle;
25
+ out[offset + 1] = b * angle;
26
+ }
27
+ /**
28
+ * The azimuthal equidistant projection (Snyder, _Map Projections — A Working
29
+ * Manual_, 1987, §25, spherical form): distances and directions from the centre
30
+ * are true, the point at angular distance `c` landing at plane distance `c`. On
31
+ * unit vectors in the canonical frame (centre `+X`, plane x east `+Y`, plane y
32
+ * north `+Z`) the angle is `atan2(√(y² + z²), x)`, which keeps its digits near
33
+ * the centre and near the antipode, where `acos(x)` loses them. The antipode is
34
+ * the circle of radius `π` and has no single image: it gives `NaN`.
35
+ *
36
+ * Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
37
+ * in each output it feeds.
38
+ */
39
+ /**
40
+ * The angular radius around the centre where the projection stops: `π`
41
+ * (exclusive).
42
+ */
43
+ export const AZIMUTHAL_EQUIDISTANT_DOMAIN_ANGLE = Math.PI;
44
+ /** Writes the plane point of the unit vector `point` into `out`. */
45
+ export function azimuthalEquidistantProject(out, point) {
46
+ const x = point[0];
47
+ const y = point[1];
48
+ const z = point[2];
49
+ const sine = Math.sqrt(y * y + z * z);
50
+ if (sine < 1e-150) {
51
+ projectNearAxis_(PAIR_, 0, x, y, z);
52
+ out[0] = PAIR_[0];
53
+ out[1] = PAIR_[1];
54
+ return out;
55
+ }
56
+ const scale = Math.atan2(sine, x) / sine;
57
+ out[0] = y * scale;
58
+ out[1] = z * scale;
59
+ return out;
60
+ }
61
+ /**
62
+ * Writes the unit vector of the plane point `point` into `out`. A point at
63
+ * distance `π` or more, or with a non-finite coordinate, gives `NaN`.
64
+ */
65
+ export function azimuthalEquidistantUnproject(out, point) {
66
+ const x = point[0];
67
+ const y = point[1];
68
+ const radius = Math.sqrt(x * x + y * y);
69
+ if (radius < Math.PI) {
70
+ const scale = radius === 0 ? 1 : Math.sin(radius) / radius;
71
+ out[0] = Math.cos(radius);
72
+ out[1] = x * scale;
73
+ out[2] = y * scale;
74
+ }
75
+ else {
76
+ out[0] = Number.NaN;
77
+ out[1] = Number.NaN;
78
+ out[2] = Number.NaN;
79
+ }
80
+ return out;
81
+ }
82
+ /**
83
+ * Rotates every unit vector of `input` (three numbers each) by `rotation`, then
84
+ * writes its plane point into `out` (two numbers each), in one pass: the sphere
85
+ * turns first, as for a view. `out` and `input` do not overlap. O(n).
86
+ *
87
+ * @returns `out`.
88
+ * @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
89
+ */
90
+ export function azimuthalEquidistantProjectArray(out, input, rotation) {
91
+ const count = elementCount_("azimuthalEquidistantProjectArray", out, input, 3, 2);
92
+ const m0 = rotation[0];
93
+ const m1 = rotation[1];
94
+ const m2 = rotation[2];
95
+ const m3 = rotation[3];
96
+ const m4 = rotation[4];
97
+ const m5 = rotation[5];
98
+ const m6 = rotation[6];
99
+ const m7 = rotation[7];
100
+ const m8 = rotation[8];
101
+ for (let index = 0; index < count; index++) {
102
+ const a = input[3 * index];
103
+ const b = input[3 * index + 1];
104
+ const c = input[3 * index + 2];
105
+ const x = m0 * a + m3 * b + m6 * c;
106
+ const y = m1 * a + m4 * b + m7 * c;
107
+ const z = m2 * a + m5 * b + m8 * c;
108
+ const sine = Math.sqrt(y * y + z * z);
109
+ if (sine < 1e-150) {
110
+ projectNearAxis_(out, 2 * index, x, y, z);
111
+ continue;
112
+ }
113
+ const scale = Math.atan2(sine, x) / sine;
114
+ out[2 * index] = y * scale;
115
+ out[2 * index + 1] = z * scale;
116
+ }
117
+ return out;
118
+ }
119
+ /**
120
+ * Writes the unit vector of every plane point of `input` (two numbers each)
121
+ * into `out` (three numbers each), then turns it by the transpose of
122
+ * `rotation`: the inverse of {@link azimuthalEquidistantProjectArray}. O(n).
123
+ *
124
+ * @returns `out`.
125
+ * @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
126
+ */
127
+ export function azimuthalEquidistantUnprojectArray(out, input, rotation) {
128
+ const count = elementCount_("azimuthalEquidistantUnprojectArray", out, input, 2, 3);
129
+ const m0 = rotation[0];
130
+ const m1 = rotation[1];
131
+ const m2 = rotation[2];
132
+ const m3 = rotation[3];
133
+ const m4 = rotation[4];
134
+ const m5 = rotation[5];
135
+ const m6 = rotation[6];
136
+ const m7 = rotation[7];
137
+ const m8 = rotation[8];
138
+ for (let index = 0; index < count; index++) {
139
+ azimuthalEquidistantUnproject(VECTOR_, vec2Load(POINT_, input, index));
140
+ const x = VECTOR_[0];
141
+ const y = VECTOR_[1];
142
+ const z = VECTOR_[2];
143
+ out[3 * index] = m0 * x + m1 * y + m2 * z;
144
+ out[3 * index + 1] = m3 * x + m4 * y + m5 * z;
145
+ out[3 * index + 2] = m6 * x + m7 * y + m8 * z;
146
+ }
147
+ return out;
148
+ }
149
+ /**
150
+ * The plane distance from the centre of a point at angular distance `angle`:
151
+ * `angle` itself. `NaN` for an angle outside `[0, π)`.
152
+ */
153
+ export function azimuthalEquidistantRadius(angle) {
154
+ return angle >= 0 && angle < Math.PI ? angle : Number.NaN;
155
+ }
156
+ /**
157
+ * The angular distance of a point at plane distance `radius`: `radius`, the
158
+ * inverse of {@link azimuthalEquidistantRadius}. `NaN` for a radius outside `[0,
159
+ * π)`.
160
+ */
161
+ export function azimuthalEquidistantAngle(radius) {
162
+ return radius >= 0 && radius < Math.PI ? radius : Number.NaN;
163
+ }
164
+ //# sourceMappingURL=azimuthal-equidistant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azimuthal-equidistant.js","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-equidistant.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;AAC7B,oFAAoF;AACpF,MAAM,KAAK,GAAG,IAAI,YAAY,CAA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AAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAa;IACvD,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAc;IACvD,OAAO,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The azimuthal projections, by the names `model-chart`'s `ProjectionKind`
3
+ * uses. A chart picks its projection from data (`projection.kind`), which is
4
+ * the one place a choice made at run time is worth a dispatch over the
5
+ * dedicated functions; a caller that knows its projection calls the dedicated
6
+ * ones.
7
+ */
8
+ export type AzimuthalProjectionKind = "stereographic" | "orthographic" | "gnomonic" | "azimuthal-equidistant" | "azimuthal-equal-area";
9
+ /**
10
+ * The plane distance from the centre of a point at angular distance `angle`, by
11
+ * the `…Radius` function of the named projection. A name that is not an
12
+ * {@link AzimuthalProjectionKind} gives `NaN`.
13
+ */
14
+ export declare function azimuthalRadius(kind: AzimuthalProjectionKind, angle: number): number;
15
+ /**
16
+ * The angular distance of a point at plane distance `radius`, by the `…Angle`
17
+ * function of the named projection. A name that is not an
18
+ * {@link AzimuthalProjectionKind} gives `NaN`.
19
+ */
20
+ export declare function azimuthalAngle(kind: AzimuthalProjectionKind, radius: number): number;
21
+ /**
22
+ * The angular radius around the centre beyond which the named projection is
23
+ * undefined or unbounded (its `…_DOMAIN_ANGLE`): `π / 2` for the orthographic
24
+ * (inclusive) and gnomonic, `π` (exclusive) for the others. A name that is not
25
+ * an {@link AzimuthalProjectionKind} gives `NaN`.
26
+ */
27
+ export declare function azimuthalDomainAngle(kind: AzimuthalProjectionKind): number;
28
+ //# sourceMappingURL=azimuthal-projection-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azimuthal-projection-kind.d.ts","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-projection-kind.ts"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAChC,eAAe,GACf,cAAc,GACd,UAAU,GACV,uBAAuB,GACvB,sBAAsB,CAAC;AAE1B;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,uBAAuB,EAC7B,KAAK,EAAE,MAAM,GACX,MAAM,CAeR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,MAAM,GACZ,MAAM,CAeR;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,CAe1E"}
@@ -0,0 +1,70 @@
1
+ import { AZIMUTHAL_EQUAL_AREA_DOMAIN_ANGLE, azimuthalEqualAreaAngle, azimuthalEqualAreaRadius, } from "./azimuthal-equal-area.js";
2
+ import { AZIMUTHAL_EQUIDISTANT_DOMAIN_ANGLE, azimuthalEquidistantAngle, azimuthalEquidistantRadius, } from "./azimuthal-equidistant.js";
3
+ import { GNOMONIC_DOMAIN_ANGLE, gnomonicAngle, gnomonicRadius, } from "./gnomonic.js";
4
+ import { ORTHOGRAPHIC_DOMAIN_ANGLE, orthographicAngle, orthographicRadius, } from "./orthographic.js";
5
+ import { STEREOGRAPHIC_DOMAIN_ANGLE, stereographicAngle, stereographicRadius, } from "./stereographic.js";
6
+ /**
7
+ * The plane distance from the centre of a point at angular distance `angle`, by
8
+ * the `…Radius` function of the named projection. A name that is not an
9
+ * {@link AzimuthalProjectionKind} gives `NaN`.
10
+ */
11
+ export function azimuthalRadius(kind, angle) {
12
+ switch (kind) {
13
+ case "stereographic":
14
+ return stereographicRadius(angle);
15
+ case "orthographic":
16
+ return orthographicRadius(angle);
17
+ case "gnomonic":
18
+ return gnomonicRadius(angle);
19
+ case "azimuthal-equidistant":
20
+ return azimuthalEquidistantRadius(angle);
21
+ case "azimuthal-equal-area":
22
+ return azimuthalEqualAreaRadius(angle);
23
+ default:
24
+ return Number.NaN;
25
+ }
26
+ }
27
+ /**
28
+ * The angular distance of a point at plane distance `radius`, by the `…Angle`
29
+ * function of the named projection. A name that is not an
30
+ * {@link AzimuthalProjectionKind} gives `NaN`.
31
+ */
32
+ export function azimuthalAngle(kind, radius) {
33
+ switch (kind) {
34
+ case "stereographic":
35
+ return stereographicAngle(radius);
36
+ case "orthographic":
37
+ return orthographicAngle(radius);
38
+ case "gnomonic":
39
+ return gnomonicAngle(radius);
40
+ case "azimuthal-equidistant":
41
+ return azimuthalEquidistantAngle(radius);
42
+ case "azimuthal-equal-area":
43
+ return azimuthalEqualAreaAngle(radius);
44
+ default:
45
+ return Number.NaN;
46
+ }
47
+ }
48
+ /**
49
+ * The angular radius around the centre beyond which the named projection is
50
+ * undefined or unbounded (its `…_DOMAIN_ANGLE`): `π / 2` for the orthographic
51
+ * (inclusive) and gnomonic, `π` (exclusive) for the others. A name that is not
52
+ * an {@link AzimuthalProjectionKind} gives `NaN`.
53
+ */
54
+ export function azimuthalDomainAngle(kind) {
55
+ switch (kind) {
56
+ case "stereographic":
57
+ return STEREOGRAPHIC_DOMAIN_ANGLE;
58
+ case "orthographic":
59
+ return ORTHOGRAPHIC_DOMAIN_ANGLE;
60
+ case "gnomonic":
61
+ return GNOMONIC_DOMAIN_ANGLE;
62
+ case "azimuthal-equidistant":
63
+ return AZIMUTHAL_EQUIDISTANT_DOMAIN_ANGLE;
64
+ case "azimuthal-equal-area":
65
+ return AZIMUTHAL_EQUAL_AREA_DOMAIN_ANGLE;
66
+ default:
67
+ return Number.NaN;
68
+ }
69
+ }
70
+ //# sourceMappingURL=azimuthal-projection-kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azimuthal-projection-kind.js","sourceRoot":"","sources":["../../src/azimuthal/azimuthal-projection-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,kCAAkC,EAClC,yBAAyB,EACzB,0BAA0B,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,qBAAqB,EACrB,aAAa,EACb,cAAc,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAgB5B;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC9B,IAA6B,EAC7B,KAAa;IAEb,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,eAAe;YACnB,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACnC,KAAK,cAAc;YAClB,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAClC,KAAK,UAAU;YACd,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,uBAAuB;YAC3B,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAC1C,KAAK,sBAAsB;YAC1B,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;QACxC;YACC,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,IAA6B,EAC7B,MAAc;IAEd,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,eAAe;YACnB,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,cAAc;YAClB,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,UAAU;YACd,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,KAAK,uBAAuB;YAC3B,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC1C,KAAK,sBAAsB;YAC1B,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACxC;YACC,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAA6B;IACjE,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,eAAe;YACnB,OAAO,0BAA0B,CAAC;QACnC,KAAK,cAAc;YAClB,OAAO,yBAAyB,CAAC;QAClC,KAAK,UAAU;YACd,OAAO,qBAAqB,CAAC;QAC9B,KAAK,uBAAuB;YAC3B,OAAO,kCAAkC,CAAC;QAC3C,KAAK,sBAAsB;YAC1B,OAAO,iCAAiC,CAAC;QAC1C;YACC,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;AACF,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { type ReadonlyMat3x3, type ReadonlyVec2, type ReadonlyVec3, type Vec2, type Vec3 } from "@ac-kit/math-linear";
2
+ /**
3
+ * The gnomonic projection (Snyder, _Map Projections — A Working Manual_, 1987,
4
+ * §22, spherical form): every great circle is a straight line, the point at
5
+ * angular distance `c` from the centre landing at plane distance `tan c`. On
6
+ * unit vectors in the canonical frame (centre `+X`, plane x east `+Y`, plane y
7
+ * north `+Z`) it is `(y, z) / x`, and only the open hemisphere around the
8
+ * centre (`x > 0`) has an image; the horizon and beyond give `NaN`. Clip well
9
+ * below {@link GNOMONIC_DOMAIN_ANGLE} (`sphericalPolylineClipToCap`), the scale
10
+ * growing without bound towards it.
11
+ *
12
+ * Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
13
+ * in each output it feeds.
14
+ */
15
+ /**
16
+ * The angular radius around the centre where the projection stops: `π / 2`
17
+ * (exclusive).
18
+ */
19
+ export declare const GNOMONIC_DOMAIN_ANGLE: number;
20
+ /**
21
+ * Writes the plane point of the unit vector `point` into `out`; `NaN` at or
22
+ * beyond the horizon.
23
+ */
24
+ export declare function gnomonicProject(out: Vec2, point: ReadonlyVec3): Vec2;
25
+ /**
26
+ * Writes the unit vector of the plane point `point` into `out`. Every finite
27
+ * point has one, however far (the scale is kept in range, so `1e200` gives a
28
+ * direction on the horizon and not `NaN`); a non-finite coordinate gives
29
+ * `NaN`.
30
+ */
31
+ export declare function gnomonicUnproject(out: Vec3, point: ReadonlyVec2): Vec3;
32
+ /**
33
+ * Rotates every unit vector of `input` (three numbers each) by `rotation`, then
34
+ * writes its plane point into `out` (two numbers each), in one pass: the sphere
35
+ * turns first, as for a view. `out` and `input` do not overlap. O(n).
36
+ *
37
+ * @returns `out`.
38
+ * @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
39
+ */
40
+ export declare function gnomonicProjectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
41
+ /**
42
+ * Writes the unit vector of every plane point of `input` (two numbers each)
43
+ * into `out` (three numbers each), then turns it by the transpose of
44
+ * `rotation`: the inverse of {@link gnomonicProjectArray}. O(n).
45
+ *
46
+ * @returns `out`.
47
+ * @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
48
+ */
49
+ export declare function gnomonicUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
50
+ /**
51
+ * The plane distance from the centre of a point at angular distance `angle`:
52
+ * `tan(angle)`. `NaN` for an angle outside `[0, π / 2)`.
53
+ */
54
+ export declare function gnomonicRadius(angle: number): number;
55
+ /**
56
+ * The angular distance of a point at plane distance `radius`: `atan(radius)`,
57
+ * the inverse of {@link gnomonicRadius}. `NaN` for a negative or non-finite
58
+ * radius.
59
+ */
60
+ export declare function gnomonicAngle(radius: number): number;
61
+ //# sourceMappingURL=gnomonic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gnomonic.d.ts","sourceRoot":"","sources":["../../src/azimuthal/gnomonic.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;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAoB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAMpE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAsBtE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAC1D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAqBH;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,YAAY,EAC5D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAqBH;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIpD"}
@@ -0,0 +1,140 @@
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 gnomonic projection (Snyder, _Map Projections — A Working Manual_, 1987,
7
+ * §22, spherical form): every great circle is a straight line, the point at
8
+ * angular distance `c` from the centre landing at plane distance `tan c`. On
9
+ * unit vectors in the canonical frame (centre `+X`, plane x east `+Y`, plane y
10
+ * north `+Z`) it is `(y, z) / x`, and only the open hemisphere around the
11
+ * centre (`x > 0`) has an image; the horizon and beyond give `NaN`. Clip well
12
+ * below {@link GNOMONIC_DOMAIN_ANGLE} (`sphericalPolylineClipToCap`), the scale
13
+ * growing without bound towards it.
14
+ *
15
+ * Inputs are unit vectors, which are not checked. A `NaN` component gives `NaN`
16
+ * in each output it feeds.
17
+ */
18
+ /**
19
+ * The angular radius around the centre where the projection stops: `π / 2`
20
+ * (exclusive).
21
+ */
22
+ export const GNOMONIC_DOMAIN_ANGLE = Math.PI / 2;
23
+ /**
24
+ * Writes the plane point of the unit vector `point` into `out`; `NaN` at or
25
+ * beyond the horizon.
26
+ */
27
+ export function gnomonicProject(out, point) {
28
+ const x = point[0];
29
+ const scale = x > 0 ? 1 / x : Number.NaN;
30
+ out[0] = point[1] * scale;
31
+ out[1] = point[2] * scale;
32
+ return out;
33
+ }
34
+ /**
35
+ * Writes the unit vector of the plane point `point` into `out`. Every finite
36
+ * point has one, however far (the scale is kept in range, so `1e200` gives a
37
+ * direction on the horizon and not `NaN`); a non-finite coordinate gives
38
+ * `NaN`.
39
+ */
40
+ export function gnomonicUnproject(out, point) {
41
+ const x = point[0];
42
+ const y = point[1];
43
+ const squared = x * x + y * y;
44
+ if (squared === Number.POSITIVE_INFINITY) {
45
+ // The square overflowed: work with the point divided by its larger
46
+ // coordinate (S12).
47
+ const largest = Math.max(Math.abs(x), Math.abs(y));
48
+ const a = x / largest;
49
+ const b = y / largest;
50
+ const inverse = 1 / largest;
51
+ const scale = 1 / Math.sqrt(inverse * inverse + a * a + b * b);
52
+ out[0] = inverse * scale;
53
+ out[1] = a * scale;
54
+ out[2] = b * scale;
55
+ return out;
56
+ }
57
+ const scale = 1 / Math.sqrt(1 + squared);
58
+ out[0] = scale;
59
+ out[1] = x * scale;
60
+ out[2] = y * scale;
61
+ return out;
62
+ }
63
+ /**
64
+ * Rotates every unit vector of `input` (three numbers each) by `rotation`, then
65
+ * writes its plane point into `out` (two numbers each), in one pass: the sphere
66
+ * turns first, as for a view. `out` and `input` do not overlap. O(n).
67
+ *
68
+ * @returns `out`.
69
+ * @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
70
+ */
71
+ export function gnomonicProjectArray(out, input, rotation) {
72
+ const count = elementCount_("gnomonicProjectArray", out, input, 3, 2);
73
+ const m0 = rotation[0];
74
+ const m1 = rotation[1];
75
+ const m2 = rotation[2];
76
+ const m3 = rotation[3];
77
+ const m4 = rotation[4];
78
+ const m5 = rotation[5];
79
+ const m6 = rotation[6];
80
+ const m7 = rotation[7];
81
+ const m8 = rotation[8];
82
+ for (let index = 0; index < count; index++) {
83
+ const x = input[3 * index];
84
+ const y = input[3 * index + 1];
85
+ const z = input[3 * index + 2];
86
+ const depth = m0 * x + m3 * y + m6 * z;
87
+ const scale = depth > 0 ? 1 / depth : Number.NaN;
88
+ out[2 * index] = (m1 * x + m4 * y + m7 * z) * scale;
89
+ out[2 * index + 1] = (m2 * x + m5 * y + m8 * z) * scale;
90
+ }
91
+ return out;
92
+ }
93
+ /**
94
+ * Writes the unit vector of every plane point of `input` (two numbers each)
95
+ * into `out` (three numbers each), then turns it by the transpose of
96
+ * `rotation`: the inverse of {@link gnomonicProjectArray}. O(n).
97
+ *
98
+ * @returns `out`.
99
+ * @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
100
+ */
101
+ export function gnomonicUnprojectArray(out, input, rotation) {
102
+ const count = elementCount_("gnomonicUnprojectArray", out, input, 2, 3);
103
+ const m0 = rotation[0];
104
+ const m1 = rotation[1];
105
+ const m2 = rotation[2];
106
+ const m3 = rotation[3];
107
+ const m4 = rotation[4];
108
+ const m5 = rotation[5];
109
+ const m6 = rotation[6];
110
+ const m7 = rotation[7];
111
+ const m8 = rotation[8];
112
+ for (let index = 0; index < count; index++) {
113
+ gnomonicUnproject(VECTOR_, vec2Load(POINT_, input, index));
114
+ const x = VECTOR_[0];
115
+ const y = VECTOR_[1];
116
+ const z = VECTOR_[2];
117
+ out[3 * index] = m0 * x + m1 * y + m2 * z;
118
+ out[3 * index + 1] = m3 * x + m4 * y + m5 * z;
119
+ out[3 * index + 2] = m6 * x + m7 * y + m8 * z;
120
+ }
121
+ return out;
122
+ }
123
+ /**
124
+ * The plane distance from the centre of a point at angular distance `angle`:
125
+ * `tan(angle)`. `NaN` for an angle outside `[0, π / 2)`.
126
+ */
127
+ export function gnomonicRadius(angle) {
128
+ return angle >= 0 && angle < Math.PI / 2 ? Math.tan(angle) : Number.NaN;
129
+ }
130
+ /**
131
+ * The angular distance of a point at plane distance `radius`: `atan(radius)`,
132
+ * the inverse of {@link gnomonicRadius}. `NaN` for a negative or non-finite
133
+ * radius.
134
+ */
135
+ export function gnomonicAngle(radius) {
136
+ return radius >= 0 && radius < Number.POSITIVE_INFINITY
137
+ ? Math.atan(radius)
138
+ : Number.NaN;
139
+ }
140
+ //# sourceMappingURL=gnomonic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gnomonic.js","sourceRoot":"","sources":["../../src/azimuthal/gnomonic.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;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAW,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAS,EAAE,KAAmB;IAC7D,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACzC,GAAG,CAAC,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ACf,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./azimuthal-equal-area.js";
2
+ export * from "./azimuthal-equidistant.js";
3
+ export * from "./azimuthal-projection-kind.js";
4
+ export * from "./gnomonic.js";
5
+ export * from "./orthographic.js";
6
+ export * from "./stereographic.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/azimuthal/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./azimuthal-equal-area.js";
2
+ export * from "./azimuthal-equidistant.js";
3
+ export * from "./azimuthal-projection-kind.js";
4
+ export * from "./gnomonic.js";
5
+ export * from "./orthographic.js";
6
+ export * from "./stereographic.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/azimuthal/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { type ReadonlyMat3x3, type ReadonlyVec2, type ReadonlyVec3, type Vec2, type Vec3 } from "@ac-kit/math-linear";
2
+ /**
3
+ * The orthographic projection (Snyder, _Map Projections — A Working Manual_,
4
+ * 1987, §20, spherical form): the sphere seen from infinity, the point at
5
+ * angular distance `c` from the centre landing at plane distance `sin c`. On
6
+ * unit vectors in the canonical frame (centre `+X`, plane x east `+Y`, plane y
7
+ * north `+Z`) it is `(y, z)`, and only the hemisphere facing the viewer (`x ≥
8
+ * 0`) has an image; the far hemisphere gives `NaN`. The limb (`x = 0`) is the
9
+ * unit circle.
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: `π / 2`
16
+ * (inclusive, the limb).
17
+ */
18
+ export declare const ORTHOGRAPHIC_DOMAIN_ANGLE: number;
19
+ /**
20
+ * Writes the plane point of the unit vector `point` into `out`; `NaN` on the
21
+ * far hemisphere.
22
+ */
23
+ export declare function orthographicProject(out: Vec2, point: ReadonlyVec3): Vec2;
24
+ /**
25
+ * Writes the unit vector of the plane point `point` into `out`, on the facing
26
+ * hemisphere. A point outside the unit circle (a limb rounded by `2⁻⁵⁰` still
27
+ * counts) or with a non-finite coordinate gives `NaN`.
28
+ */
29
+ export declare function orthographicUnproject(out: Vec3, point: ReadonlyVec2): Vec3;
30
+ /**
31
+ * Rotates every unit vector of `input` (three numbers each) by `rotation`, then
32
+ * writes its plane point into `out` (two numbers each), in one pass: the sphere
33
+ * turns first, as for a view. `out` and `input` do not overlap. O(n).
34
+ *
35
+ * @returns `out`.
36
+ * @throws {RangeError} Unless `input` holds `n` vectors and `out` `n` points.
37
+ */
38
+ export declare function orthographicProjectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
39
+ /**
40
+ * Writes the unit vector of every plane point of `input` (two numbers each)
41
+ * into `out` (three numbers each), then turns it by the transpose of
42
+ * `rotation`: the inverse of {@link orthographicProjectArray}. O(n).
43
+ *
44
+ * @returns `out`.
45
+ * @throws {RangeError} Unless `input` holds `n` points and `out` `n` vectors.
46
+ */
47
+ export declare function orthographicUnprojectArray<T extends Float64Array>(out: T, input: Float64Array, rotation: ReadonlyMat3x3): T;
48
+ /**
49
+ * The plane distance from the centre of a point at angular distance `angle`:
50
+ * `sin(angle)`. `NaN` for an angle outside `[0, π / 2]`.
51
+ */
52
+ export declare function orthographicRadius(angle: number): number;
53
+ /**
54
+ * The angular distance of a point at plane distance `radius`: `asin(radius)`,
55
+ * the inverse of {@link orthographicRadius}. `NaN` for a radius outside `[0,
56
+ * 1]`.
57
+ */
58
+ export declare function orthographicAngle(radius: number): number;
59
+ //# sourceMappingURL=orthographic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orthographic.d.ts","sourceRoot":"","sources":["../../src/azimuthal/orthographic.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,IAAI,EAIT,MAAM,qBAAqB,CAAC;AAc7B;;;;;;;;;;;GAWG;AAEH;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAoB,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAOxE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAmB1E;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,YAAY,EAC9D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAwBH;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,YAAY,EAChE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,cAAc,GACtB,CAAC,CAqBH;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD"}