d3js-plugins-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +1 -0
  6. data/d3js-plugins-rails.gemspec +21 -0
  7. data/lib/d3js-plugins-rails/version.rb +7 -0
  8. data/lib/d3js-plugins-rails.rb +10 -0
  9. data/vendor/assets/javascripts/d3/plugins/.gitignore +1 -0
  10. data/vendor/assets/javascripts/d3/plugins/LICENSE +26 -0
  11. data/vendor/assets/javascripts/d3/plugins/Makefile +87 -0
  12. data/vendor/assets/javascripts/d3/plugins/README.md +19 -0
  13. data/vendor/assets/javascripts/d3/plugins/box/box.js +301 -0
  14. data/vendor/assets/javascripts/d3/plugins/bullet/README.md +14 -0
  15. data/vendor/assets/javascripts/d3/plugins/bullet/bullet.js +241 -0
  16. data/vendor/assets/javascripts/d3/plugins/chernoff/README.md +15 -0
  17. data/vendor/assets/javascripts/d3/plugins/chernoff/chernoff.js +176 -0
  18. data/vendor/assets/javascripts/d3/plugins/cie/README.md +54 -0
  19. data/vendor/assets/javascripts/d3/plugins/cie/cie.js +155 -0
  20. data/vendor/assets/javascripts/d3/plugins/fisheye/README.md +43 -0
  21. data/vendor/assets/javascripts/d3/plugins/fisheye/fisheye.js +85 -0
  22. data/vendor/assets/javascripts/d3/plugins/force_labels/README.md +29 -0
  23. data/vendor/assets/javascripts/d3/plugins/force_labels/force_labels.js +56 -0
  24. data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/README.md +7 -0
  25. data/vendor/assets/javascripts/d3/plugins/geo/polyhedron/polyhedron.js +436 -0
  26. data/vendor/assets/javascripts/d3/plugins/geo/projection/README.md +107 -0
  27. data/vendor/assets/javascripts/d3/plugins/geo/projection/aitoff.js +40 -0
  28. data/vendor/assets/javascripts/d3/plugins/geo/projection/armadillo.js +79 -0
  29. data/vendor/assets/javascripts/d3/plugins/geo/projection/august.js +15 -0
  30. data/vendor/assets/javascripts/d3/plugins/geo/projection/baker.js +28 -0
  31. data/vendor/assets/javascripts/d3/plugins/geo/projection/berghaus.js +60 -0
  32. data/vendor/assets/javascripts/d3/plugins/geo/projection/boggs.js +27 -0
  33. data/vendor/assets/javascripts/d3/plugins/geo/projection/bonne.js +29 -0
  34. data/vendor/assets/javascripts/d3/plugins/geo/projection/bromley.js +5 -0
  35. data/vendor/assets/javascripts/d3/plugins/geo/projection/collignon.js +17 -0
  36. data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-conformal.js +29 -0
  37. data/vendor/assets/javascripts/d3/plugins/geo/projection/conic-equidistant.js +27 -0
  38. data/vendor/assets/javascripts/d3/plugins/geo/projection/craig.js +24 -0
  39. data/vendor/assets/javascripts/d3/plugins/geo/projection/craster.js +18 -0
  40. data/vendor/assets/javascripts/d3/plugins/geo/projection/cylindrical-equal-area.js +23 -0
  41. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert1.js +18 -0
  42. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert2.js +17 -0
  43. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert3.js +17 -0
  44. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert4.js +24 -0
  45. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert5.js +17 -0
  46. data/vendor/assets/javascripts/d3/plugins/geo/projection/eckert6.js +22 -0
  47. data/vendor/assets/javascripts/d3/plugins/geo/projection/eisenlohr.js +16 -0
  48. data/vendor/assets/javascripts/d3/plugins/geo/projection/end.js +1 -0
  49. data/vendor/assets/javascripts/d3/plugins/geo/projection/gringorten.js +111 -0
  50. data/vendor/assets/javascripts/d3/plugins/geo/projection/guyou.js +46 -0
  51. data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer-retroazimuthal.js +75 -0
  52. data/vendor/assets/javascripts/d3/plugins/geo/projection/hammer.js +51 -0
  53. data/vendor/assets/javascripts/d3/plugins/geo/projection/hatano.js +25 -0
  54. data/vendor/assets/javascripts/d3/plugins/geo/projection/healpix.js +64 -0
  55. data/vendor/assets/javascripts/d3/plugins/geo/projection/hill.js +64 -0
  56. data/vendor/assets/javascripts/d3/plugins/geo/projection/homolosine.js +17 -0
  57. data/vendor/assets/javascripts/d3/plugins/geo/projection/interrupt.js +111 -0
  58. data/vendor/assets/javascripts/d3/plugins/geo/projection/kavrayskiy7.js +15 -0
  59. data/vendor/assets/javascripts/d3/plugins/geo/projection/lagrange.js +27 -0
  60. data/vendor/assets/javascripts/d3/plugins/geo/projection/larrivee.js +39 -0
  61. data/vendor/assets/javascripts/d3/plugins/geo/projection/laskowski.js +31 -0
  62. data/vendor/assets/javascripts/d3/plugins/geo/projection/littrow.js +21 -0
  63. data/vendor/assets/javascripts/d3/plugins/geo/projection/loximuthal.js +29 -0
  64. data/vendor/assets/javascripts/d3/plugins/geo/projection/miller.js +15 -0
  65. data/vendor/assets/javascripts/d3/plugins/geo/projection/mollweide.js +35 -0
  66. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-parabolic.js +21 -0
  67. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-quartic.js +23 -0
  68. data/vendor/assets/javascripts/d3/plugins/geo/projection/mt-flat-polar-sinusoidal.js +25 -0
  69. data/vendor/assets/javascripts/d3/plugins/geo/projection/natural-earth.js +22 -0
  70. data/vendor/assets/javascripts/d3/plugins/geo/projection/nell-hammer.js +20 -0
  71. data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel1.js +12 -0
  72. data/vendor/assets/javascripts/d3/plugins/geo/projection/parallel2.js +13 -0
  73. data/vendor/assets/javascripts/d3/plugins/geo/projection/peirce-quincuncial.js +14 -0
  74. data/vendor/assets/javascripts/d3/plugins/geo/projection/polyconic.js +25 -0
  75. data/vendor/assets/javascripts/d3/plugins/geo/projection/projection.js +29 -0
  76. data/vendor/assets/javascripts/d3/plugins/geo/projection/robinson.js +83 -0
  77. data/vendor/assets/javascripts/d3/plugins/geo/projection/satellite.js +68 -0
  78. data/vendor/assets/javascripts/d3/plugins/geo/projection/sinu-mollweide.js +19 -0
  79. data/vendor/assets/javascripts/d3/plugins/geo/projection/sinusoidal.js +15 -0
  80. data/vendor/assets/javascripts/d3/plugins/geo/projection/start.js +1 -0
  81. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/aitoff-test.js +26 -0
  82. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/armadillo-test.js +28 -0
  83. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/baker-test.js +26 -0
  84. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/boggs-test.js +26 -0
  85. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/bonne-test.js +45 -0
  86. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craig-test.js +25 -0
  87. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/craster-test.js +25 -0
  88. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/env.js +32 -0
  89. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/equirectangular-test.js +97 -0
  90. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hammer-test.js +29 -0
  91. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hatano-test.js +25 -0
  92. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/hill-test.js +26 -0
  93. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/larrivee-test.js +25 -0
  94. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/laskowski-test.js +26 -0
  95. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/littrow-test.js +24 -0
  96. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/loximuthal-test.js +25 -0
  97. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mollweide-test.js +26 -0
  98. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-parabolic-test.js +25 -0
  99. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-quartic-test.js +25 -0
  100. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/mt-flat-polar-sinusoidal-test.js +25 -0
  101. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/natural-earth-test.js +26 -0
  102. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/quartic-authalic-test.js +0 -0
  103. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/robinson-test.js +26 -0
  104. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/wagner6-test.js +25 -0
  105. data/vendor/assets/javascripts/d3/plugins/geo/projection/test/winkel3-test.js +26 -0
  106. data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten.js +41 -0
  107. data/vendor/assets/javascripts/d3/plugins/geo/projection/van-der-grinten4.js +22 -0
  108. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner4.js +9 -0
  109. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner6.js +15 -0
  110. data/vendor/assets/javascripts/d3/plugins/geo/projection/wagner7.js +22 -0
  111. data/vendor/assets/javascripts/d3/plugins/geo/projection/wiechel.js +14 -0
  112. data/vendor/assets/javascripts/d3/plugins/geo/projection/winkel3.js +40 -0
  113. data/vendor/assets/javascripts/d3/plugins/geo/tile/README.md +6 -0
  114. data/vendor/assets/javascripts/d3/plugins/geo/tile/tile.js +53 -0
  115. data/vendor/assets/javascripts/d3/plugins/geodesic/README.md +3 -0
  116. data/vendor/assets/javascripts/d3/plugins/geodesic/geodesic.js +130 -0
  117. data/vendor/assets/javascripts/d3/plugins/geom/contour/README.md +5 -0
  118. data/vendor/assets/javascripts/d3/plugins/geom/contour/contour.js +72 -0
  119. data/vendor/assets/javascripts/d3/plugins/graph/README.md +148 -0
  120. data/vendor/assets/javascripts/d3/plugins/graph/data/cities-matrix.json +37 -0
  121. data/vendor/assets/javascripts/d3/plugins/graph/data/cities.csv +36 -0
  122. data/vendor/assets/javascripts/d3/plugins/graph/data/miserables.json +338 -0
  123. data/vendor/assets/javascripts/d3/plugins/graph/graph.js +161 -0
  124. data/vendor/assets/javascripts/d3/plugins/graph/index.html +37 -0
  125. data/vendor/assets/javascripts/d3/plugins/hexbin/README.md +58 -0
  126. data/vendor/assets/javascripts/d3/plugins/hexbin/hexbin.js +96 -0
  127. data/vendor/assets/javascripts/d3/plugins/hive/README.md +5 -0
  128. data/vendor/assets/javascripts/d3/plugins/hive/hive.js +80 -0
  129. data/vendor/assets/javascripts/d3/plugins/horizon/README.md +11 -0
  130. data/vendor/assets/javascripts/d3/plugins/horizon/horizon.js +192 -0
  131. data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/README.md +11 -0
  132. data/vendor/assets/javascripts/d3/plugins/interpolate-zoom/interpolate-zoom.js +75 -0
  133. data/vendor/assets/javascripts/d3/plugins/jsonp/README.md +26 -0
  134. data/vendor/assets/javascripts/d3/plugins/jsonp/jsonp.js +25 -0
  135. data/vendor/assets/javascripts/d3/plugins/keybinding/README.md +17 -0
  136. data/vendor/assets/javascripts/d3/plugins/keybinding/keybinding.js +120 -0
  137. data/vendor/assets/javascripts/d3/plugins/longscroll/README.md +10 -0
  138. data/vendor/assets/javascripts/d3/plugins/longscroll/longscroll.js +75 -0
  139. data/vendor/assets/javascripts/d3/plugins/package.json +20 -0
  140. data/vendor/assets/javascripts/d3/plugins/qq/README.md +3 -0
  141. data/vendor/assets/javascripts/d3/plugins/qq/qq.js +249 -0
  142. data/vendor/assets/javascripts/d3/plugins/rollup/README.md +5 -0
  143. data/vendor/assets/javascripts/d3/plugins/rollup/rollup.js +131 -0
  144. data/vendor/assets/javascripts/d3/plugins/sankey/README.md +17 -0
  145. data/vendor/assets/javascripts/d3/plugins/sankey/sankey.js +292 -0
  146. data/vendor/assets/javascripts/d3/plugins/simplify/README.md +6 -0
  147. data/vendor/assets/javascripts/d3/plugins/simplify/simplify-test.js +193 -0
  148. data/vendor/assets/javascripts/d3/plugins/simplify/simplify.js +446 -0
  149. data/vendor/assets/javascripts/d3/plugins/superformula/superformula.js +98 -0
  150. data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode-test.js +68 -0
  151. data/vendor/assets/javascripts/d3/plugins/urlencode/urlencode.js +37 -0
  152. metadata +218 -0
