d3js-plugins-rails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/d3js-plugins-rails/version.rb +2 -1
- data/vendor/assets/javascripts/d3/plugins/Makefile +8 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/README.md +8 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/august.js +19 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/berghaus.js +14 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/bonne.js +1 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js +11 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js +3 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/craig.js +13 -7
- data/vendor/assets/javascripts/d3/plugins/geo/projection/eisenlohr.js +70 -9
- data/vendor/assets/javascripts/d3/plugins/geo/projection/elliptic.js +115 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/fahey.js +19 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/guyou.js +50 -36
- data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer-retroazimuthal.js +40 -11
- data/vendor/assets/javascripts/d3/plugins/geo/projection/lagrange.js +19 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/laskowski.js +3 -3
- data/vendor/assets/javascripts/d3/plugins/geo/projection/modified-stereographic.js +104 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/peirce-quincuncial.js +41 -5
- data/vendor/assets/javascripts/d3/plugins/geo/projection/polyconic.js +10 -6
- data/vendor/assets/javascripts/d3/plugins/geo/projection/projection.js +21 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/rectangular-polyconic.js +40 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/august-test.js +27 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/berghaus-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craig-test.js +26 -11
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/eisenlohr-test.js +34 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/env.js +5 -4
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/fahey-test.js +25 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/guyou-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hammer-retroazimuthal-test.js +39 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/lagrange-test.js +59 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/loximuthal-test.js +1 -1
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/modified-stereographic-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/peirce-quincuncial-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/polyconic-test.js +26 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/rectangular-polyconic-test.js +48 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/times-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/two-point-azimuthal-test.js +22 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/two-point-equidistant-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/van-der-grinten2-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/van-der-grinten3-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/van-der-grinten4-test.js +28 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/test/wiechel-test.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/times.js +19 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/two-point-azimuthal.js +46 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/two-point-equidistant.js +23 -5
- data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten2.js +28 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten3.js +24 -0
- data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten4.js +37 -5
- data/vendor/assets/javascripts/d3/plugins/geo/projection/wiechel.js +12 -0
- data/vendor/assets/javascripts/d3/plugins/graph/README.md +6 -7
- data/vendor/assets/javascripts/d3/plugins/graph/graph.js +0 -33
- data/vendor/assets/javascripts/d3/plugins/graph/index.html +0 -1
- data/vendor/assets/javascripts/d3/plugins/keybinding/keybinding.js +189 -112
- data/vendor/assets/javascripts/d3/plugins/longscroll/longscroll.js +3 -2
- metadata +29 -3
@@ -12,6 +12,7 @@ d3.geo.projection.js: \
|
|
12
12
|
geo/projection/parallel1.js \
|
13
13
|
geo/projection/parallel2.js \
|
14
14
|
geo/projection/interrupt.js \
|
15
|
+
geo/projection/elliptic.js \
|
15
16
|
geo/projection/aitoff.js \
|
16
17
|
geo/projection/guyou.js \
|
17
18
|
geo/projection/mollweide.js \
|
@@ -37,6 +38,7 @@ d3.geo.projection.js: \
|
|
37
38
|
geo/projection/eckert5.js \
|
38
39
|
geo/projection/eckert6.js \
|
39
40
|
geo/projection/eisenlohr.js \
|
41
|
+
geo/projection/fahey.js \
|
40
42
|
geo/projection/gringorten.js \
|
41
43
|
geo/projection/hammer-retroazimuthal.js \
|
42
44
|
geo/projection/hammer.js \
|
@@ -51,6 +53,7 @@ d3.geo.projection.js: \
|
|
51
53
|
geo/projection/littrow.js \
|
52
54
|
geo/projection/loximuthal.js \
|
53
55
|
geo/projection/miller.js \
|
56
|
+
geo/projection/modified-stereographic.js \
|
54
57
|
geo/projection/mt-flat-polar-parabolic.js \
|
55
58
|
geo/projection/mt-flat-polar-quartic.js \
|
56
59
|
geo/projection/mt-flat-polar-sinusoidal.js \
|
@@ -58,10 +61,15 @@ d3.geo.projection.js: \
|
|
58
61
|
geo/projection/nell-hammer.js \
|
59
62
|
geo/projection/peirce-quincuncial.js \
|
60
63
|
geo/projection/polyconic.js \
|
64
|
+
geo/projection/rectangular-polyconic.js \
|
61
65
|
geo/projection/robinson.js \
|
62
66
|
geo/projection/satellite.js \
|
67
|
+
geo/projection/times.js \
|
68
|
+
geo/projection/two-point-azimuthal.js \
|
63
69
|
geo/projection/two-point-equidistant.js \
|
64
70
|
geo/projection/van-der-grinten.js \
|
71
|
+
geo/projection/van-der-grinten2.js \
|
72
|
+
geo/projection/van-der-grinten3.js \
|
65
73
|
geo/projection/van-der-grinten4.js \
|
66
74
|
geo/projection/wagner4.js \
|
67
75
|
geo/projection/wagner6.js \
|
@@ -27,6 +27,7 @@ Projections:
|
|
27
27
|
* d3.geo.eckert6 - [Eckert VI](http://bl.ocks.org/3734329)
|
28
28
|
* d3.geo.eisenlohr - [Eisenlohr conformal](http://bl.ocks.org/3797585)
|
29
29
|
* d3.geo.equirectangular - [Equirectangular (Plate Carrée)](http://bl.ocks.org/3757119)
|
30
|
+
* d3.geo.fahey - [Fahey](http://bl.ocks.org/4731228)
|
30
31
|
* d3.geo.gnomonic - [gnomonic](http://bl.ocks.org/3757349)
|
31
32
|
* d3.geo.gringorten - [Gringorten](http://bl.ocks.org/3796882)
|
32
33
|
* d3.geo.guyou - [Guyou hemisphere-in-a-square](http://bl.ocks.org/3763867)
|
@@ -43,6 +44,7 @@ Projections:
|
|
43
44
|
* d3.geo.loximuthal - [loximuthal](http://bl.ocks.org/3867220)
|
44
45
|
* d3.geo.mercator - [Mercator](http://bl.ocks.org/3757132)
|
45
46
|
* d3.geo.miller - [Miller](http://bl.ocks.org/3734333)
|
47
|
+
* d3.geo.modifiedStereographic - Modified Stereographic
|
46
48
|
* d3.geo.mollweide - [Mollweide](http://bl.ocks.org/3734336), [Atlantis](http://bl.ocks.org/4519975)
|
47
49
|
* d3.geo.mtFlatPolarParabolic - [McBryde–Thomas flat-polar parabolic](http://bl.ocks.org/4465130)
|
48
50
|
* d3.geo.mtFlatPolarQuartic - [McBryde–Thomas flat-polar quartic](http://bl.ocks.org/4465137)
|
@@ -52,12 +54,18 @@ Projections:
|
|
52
54
|
* d3.geo.orthographic - [orthographic](http://bl.ocks.org/3757125)
|
53
55
|
* d3.geo.peirceQuincuncial - [Pierce quincuncial](http://bl.ocks.org/4310087)
|
54
56
|
* d3.geo.polyconic - [Polyconic](http://bl.ocks.org/3734343)
|
57
|
+
* d3.geo.rectangularPolyconic - Rectangular Polyconic
|
55
58
|
* d3.geo.robinson - [Robinson](http://bl.ocks.org/3710566)
|
56
59
|
* d3.geo.satellite - [satellite (tilted perpsective)](http://bl.ocks.org/3790444)
|
57
60
|
* d3.geo.sinusoidal - [sinusoidal](http://bl.ocks.org/3712399)
|
58
61
|
* d3.geo.sinuMollweide - [Sinu-Mollweide](http://bl.ocks.org/4319903)
|
59
62
|
* d3.geo.stereographic - [stereographic](http://bl.ocks.org/3757137)
|
63
|
+
* d3.geo.times - Times
|
64
|
+
* d3.geo.twoPointAzimuthal - Two-Point Azimuthal
|
65
|
+
* d3.geo.twoPointEquidistant - Two-Point Equidistant
|
60
66
|
* d3.geo.vanDerGrinten - [Van der Grinten](http://bl.ocks.org/3796831)
|
67
|
+
* d3.geo.vanDerGrinten2 - Van der Grinten II
|
68
|
+
* d3.geo.vanDerGrinten3 - Van der Grinten III
|
61
69
|
* d3.geo.vanDerGrinten4 - [Van der Grinten IV](http://bl.ocks.org/4489365)
|
62
70
|
* d3.geo.wagner4 - [Wagner IV, Putniṇš P2´](http://bl.ocks.org/4487674)
|
63
71
|
* d3.geo.wagner6 - [Wagner VI](http://bl.ocks.org/3710148)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
function august(λ, φ) {
|
2
2
|
var tanφ = Math.tan(φ / 2),
|
3
|
-
k = 1 - tanφ * tan
|
3
|
+
k = asqrt(1 - tanφ * tanφ),
|
4
4
|
c = 1 + k * Math.cos(λ /= 2),
|
5
5
|
x = Math.sin(λ) * k / c,
|
6
6
|
y = tanφ / c,
|
@@ -12,4 +12,22 @@ function august(λ, φ) {
|
|
12
12
|
];
|
13
13
|
}
|
14
14
|
|
15
|
+
august.invert = function(x, y) {
|
16
|
+
x *= 3 / 8, y *= 3 / 8;
|
17
|
+
if (!x && Math.abs(y) > 1) return null;
|
18
|
+
var x2 = x * x,
|
19
|
+
y2 = y * y,
|
20
|
+
s = 1 + x2 + y2,
|
21
|
+
sin3η = Math.sqrt(.5 * (s - Math.sqrt(s * s - 4 * y * y))),
|
22
|
+
η = asin(sin3η) / 3,
|
23
|
+
ξ = sin3η ? arcosh(Math.abs(y / sin3η)) / 3 : arsinh(Math.abs(x)) / 3,
|
24
|
+
cosη = Math.cos(η),
|
25
|
+
coshξ = cosh(ξ),
|
26
|
+
d = coshξ * coshξ - cosη * cosη;
|
27
|
+
return [
|
28
|
+
sgn(x) * 2 * Math.atan2(sinh(ξ) * cosη, .25 - d),
|
29
|
+
sgn(y) * 2 * Math.atan2(coshξ * Math.sin(η), .25 + d)
|
30
|
+
];
|
31
|
+
};
|
32
|
+
|
15
33
|
(d3.geo.august = function() { return projection(august); }).raw = august;
|
@@ -17,6 +17,20 @@ function berghaus(n) {
|
|
17
17
|
return p;
|
18
18
|
}
|
19
19
|
|
20
|
+
forward.invert = function(x, y) {
|
21
|
+
var r = Math.sqrt(x * x + y * y);
|
22
|
+
if (r > π / 2) {
|
23
|
+
var θ = Math.atan2(y, x),
|
24
|
+
θ0 = k * Math.round((θ - π / 2) / k) + π / 2,
|
25
|
+
s = θ > θ0 ? -1 : 1,
|
26
|
+
A = r * Math.cos(θ0 - θ)
|
27
|
+
cotα = 1 / Math.tan(s * Math.acos((A - π) / Math.sqrt(π * (π - 2 * A) + r * r)));
|
28
|
+
θ = θ0 + 2 * Math.atan((cotα + s * Math.sqrt(cotα * cotα - 3)) / 3);
|
29
|
+
x = r * Math.cos(θ), y = r * Math.sin(θ);
|
30
|
+
}
|
31
|
+
return berghausAzimuthalEquidistant.invert(x, y);
|
32
|
+
};
|
33
|
+
|
20
34
|
return forward;
|
21
35
|
}
|
22
36
|
|
@@ -3,9 +3,11 @@
|
|
3
3
|
function conicConformal(φ0, φ1) {
|
4
4
|
var cosφ0 = Math.cos(φ0),
|
5
5
|
t = function(φ) { return Math.tan(π / 4 + φ / 2); },
|
6
|
-
n = Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)),
|
6
|
+
n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)),
|
7
7
|
F = cosφ0 * Math.pow(t(φ0), n) / n;
|
8
8
|
|
9
|
+
if (!n) return conicConformalMercator;
|
10
|
+
|
9
11
|
function forward(λ, φ) {
|
10
12
|
var ρ = Math.abs(Math.abs(φ) - π / 2) < ε ? 0 : F / Math.pow(t(φ), n);
|
11
13
|
return [
|
@@ -26,4 +28,12 @@ function conicConformal(φ0, φ1) {
|
|
26
28
|
return forward;
|
27
29
|
}
|
28
30
|
|
31
|
+
function conicConformalMercator(λ, φ) {
|
32
|
+
return [λ, Math.log(Math.tan(π / 4 + φ / 2))];
|
33
|
+
}
|
34
|
+
|
35
|
+
conicConformalMercator.invert = function(x, y) {
|
36
|
+
return [x, 2 * Math.atan(Math.exp(y)) - π / 2];
|
37
|
+
};
|
38
|
+
|
29
39
|
(d3.geo.conicConformal = function() { return parallel2Projection(conicConformal); }).raw = conicConformal;
|
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
function conicEquidistant(φ0, φ1) {
|
4
4
|
var cosφ0 = Math.cos(φ0),
|
5
|
-
n = (cosφ0 - Math.cos(φ1)) / (φ1 - φ0),
|
5
|
+
n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0),
|
6
6
|
G = cosφ0 / n + φ0;
|
7
7
|
|
8
|
+
if (Math.abs(n) < ε) return d3.geo.equirectangular.raw;
|
9
|
+
|
8
10
|
function forward(λ, φ) {
|
9
11
|
var ρ = G - φ;
|
10
12
|
return [
|
@@ -10,13 +10,19 @@ function craig(φ0) {
|
|
10
10
|
];
|
11
11
|
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
forward.invert = tanφ0 ? function(x, y) {
|
14
|
+
if (x) y *= Math.sin(x) / x;
|
15
|
+
var cosλ = Math.cos(x);
|
16
|
+
return [
|
17
|
+
x,
|
18
|
+
2 * Math.atan2(Math.sqrt(cosλ * cosλ + tanφ0 * tanφ0 - y * y) - cosλ, tanφ0 - y)
|
19
|
+
];
|
20
|
+
} : function(x, y) {
|
21
|
+
return [
|
22
|
+
x,
|
23
|
+
asin(x ? y * Math.tan(x) / x : y)
|
24
|
+
];
|
25
|
+
};
|
20
26
|
|
21
27
|
return forward;
|
22
28
|
}
|
@@ -1,16 +1,77 @@
|
|
1
|
+
// @import august
|
2
|
+
|
1
3
|
function eisenlohr(λ, φ) {
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
t = Math.sin(φ) / (cosφ2 + 2 * c1 * k),
|
4
|
+
var s0 = Math.sin(λ /= 2),
|
5
|
+
c0 = Math.cos(λ),
|
6
|
+
k = Math.sqrt(Math.cos(φ)),
|
7
|
+
c1 = Math.cos(φ /= 2),
|
8
|
+
t = Math.sin(φ) / (c1 + Math.SQRT2 * c0 * k),
|
8
9
|
c = Math.sqrt(2 / (1 + t * t)),
|
9
|
-
v = Math.sqrt((
|
10
|
+
v = Math.sqrt((Math.SQRT2 * c1 + (c0 + s0) * k) / (Math.SQRT2 * c1 + (c0 - s0) * k));
|
10
11
|
return [
|
11
|
-
|
12
|
-
|
12
|
+
eisenlohrK * (c * (v - 1 / v) - 2 * Math.log(v)),
|
13
|
+
eisenlohrK * (c * t * (v + 1 / v) - 2 * Math.atan(t))
|
13
14
|
];
|
14
15
|
}
|
15
16
|
|
17
|
+
eisenlohr.invert = function(x, y) {
|
18
|
+
var p = d3.geo.august.raw.invert(x / 1.2, y * 1.065);
|
19
|
+
if (!p) return null;
|
20
|
+
var λ = p[0],
|
21
|
+
φ = p[1],
|
22
|
+
i = 20;
|
23
|
+
x /= eisenlohrK, y /= eisenlohrK;
|
24
|
+
do {
|
25
|
+
var _0 = λ / 2,
|
26
|
+
_1 = φ / 2,
|
27
|
+
s0 = Math.sin(_0),
|
28
|
+
c0 = Math.cos(_0),
|
29
|
+
s1 = Math.sin(_1),
|
30
|
+
c1 = Math.cos(_1),
|
31
|
+
cos1 = Math.cos(φ),
|
32
|
+
|
33
|
+
k = Math.sqrt(cos1),
|
34
|
+
t = s1 / (c1 + Math.SQRT2 * c0 * k),
|
35
|
+
t2 = t * t,
|
36
|
+
c = Math.sqrt(2 / (1 + t2)),
|
37
|
+
v0 = (Math.SQRT2 * c1 + (c0 + s0) * k),
|
38
|
+
v1 = (Math.SQRT2 * c1 + (c0 - s0) * k),
|
39
|
+
v2 = v0 / v1,
|
40
|
+
v = Math.sqrt(v2),
|
41
|
+
vm1v = v - 1 / v,
|
42
|
+
vp1v = v + 1 / v,
|
43
|
+
|
44
|
+
fx = c * vm1v - 2 * Math.log(v) - x,
|
45
|
+
fy = c * t * vp1v - 2 * Math.atan(t) - y,
|
46
|
+
|
47
|
+
δtδλ = s1 && Math.SQRT1_2 * k * s0 * t2 / s1,
|
48
|
+
δtδφ = (Math.SQRT2 * c0 * c1 + k) / (2 * (c1 + Math.SQRT2 * c0 * k) * (c1 + Math.SQRT2 * c0 * k) * k),
|
49
|
+
|
50
|
+
δcδt = -.5 * t * c * c * c,
|
51
|
+
δcδλ = δcδt * δtδλ,
|
52
|
+
δcδφ = δcδt * δtδφ,
|
53
|
+
|
54
|
+
A = (A = 2 * c1 + Math.SQRT2 * k * (c0 - s0)) * A * v,
|
55
|
+
δvδλ = (Math.SQRT2 * c0 * c1 * k + cos1) / A,
|
56
|
+
δvδφ = -(Math.SQRT2 * s0 * s1) / (k * A),
|
57
|
+
|
58
|
+
δxδλ = vm1v * δcδλ - 2 * δvδλ / v + c * (δvδλ + δvδλ / v2),
|
59
|
+
δxδφ = vm1v * δcδφ - 2 * δvδφ / v + c * (δvδφ + δvδφ / v2),
|
60
|
+
δyδλ = t * vp1v * δcδλ - 2 * δtδλ / (1 + t2) + c * vp1v * δtδλ + c * t * (δvδλ - δvδλ / v2),
|
61
|
+
δyδφ = t * vp1v * δcδφ - 2 * δtδφ / (1 + t2) + c * vp1v * δtδφ + c * t * (δvδφ - δvδφ / v2),
|
62
|
+
|
63
|
+
denominator = δxδφ * δyδλ - δyδφ * δxδλ;
|
64
|
+
if (!denominator) break;
|
65
|
+
var δλ = (fy * δxδφ - fx * δyδφ) / denominator,
|
66
|
+
δφ = (fx * δyδλ - fy * δxδλ) / denominator;
|
67
|
+
λ -= δλ;
|
68
|
+
φ = Math.max(-π / 2, Math.min(π / 2, φ - δφ));
|
69
|
+
} while ((Math.abs(δλ) > ε || Math.abs(δφ) > ε) && --i > 0);
|
70
|
+
return Math.abs(Math.abs(φ) - π / 2) < ε
|
71
|
+
? [0, φ]
|
72
|
+
: i && [λ, φ];
|
73
|
+
};
|
74
|
+
|
75
|
+
var eisenlohrK = 3 + 2 * Math.SQRT2;
|
76
|
+
|
16
77
|
(d3.geo.eisenlohr = function() { return projection(eisenlohr); }).raw = eisenlohr;
|
@@ -0,0 +1,115 @@
|
|
1
|
+
// Returns [sn, cn, dn](u + iv|m).
|
2
|
+
function ellipticJi(u, v, m) {
|
3
|
+
if (!u) {
|
4
|
+
var b = ellipticJ(v, 1 - m);
|
5
|
+
return [
|
6
|
+
[0, b[0] / b[1]],
|
7
|
+
[1 / b[1], 0],
|
8
|
+
[b[2] / b[1], 0]
|
9
|
+
];
|
10
|
+
}
|
11
|
+
var a = ellipticJ(u, m);
|
12
|
+
if (!v) return [[a[0], 0], [a[1], 0], [a[2], 0]];
|
13
|
+
var b = ellipticJ(v, 1 - m),
|
14
|
+
denominator = b[1] * b[1] + m * a[0] * a[0] * b[0] * b[0];
|
15
|
+
return [
|
16
|
+
[a[0] * b[2] / denominator, a[1] * a[2] * b[0] * b[1] / denominator],
|
17
|
+
[a[1] * b[1] / denominator, -a[0] * a[2] * b[0] * b[2] / denominator],
|
18
|
+
[a[2] * b[1] * b[2] / denominator, -m * a[0] * a[1] * b[0] / denominator]
|
19
|
+
];
|
20
|
+
}
|
21
|
+
|
22
|
+
// Returns [sn, cn, dn, ph](u|m).
|
23
|
+
function ellipticJ(u, m) {
|
24
|
+
var ai, b, φ, t, twon;
|
25
|
+
if (m < ε) {
|
26
|
+
t = Math.sin(u);
|
27
|
+
b = Math.cos(u);
|
28
|
+
ai = .25 * m * (u - t * b);
|
29
|
+
return [
|
30
|
+
t - ai * b,
|
31
|
+
b + ai * t,
|
32
|
+
1 - .5 * m * t * t,
|
33
|
+
u - ai
|
34
|
+
];
|
35
|
+
}
|
36
|
+
if (m >= 1 - ε) {
|
37
|
+
ai = .25 * (1 - m);
|
38
|
+
b = cosh(u);
|
39
|
+
t = tanh(u);
|
40
|
+
φ = 1 / b;
|
41
|
+
twon = b * sinh(u);
|
42
|
+
return [
|
43
|
+
t + ai * (twon - u) / (b * b),
|
44
|
+
φ - ai * t * φ * (twon - u),
|
45
|
+
φ + ai * t * φ * (twon + u),
|
46
|
+
2 * Math.atan(Math.exp(u)) - π / 2 + ai * (twon - u) / b
|
47
|
+
];
|
48
|
+
}
|
49
|
+
|
50
|
+
var a = [1, 0, 0, 0, 0, 0, 0, 0, 0],
|
51
|
+
c = [Math.sqrt(m), 0, 0, 0, 0, 0, 0, 0, 0],
|
52
|
+
i = 0;
|
53
|
+
b = Math.sqrt(1 - m);
|
54
|
+
twon = 1;
|
55
|
+
|
56
|
+
while (Math.abs(c[i] / a[i]) > ε && i < 8) {
|
57
|
+
ai = a[i++];
|
58
|
+
c[i] = .5 * (ai - b);
|
59
|
+
a[i] = .5 * (ai + b);
|
60
|
+
b = asqrt(ai * b);
|
61
|
+
twon *= 2;
|
62
|
+
}
|
63
|
+
|
64
|
+
φ = twon * a[i] * u;
|
65
|
+
do {
|
66
|
+
t = c[i] * Math.sin(b = φ) / a[i];
|
67
|
+
φ = .5 * (asin(t) + φ);
|
68
|
+
} while (--i);
|
69
|
+
|
70
|
+
return [Math.sin(φ), t = Math.cos(φ), t / Math.cos(φ - b), φ];
|
71
|
+
}
|
72
|
+
|
73
|
+
// Calculate F(φ+iψ|m).
|
74
|
+
// See Abramowitz and Stegun, 17.4.11.
|
75
|
+
function ellipticFi(φ, ψ, m) {
|
76
|
+
var r = Math.abs(φ),
|
77
|
+
i = Math.abs(ψ),
|
78
|
+
sinhψ = sinh(i);
|
79
|
+
if (r) {
|
80
|
+
var cscφ = 1 / Math.sin(r),
|
81
|
+
cotφ2 = 1 / (Math.tan(r) * Math.tan(r)),
|
82
|
+
b = -(cotφ2 + m * (sinhψ * sinhψ * cscφ * cscφ) - 1 + m),
|
83
|
+
c = (m - 1) * cotφ2,
|
84
|
+
cotλ2 = .5 * (-b + Math.sqrt(b * b - 4 * c));
|
85
|
+
return [
|
86
|
+
ellipticF(Math.atan(1 / Math.sqrt(cotλ2)), m) * sgn(φ),
|
87
|
+
ellipticF(Math.atan(asqrt((cotλ2 / cotφ2 - 1) / m)), 1 - m) * sgn(ψ)
|
88
|
+
];
|
89
|
+
}
|
90
|
+
return [
|
91
|
+
0,
|
92
|
+
ellipticF(Math.atan(sinhψ), 1 - m) * sgn(ψ)
|
93
|
+
];
|
94
|
+
}
|
95
|
+
|
96
|
+
// Calculate F(φ|m) where m = k² = sin²α.
|
97
|
+
// See Abramowitz and Stegun, 17.6.7.
|
98
|
+
function ellipticF(φ, m) {
|
99
|
+
if (!m) return φ;
|
100
|
+
if (m === 1) return Math.log(Math.tan(φ / 2 + π / 4));
|
101
|
+
var a = 1,
|
102
|
+
b = Math.sqrt(1 - m),
|
103
|
+
c = Math.sqrt(m);
|
104
|
+
for (var i = 0; Math.abs(c) > ε; i++) {
|
105
|
+
if (φ % π) {
|
106
|
+
var dφ = Math.atan(b * Math.tan(φ) / a);
|
107
|
+
if (dφ < 0) dφ += π;
|
108
|
+
φ += dφ + ~~(φ / π) * π;
|
109
|
+
} else φ += φ;
|
110
|
+
c = (a + b) / 2;
|
111
|
+
b = Math.sqrt(a * b);
|
112
|
+
c = ((a = c) - b) / 2;
|
113
|
+
}
|
114
|
+
return φ / (Math.pow(2, i) * a);
|
115
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
function fahey(λ, φ) {
|
2
|
+
var t = Math.tan(φ / 2);
|
3
|
+
return [
|
4
|
+
λ * faheyK * asqrt(1 - t * t),
|
5
|
+
(1 + faheyK) * t
|
6
|
+
];
|
7
|
+
}
|
8
|
+
|
9
|
+
fahey.invert = function(x, y) {
|
10
|
+
var t = y / (1 + faheyK);
|
11
|
+
return [
|
12
|
+
x ? x / (faheyK * asqrt(1 - t * t)) : 0,
|
13
|
+
2 * Math.atan(t)
|
14
|
+
];
|
15
|
+
};
|
16
|
+
|
17
|
+
var faheyK = Math.cos(35 * radians);
|
18
|
+
|
19
|
+
(d3.geo.fahey = function() { return projection(fahey); }).raw = fahey;
|
@@ -1,46 +1,60 @@
|
|
1
|
+
// @import elliptic
|
2
|
+
|
3
|
+
// √k' tn(½K - w) = exp(-ζ).
|
1
4
|
function guyou(λ, φ) {
|
2
|
-
|
5
|
+
|
6
|
+
var k_ = (Math.SQRT2 - 1) / (Math.SQRT2 + 1),
|
7
|
+
k = Math.sqrt(1 - k_ * k_),
|
8
|
+
K = ellipticF(π / 2, k * k),
|
9
|
+
f = -1;
|
10
|
+
|
11
|
+
var s = λ > 0 ? -1 : 1;
|
12
|
+
λ += s * π / 2;
|
13
|
+
|
14
|
+
var ψ = Math.log(Math.tan(π / 4 + Math.abs(φ) / 2)),
|
15
|
+
r = Math.exp(f * ψ) / Math.sqrt(k_),
|
16
|
+
at = guyouComplexAtan(r * Math.cos(f * λ), r * Math.sin(f * λ)),
|
17
|
+
t = ellipticFi(at[0], at[1], k * k);
|
18
|
+
|
19
|
+
return [-s * .5 * K - t[1], sgn(φ) * (.5 * K - t[0])];
|
3
20
|
}
|
4
21
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
i = Math.abs(ψ),
|
10
|
-
sinhψ = .5 * ((sinhψ = Math.exp(i)) - 1 / sinhψ);
|
11
|
-
if (r) {
|
12
|
-
var cscφ = 1 / Math.sin(r),
|
13
|
-
cotφ2 = (cotφ2 = Math.cos(r) * cscφ) * cotφ2,
|
14
|
-
b = -(cotφ2 + m * (sinhψ * sinhψ * cscφ * cscφ + 1) - 1),
|
15
|
-
cotλ2 = .5 * (-b + Math.sqrt(b * b - 4 * (m - 1) * cotφ2));
|
16
|
-
return [
|
17
|
-
guyouEllipticF(Math.atan(1 / Math.sqrt(cotλ2)), m) * sgn(φ),
|
18
|
-
guyouEllipticF(Math.atan(Math.sqrt(cotλ2 / cotφ2 - 1) / m), 1 - m) * sgn(ψ)
|
19
|
-
];
|
20
|
-
}
|
22
|
+
function guyouComplexAtan(x, y) {
|
23
|
+
var x2 = x * x,
|
24
|
+
y_1 = y + 1,
|
25
|
+
t = 1 - x2 - y * y;
|
21
26
|
return [
|
22
|
-
|
23
|
-
|
27
|
+
sgn(x) * π / 4 - .5 * Math.atan2(t, 2 * x),
|
28
|
+
-.25 * Math.log(t * t + 4 * x2) + .5 * Math.log(y_1 * y_1 + x2)
|
24
29
|
];
|
25
30
|
}
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
for (var i = 0; Math.abs(c) > ε; i++) {
|
34
|
-
if (φ % π) {
|
35
|
-
var dφ = Math.atan(b * Math.tan(φ) / a);
|
36
|
-
if (dφ < 0) dφ += π;
|
37
|
-
φ += dφ + ~~(φ / π) * π;
|
38
|
-
} else φ += φ;
|
39
|
-
c = (a + b) / 2;
|
40
|
-
b = Math.sqrt(a * b);
|
41
|
-
c = ((a = c) - b) / 2;
|
42
|
-
}
|
43
|
-
return φ / (Math.pow(2, i) * a);
|
32
|
+
function guyouComplexDivide(a, b) {
|
33
|
+
var denominator = b[0] * b[0] + b[1] * b[1];
|
34
|
+
return [
|
35
|
+
(a[0] * b[0] + a[1] * b[1]) / denominator,
|
36
|
+
(a[1] * b[0] - a[0] * b[1]) / denominator
|
37
|
+
];
|
44
38
|
}
|
45
39
|
|
40
|
+
guyou.invert = function(x, y) {
|
41
|
+
var k_ = (Math.SQRT2 - 1) / (Math.SQRT2 + 1),
|
42
|
+
k = Math.sqrt(1 - k_ * k_),
|
43
|
+
K = ellipticF(π / 2, k * k),
|
44
|
+
f = -1;
|
45
|
+
|
46
|
+
var s = x > 0 ? -1 : 1;
|
47
|
+
|
48
|
+
var j = ellipticJi(.5 * K - y, -s * .5 * K - x, k * k),
|
49
|
+
tn = guyouComplexDivide(j[0], j[1]),
|
50
|
+
λ = Math.atan2(tn[1], tn[0]) / f - s * π / 2;
|
51
|
+
if (λ < -π) λ += 2 * π;
|
52
|
+
else if (λ > π) λ -= 2 * π;
|
53
|
+
|
54
|
+
return [
|
55
|
+
λ,
|
56
|
+
2 * Math.atan(Math.exp(.5 / f * Math.log(k_ * tn[0] * tn[0] + k_ * tn[1] * tn[1]))) - π / 2
|
57
|
+
];
|
58
|
+
};
|
59
|
+
|
46
60
|
(d3.geo.guyou = function() { return projection(guyou); }).raw = guyou;
|