@@ -0,0 +1,27 @@
1
+ // @import parallel2
2
+
3
+ function conicEquidistant(φ0, φ1) {
4
+ var cosφ0 = Math.cos(φ0),
5
+ n = (cosφ0 - Math.cos(φ1)) / (φ1 - φ0),
6
+ G = cosφ0 / n + φ0;
7
+
8
+ function forward(λ, φ) {
9
+ var ρ = G - φ;
10
+ return [
11
+ ρ * Math.sin(n * λ),
12
+ G - ρ * Math.cos(n * λ)
13
+ ];
14
+ }
15
+
16
+ forward.invert = function(x, y) {
17
+ var ρ0_y = G - y;
18
+ return [
19
+ Math.atan2(x, ρ0_y) / n,
20
+ G - sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y)
21
+ ];
22
+ };
23
+
24
+ return forward;
25
+ }
26
+
27
+ (d3.geo.conicEquidistant = function() { return parallel2Projection(conicEquidistant); }).raw = conicEquidistant;
@@ -0,0 +1,24 @@
1
+ // @import parallel1
2
+
3
+ function craig(φ0) {
4
+ var tanφ0 = Math.tan(φ0);
5
+
6
+ function forward(λ, φ) {
7
+ return [
8
+ λ,
9
+ (λ ? λ / Math.sin(λ) : 1) * (Math.sin(φ) * Math.cos(λ) - tanφ0 * Math.cos(φ))
10
+ ];
11
+ }
12
+
13
+ // TODO
14
+ // forward.invert = function(x, y) {
15
+ // return [
16
+ // x,
17
+ // asin(y * (x ? Math.tan(x) / x : 1))
18
+ // ];
19
+ // };
20
+
21
+ return forward;
22
+ }
23
+
24
+ (d3.geo.craig = function() { return parallel1Projection(craig); }).raw = craig;
@@ -0,0 +1,18 @@
1
+ function craster(λ, φ) {
2
+ var sqrt3 = Math.sqrt(3);
3
+ return [
4
+ sqrt3 * λ * (2 * Math.cos(2 * φ / 3) - 1) / sqrtπ,
5
+ sqrt3 * sqrtπ * Math.sin(φ / 3)
6
+ ];
7
+ }
8
+
9
+ craster.invert = function(x, y) {
10
+ var sqrt3 = Math.sqrt(3),
11
+ φ = 3 * asin(y / (sqrt3 * sqrtπ));
12
+ return [
13
+ sqrtπ * x / (sqrt3 * (2 * Math.cos(2 * φ / 3) - 1)),
14
+ φ
15
+ ];
16
+ };
17
+
18
+ (d3.geo.craster = function() { return projection(craster); }).raw = craster;
@@ -0,0 +1,23 @@
1
+ // @import parallel1
2
+
3
+ function cylindricalEqualArea(φ0) {
4
+ var cosφ0 = Math.cos(φ0);
5
+
6
+ function forward(λ, φ) {
7
+ return [
8
+ λ * cosφ0,
9
+ Math.sin(φ) / cosφ0
10
+ ];
11
+ }
12
+
13
+ forward.invert = function(x, y) {
14
+ return [
15
+ x / cosφ0,
16
+ asin(y * cosφ0)
17
+ ];
18
+ };
19
+
20
+ return forward;
21
+ }
22
+
23
+ (d3.geo.cylindricalEqualArea = function() { return parallel1Projection(cylindricalEqualArea); }).raw = cylindricalEqualArea;
@@ -0,0 +1,18 @@
1
+ function eckert1(λ, φ) {
2
+ var α = Math.sqrt(8 / (3 * π));
3
+ return [
4
+ α * λ * (1 - Math.abs(φ) / π),
5
+ α * φ
6
+ ];
7
+ }
8
+
9
+ eckert1.invert = function(x, y) {
10
+ var α = Math.sqrt(8 / (3 * π)),
11
+ φ = y / α;
12
+ return [
13
+ x / (α * (1 - Math.abs(φ) / π)),
14
+ φ
15
+ ];
16
+ };
17
+
18
+ (d3.geo.eckert1 = function() { return projection(eckert1); }).raw = eckert1;
@@ -0,0 +1,17 @@
1
+ function eckert2(λ, φ) {
2
+ var α = Math.sqrt(4 - 3 * Math.sin(Math.abs(φ)));
3
+ return [
4
+ 2 / Math.sqrt(6 * π) * λ * α,
5
+ sgn(φ) * Math.sqrt(2 * π / 3) * (2 - α)
6
+ ];
7
+ }
8
+
9
+ eckert2.invert = function(x, y) {
10
+ var α = 2 - Math.abs(y) / Math.sqrt(2 * π / 3);
11
+ return [
12
+ x * Math.sqrt(6 * π) / (2 * α),
13
+ sgn(y) * asin((4 - α * α) / 3)
14
+ ];
15
+ };
16
+
17
+ (d3.geo.eckert2 = function() { return projection(eckert2); }).raw = eckert2;
@@ -0,0 +1,17 @@
1
+ function eckert3(λ, φ) {
2
+ var k = Math.sqrt(π * (4 + π));
3
+ return [
4
+ 2 / k * λ * (1 + Math.sqrt(1 - 4 * φ * φ / (π * π))),
5
+ 4 / k * φ
6
+ ];
7
+ }
8
+
9
+ eckert3.invert = function(x, y) {
10
+ var k = Math.sqrt(π * (4 + π)) / 2;
11
+ return [
12
+ x * k / (1 + asqrt(1 - y * y * (4 + π) / (4 * π))),
13
+ y * k / 2
14
+ ];
15
+ };
16
+
17
+ (d3.geo.eckert3 = function() { return projection(eckert3); }).raw = eckert3;
@@ -0,0 +1,24 @@
1
+ function eckert4(λ, φ) {
2
+ var k = (2 + π / 2) * Math.sin(φ);
3
+ φ /= 2;
4
+ for (var i = 0, δ = Infinity; i < 10 && Math.abs(δ) > ε; i++) {
5
+ var cosφ = Math.cos(φ);
6
+ φ -= δ = (φ + Math.sin(φ) * (cosφ + 2) - k) / (2 * cosφ * (1 + cosφ));
7
+ }
8
+ return [
9
+ 2 / Math.sqrt(π * (4 + π)) * λ * (1 + Math.cos(φ)),
10
+ 2 * Math.sqrt(π / (4 + π)) * Math.sin(φ)
11
+ ];
12
+ }
13
+
14
+ eckert4.invert = function(x, y) {
15
+ var j = 2 * Math.sqrt(π / (4 + π)),
16
+ k = asin(y / cy),
17
+ c = Math.cos(k);
18
+ return [
19
+ x / (2 / Math.sqrt(π * (4 + π)) * (1 + c)),
20
+ asin((k + y / j * (c + 2)) / (2 + π / 2))
21
+ ];
22
+ };
23
+
24
+ (d3.geo.eckert4 = function() { return projection(eckert4); }).raw = eckert4;
@@ -0,0 +1,17 @@
1
+ function eckert5(λ, φ) {
2
+ return [
3
+ λ * (1 + Math.cos(φ)) / Math.sqrt(2 + π),
4
+ 2 * φ / Math.sqrt(2 + π)
5
+ ];
6
+ }
7
+
8
+ eckert5.invert = function(x, y) {
9
+ var k = Math.sqrt(2 + π),
10
+ φ = y * k / 2;
11
+ return [
12
+ k * x / (1 + Math.cos(φ)),
13
+ φ
14
+ ];
15
+ };
16
+
17
+ (d3.geo.eckert5 = function() { return projection(eckert5); }).raw = eckert5;
@@ -0,0 +1,22 @@
1
+ function eckert6(λ, φ) {
2
+ var k = (1 + π / 2) * Math.sin(φ);
3
+ for (var i = 0, δ = Infinity; i < 10 && Math.abs(δ) > ε; i++) {
4
+ φ -= δ = (φ + Math.sin(φ) - k) / (1 + Math.cos(φ));
5
+ }
6
+ k = Math.sqrt(2 + π);
7
+ return [
8
+ λ * (1 + Math.cos(φ)) / k,
9
+ 2 * φ / k
10
+ ];
11
+ }
12
+
13
+ eckert6.invert = function(x, y) {
14
+ var j = 1 + π / 2,
15
+ k = Math.sqrt(j / 2);
16
+ return [
17
+ x * 2 * k / (1 + Math.cos(y *= k)),
18
+ asin((y + Math.sin(y)) / j)
19
+ ];
20
+ };
21
+
22
+ (d3.geo.eckert6 = function() { return projection(eckert6); }).raw = eckert6;
@@ -0,0 +1,16 @@
1
+ function eisenlohr(λ, φ) {
2
+ var f = 3 + Math.sqrt(8),
3
+ s1 = Math.sin(λ /= 2),
4
+ c1 = Math.cos(λ),
5
+ k = Math.sqrt(Math.cos(φ) / 2),
6
+ cosφ2 = Math.cos(φ /= 2),
7
+ t = Math.sin(φ) / (cosφ2 + 2 * c1 * k),
8
+ c = Math.sqrt(2 / (1 + t * t)),
9
+ v = Math.sqrt((cosφ2 + (c1 + s1) * k) / (cosφ2 + (c1 - s1) * k));
10
+ return [
11
+ f * (c * (v - 1 / v) - 2 * Math.log(v)),
12
+ f * (c * t * (v + 1 / v) - 2 * Math.atan(t))
13
+ ];
14
+ }
15
+
16
+ (d3.geo.eisenlohr = function() { return projection(eisenlohr); }).raw = eisenlohr;
@@ -0,0 +1,111 @@
1
+ function gringortenProjection() {
2
+ var quincuncial = false,
3
+ m = projectionMutator(gringorten),
4
+ p = m(quincuncial);
5
+
6
+ p.quincuncial = function(_) {
7
+ if (!arguments.length) return quincuncial;
8
+ return m(quincuncial = !!_);
9
+ };
10
+
11
+ return p;
12
+ }
13
+
14
+ function gringorten(quincuncial) {
15
+ return function(λ, φ) {
16
+ var cosφ = Math.cos(φ),
17
+ x = Math.cos(λ) * cosφ,
18
+ y = Math.sin(λ) * cosφ,
19
+ z = Math.sin(φ);
20
+ if (quincuncial) {
21
+ λ = Math.atan2(y, -z) - π / 4;
22
+ φ = asin(x);
23
+ } else {
24
+ λ = Math.atan2(z, x) + π / 2;
25
+ φ = asin(-y);
26
+ }
27
+ while (λ < 0) λ += 2 * π;
28
+ var nφ = φ < 0,
29
+ df = ~~(λ / (π / 4));
30
+ λ %= π / 2;
31
+ var point = gringortenHexadecant(df & 1 ? π / 2 - λ : λ, Math.abs(φ)),
32
+ x = point[0],
33
+ y = point[1],
34
+ t;
35
+ if (quincuncial && nφ) y = -2 - y;
36
+ if (df > 3) x = -x, y = -y;
37
+ switch (df % 4) {
38
+ case 1: x = -x; // fall through
39
+ case 2: t = x; x = -y; y = t; break;
40
+ case 3: y = -y; break;
41
+ }
42
+ if (!quincuncial && nφ) x = 2 - x;
43
+ return quincuncial ? [(x - y) / Math.SQRT2, (x + y) / Math.SQRT2] : [x, y];
44
+ };
45
+ }
46
+
47
+ function gringortenHexadecant(λ, φ) {
48
+ if (φ === π / 2) return [0, 0];
49
+
50
+ var sinφ = Math.sin(φ),
51
+ r = sinφ * sinφ,
52
+ r2 = r * r,
53
+ j = 1 + r2,
54
+ k = 1 + 3 * r2,
55
+ q = 1 - r2,
56
+ z = asin(1 / Math.sqrt(j)),
57
+ v = q + r * j * z,
58
+ p2 = (1 - sinφ) / v,
59
+ p = Math.sqrt(p2),
60
+ a2 = p2 * j,
61
+ a = Math.sqrt(a2),
62
+ h = p * q;
63
+ if (λ === 0) return [0, -(h + r * a)];
64
+
65
+ var cosφ = Math.cos(φ),
66
+ secφ = 1 / cosφ,
67
+ drdφ = 2 * sinφ * cosφ,
68
+ dvdφ = (-3 * r + z * k) * drdφ,
69
+ dp2dφ = (-v * cosφ - (1 - sinφ) * dvdφ) / (v * v),
70
+ dpdφ = (.5 * dp2dφ) / p,
71
+ dhdφ = q * dpdφ - 2 * r * p * drdφ,
72
+ dra2dφ = r * j * dp2dφ + p2 * k * drdφ,
73
+ μ = -secφ * drdφ,
74
+ ν = -secφ * dra2dφ,
75
+ ζ = -2 * secφ * dhdφ,
76
+ Λ = 4 * λ / π;
77
+
78
+ if (λ > .222 * π || φ < π / 4 && λ > .175 * π) {
79
+ // Slower but accurate bisection method.
80
+ var x = (h + r * asqrt(a2 * (1 + r2) - h * h)) / (1 + r2);
81
+ if (λ > π / 4) return [x, x];
82
+
83
+ var x1 = x,
84
+ x0 = .5 * x,
85
+ i = -1;
86
+ x = .5 * (x0 + x1);
87
+ do {
88
+ var g = Math.sqrt(a2 - x * x),
89
+ f = (x * (ζ + μ * g) + ν * asin(x / a)) - Λ;
90
+ if (!f) break;
91
+ if (f < 0) x0 = x;
92
+ else x1 = x;
93
+ x = .5 * (x0 + x1);
94
+ } while (++i < 50 && Math.abs(x1 - x0) > ε);
95
+ } else {
96
+ // Newton-Raphson.
97
+ for (var x = ε, i = 0; i < 25; i++) {
98
+ var x2 = x * x,
99
+ g = asqrt(a2 - x2),
100
+ ζμg = ζ + μ * g,
101
+ f = x * ζμg + ν * asin(x / a) - Λ,
102
+ df = ζμg + (ν - μ * x2) / g,
103
+ dx = g ? -f / df : 0;
104
+ x += dx;
105
+ if (Math.abs(dx) < ε) break;
106
+ }
107
+ }
108
+ return [x, -h - r * asqrt(a2 - x * x)];
109
+ }
110
+
111
+ (d3.geo.gringorten = gringortenProjection).raw = gringorten;
@@ -0,0 +1,46 @@
1
+ function guyou(λ, φ) {
2
+ return guyouEllipticFi(λ, sgn(φ) * Math.log(Math.tan(.5 * (Math.abs(φ) + π / 2))), .5);
3
+ }
4
+
5
+ // Calculate F(φ+iψ|m).
6
+ // See Abramowitz and Stegun, 17.4.11.
7
+ function guyouEllipticFi(φ, ψ, m) {
8
+ var r = Math.abs(φ),
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
+ }
21
+ return [
22
+ 0,
23
+ guyouEllipticF(Math.atan(sinhψ), 1 - m) * sgn(ψ)
24
+ ];
25
+ }
26
+
27
+ // Calculate F(φ|m) where m = k² = sin²α.
28
+ // See Abramowitz and Stegun, 17.6.7.
29
+ function guyouEllipticF(φ, m) {
30
+ var a = 1,
31
+ b = Math.sqrt(1 - m),
32
+ c = Math.sqrt(m);
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);
44
+ }
45
+
46
+ (d3.geo.guyou = function() { return projection(guyou); }).raw = guyou;
@@ -0,0 +1,75 @@
1
+ function hammerRetroazimuthal(φ0) {
2
+ var sinφ0 = Math.sin(φ0),
3
+ cosφ0 = Math.cos(φ0);
4
+
5
+ function forward(λ, φ) {
6
+ var cosφ = Math.cos(φ),
7
+ // Cartesian coordinates.
8
+ x = Math.cos(λ) * cosφ,
9
+ y = Math.sin(λ) * cosφ,
10
+ z = Math.sin(φ),
11
+ // Latitudinal rotation of φ by φ0.
12
+ sinφ = z * cosφ0 + x * sinφ0,
13
+ // Latitudinal rotation of λ by φ0 (inline).
14
+ cosλ = Math.cos(λ = Math.atan2(y, x * cosφ0 - z * sinφ0)),
15
+ cosφ = Math.cos(φ = asin(sinφ)),
16
+ z = acos(sinφ0 * sinφ + cosφ0 * cosφ * cosλ),
17
+ sinz = Math.sin(z),
18
+ K = Math.abs(sinz) > ε ? z / sinz : 1;
19
+ return [
20
+ K * cosφ0 * Math.sin(λ),
21
+ (Math.abs(λ) > π / 2 ? K : -K) // rotate for back hemisphere
22
+ * (sinφ0 * cosφ - cosφ0 * sinφ * cosλ)
23
+ ];
24
+ }
25
+
26
+ return forward;
27
+ }
28
+
29
+ function hammerRetroazimuthalProjection() {
30
+ var φ0 = 0,
31
+ m = projectionMutator(hammerRetroazimuthal),
32
+ p = m(φ0),
33
+ rotate_ = p.rotate,
34
+ stream_ = p.stream,
35
+ circle = d3.geo.circle();
36
+
37
+ p.parallel = function(_) {
38
+ if (!arguments.length) return φ0 / π * 180;
39
+ var r = p.rotate();
40
+ return m(φ0 = _ * π / 180).rotate(r);
41
+ };
42
+
43
+ p.rotate = function(_) {
44
+ if (!arguments.length) return (_ = rotate_.call(p), _[1] += φ0 / π * 180, _);
45
+ rotate_.call(p, [_[0], _[1] - φ0 / π * 180]);
46
+ circle.origin([-_[0], -_[1]]);
47
+ return p;
48
+ };
49
+
50
+ p.stream = function(stream) {
51
+ stream = stream_(stream);
52
+ stream.sphere = function() {
53
+ stream.polygonStart();
54
+ var ε = 1e-2,
55
+ ring = circle.angle(90 - ε)().coordinates[0],
56
+ n = ring.length - 1,
57
+ i = -1,
58
+ p;
59
+ stream.lineStart();
60
+ while (++i < n) stream.point((p = ring[i])[0], p[1]);
61
+ stream.lineEnd();
62
+ ring = circle.angle(90 + ε)().coordinates[0];
63
+ n = ring.length - 1;
64
+ stream.lineStart();
65
+ while (--i >= 0) stream.point((p = ring[i])[0], p[1]);
66
+ stream.lineEnd();
67
+ stream.polygonEnd();
68
+ };
69
+ return stream;
70
+ };
71
+
72
+ return p;
73
+ }
74
+
75
+ (d3.geo.hammerRetroazimuthal = hammerRetroazimuthalProjection).raw = hammerRetroazimuthal;