d3js-plugins-rails 0.0.2 → 0.0.3
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.
- 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
| @@ -1,18 +1,15 @@ | |
| 1 1 | 
             
            function hammerRetroazimuthal(φ0) {
         | 
| 2 2 | 
             
              var sinφ0 = Math.sin(φ0),
         | 
| 3 | 
            -
                  cosφ0 = Math.cos(φ0) | 
| 3 | 
            +
                  cosφ0 = Math.cos(φ0),
         | 
| 4 | 
            +
                  rotate = hammerRetroazimuthalRotation(φ0);
         | 
| 5 | 
            +
              rotate.invert = hammerRetroazimuthalRotation(-φ0);
         | 
| 4 6 |  | 
| 5 7 | 
             
              function forward(λ, φ) {
         | 
| 6 | 
            -
                var  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
                     | 
| 10 | 
            -
                     | 
| 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φ)),
         | 
| 8 | 
            +
                var p = rotate(λ, φ);
         | 
| 9 | 
            +
                λ = p[0], φ = p[1];
         | 
| 10 | 
            +
                var sinφ = Math.sin(φ),
         | 
| 11 | 
            +
                    cosφ = Math.cos(φ),
         | 
| 12 | 
            +
                    cosλ = Math.cos(λ),
         | 
| 16 13 | 
             
                    z = acos(sinφ0 * sinφ + cosφ0 * cosφ * cosλ),
         | 
| 17 14 | 
             
                    sinz = Math.sin(z),
         | 
| 18 15 | 
             
                    K = Math.abs(sinz) > ε ? z / sinz : 1;
         | 
| @@ -23,9 +20,40 @@ function hammerRetroazimuthal(φ0) { | |
| 23 20 | 
             
                ];
         | 
| 24 21 | 
             
              }
         | 
| 25 22 |  | 
| 23 | 
            +
              forward.invert = function(x, y) {
         | 
| 24 | 
            +
                var ρ = Math.sqrt(x * x + y * y),
         | 
| 25 | 
            +
                    sinz = -Math.sin(ρ),
         | 
| 26 | 
            +
                    cosz = Math.cos(ρ),
         | 
| 27 | 
            +
                    a = ρ * cosz,
         | 
| 28 | 
            +
                    b = -y * sinz,
         | 
| 29 | 
            +
                    c = ρ * sinφ0,
         | 
| 30 | 
            +
                    d = asqrt(a * a + b * b - c * c),
         | 
| 31 | 
            +
                    φ = Math.atan2(a * c + b * d, b * c - a * d),
         | 
| 32 | 
            +
                    λ = (ρ > π / 2 ? -1 : 1) * Math.atan2(x * sinz, ρ * Math.cos(φ) * cosz + y * Math.sin(φ) * sinz);
         | 
| 33 | 
            +
                return rotate.invert(λ, φ);
         | 
| 34 | 
            +
              };
         | 
| 35 | 
            +
             | 
| 26 36 | 
             
              return forward;
         | 
| 27 37 | 
             
            }
         | 
| 28 38 |  | 
| 39 | 
            +
            // Latitudinal rotation by φ0.
         | 
| 40 | 
            +
            // Temporary hack until D3 supports arbitrary small-circle clipping origins.
         | 
| 41 | 
            +
            function hammerRetroazimuthalRotation(φ0) {
         | 
| 42 | 
            +
              var sinφ0 = Math.sin(φ0),
         | 
| 43 | 
            +
                  cosφ0 = Math.cos(φ0);
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              return function(λ, φ) {
         | 
| 46 | 
            +
                var cosφ = Math.cos(φ),
         | 
| 47 | 
            +
                    x = Math.cos(λ) * cosφ,
         | 
| 48 | 
            +
                    y = Math.sin(λ) * cosφ,
         | 
| 49 | 
            +
                    z = Math.sin(φ);
         | 
| 50 | 
            +
                return [
         | 
| 51 | 
            +
                  Math.atan2(y, x * cosφ0 - z * sinφ0),
         | 
| 52 | 
            +
                  asin(z * cosφ0 + x * sinφ0)
         | 
| 53 | 
            +
                ];
         | 
| 54 | 
            +
              };
         | 
| 55 | 
            +
            }
         | 
| 56 | 
            +
             | 
| 29 57 | 
             
            function hammerRetroazimuthalProjection() {
         | 
| 30 58 | 
             
              var φ0 = 0,
         | 
| 31 59 | 
             
                  m = projectionMutator(hammerRetroazimuthal),
         | 
| @@ -40,6 +68,7 @@ function hammerRetroazimuthalProjection() { | |
| 40 68 | 
             
                return m(φ0 = _ * π / 180).rotate(r);
         | 
| 41 69 | 
             
              };
         | 
| 42 70 |  | 
| 71 | 
            +
              // Temporary hack; see hammerRetroazimuthalRotation.
         | 
| 43 72 | 
             
              p.rotate = function(_) {
         | 
| 44 73 | 
             
                if (!arguments.length) return (_ = rotate_.call(p), _[1] += φ0 / π * 180, _);
         | 
| 45 74 | 
             
                rotate_.call(p, [_[0], _[1] - φ0 / π * 180]);
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            function lagrange(n) {
         | 
| 2 | 
            -
               | 
| 2 | 
            +
              function forward(λ, φ) {
         | 
| 3 3 | 
             
                if (Math.abs(Math.abs(φ) - π / 2) < ε) return [0, φ < 0 ? -2 : 2];
         | 
| 4 4 | 
             
                var sinφ = Math.sin(φ),
         | 
| 5 5 | 
             
                    v = Math.pow((1 + sinφ) / (1 - sinφ), n / 2),
         | 
| @@ -8,7 +8,25 @@ function lagrange(n) { | |
| 8 8 | 
             
                  2 * Math.sin(λ) / c,
         | 
| 9 9 | 
             
                  (v - 1 / v) / c
         | 
| 10 10 | 
             
                ];
         | 
| 11 | 
            +
              }
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              forward.invert = function(x, y) {
         | 
| 14 | 
            +
                var y0 = Math.abs(y);
         | 
| 15 | 
            +
                if (Math.abs(y0 - 2) < ε) return x ? null : [0, sgn(y) * π / 2];
         | 
| 16 | 
            +
                if (y0 > 2) return null;
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                x /= 2, y /= 2;
         | 
| 19 | 
            +
                var x2 = x * x,
         | 
| 20 | 
            +
                    y2 = y * y,
         | 
| 21 | 
            +
                    t = 2 * y / (1 + x2 + y2); // tanh(nφ)
         | 
| 22 | 
            +
                t = Math.pow((1 + t) / (1 - t), 1 / n);
         | 
| 23 | 
            +
                return [
         | 
| 24 | 
            +
                  Math.atan2(2 * x, 1 - x2 - y2) / n,
         | 
| 25 | 
            +
                  asin((t - 1) / (t + 1))
         | 
| 26 | 
            +
                ];
         | 
| 11 27 | 
             
              };
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              return forward;
         | 
| 12 30 | 
             
            }
         | 
| 13 31 |  | 
| 14 32 | 
             
            function lagrangeProjection() {
         | 
| @@ -7,8 +7,8 @@ function laskowski(λ, φ) { | |
| 7 7 | 
             
            }
         | 
| 8 8 |  | 
| 9 9 | 
             
            laskowski.invert = function(x, y) {
         | 
| 10 | 
            -
              var λ = x | 
| 11 | 
            -
                  φ = y,
         | 
| 10 | 
            +
              var λ = sgn(x) * π,
         | 
| 11 | 
            +
                  φ = y / 2,
         | 
| 12 12 | 
             
                  i = 50;
         | 
| 13 13 | 
             
              do {
         | 
| 14 14 | 
             
                var λ2 = λ * λ,
         | 
| @@ -25,7 +25,7 @@ laskowski.invert = function(x, y) { | |
| 25 25 | 
             
                    δφ = (fx * δyδλ - fy * δxδλ) / denominator;
         | 
| 26 26 | 
             
                λ -= δλ, φ -= δφ;
         | 
| 27 27 | 
             
              } while ((Math.abs(δλ) > ε || Math.abs(δφ) > ε) && --i > 0);
         | 
| 28 | 
            -
              return [λ, φ];
         | 
| 28 | 
            +
              return i && [λ, φ];
         | 
| 29 29 | 
             
            };
         | 
| 30 30 |  | 
| 31 31 | 
             
            (d3.geo.laskowski = function() { return projection(laskowski); }).raw = laskowski;
         | 
| @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            function modifiedStereographic(C) {
         | 
| 2 | 
            +
              var m = C.length - 1;
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              function forward(λ, φ) {
         | 
| 5 | 
            +
                var cosφ = Math.cos(φ),
         | 
| 6 | 
            +
                    k = 2 / (1 + cosφ * Math.cos(λ)),
         | 
| 7 | 
            +
                    zr = k * cosφ * Math.sin(λ),
         | 
| 8 | 
            +
                    zi = k * Math.sin(φ),
         | 
| 9 | 
            +
                    i = m,
         | 
| 10 | 
            +
                    w = C[i],
         | 
| 11 | 
            +
                    ar = w[0],
         | 
| 12 | 
            +
                    ai = w[1],
         | 
| 13 | 
            +
                    t;
         | 
| 14 | 
            +
                while (--i >= 0) {
         | 
| 15 | 
            +
                  w = C[i];
         | 
| 16 | 
            +
                  ar = w[0] + zr * (t = ar) - zi * ai;
         | 
| 17 | 
            +
                  ai = w[1] + zr * ai + zi * t;
         | 
| 18 | 
            +
                }
         | 
| 19 | 
            +
                ar = zr * (t = ar) - zi * ai;
         | 
| 20 | 
            +
                ai = zr * ai + zi * t;
         | 
| 21 | 
            +
                return [ar, ai];
         | 
| 22 | 
            +
              }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              forward.invert = function(x, y) {
         | 
| 25 | 
            +
                var i = 20,
         | 
| 26 | 
            +
                    zr = x,
         | 
| 27 | 
            +
                    zi = y;
         | 
| 28 | 
            +
                do {
         | 
| 29 | 
            +
                  var j = m,
         | 
| 30 | 
            +
                      w = C[j],
         | 
| 31 | 
            +
                      ar = w[0],
         | 
| 32 | 
            +
                      ai = w[1],
         | 
| 33 | 
            +
                      br = 0,
         | 
| 34 | 
            +
                      bi = 0,
         | 
| 35 | 
            +
                      t;
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  while (--j >= 0) {
         | 
| 38 | 
            +
                    w = C[j];
         | 
| 39 | 
            +
                    br = ar + zr * (t = br) - zi * bi;
         | 
| 40 | 
            +
                    bi = ai + zr * bi + zi * t;
         | 
| 41 | 
            +
                    ar = w[0] + zr * (t = ar) - zi * ai;
         | 
| 42 | 
            +
                    ai = w[1] + zr * ai + zi * t;
         | 
| 43 | 
            +
                  }
         | 
| 44 | 
            +
                  br = ar + zr * (t = br) - zi * bi;
         | 
| 45 | 
            +
                  bi = ai + zr * bi + zi * t;
         | 
| 46 | 
            +
                  ar = zr * (t = ar) - zi * ai - x;
         | 
| 47 | 
            +
                  ai = zr * ai + zi * t - y;
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  var denominator = br * br + bi * bi, δr, δi;
         | 
| 50 | 
            +
                  zr -= δr = (ar * br + ai * bi) / denominator;
         | 
| 51 | 
            +
                  zi -= δi = (ai * br - ar * bi) / denominator;
         | 
| 52 | 
            +
                } while (Math.abs(δr) + Math.abs(δi) > ε * ε && --i > 0);
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                if (i) {
         | 
| 55 | 
            +
                  var ρ = Math.sqrt(zr * zr + zi * zi),
         | 
| 56 | 
            +
                      c = 2 * Math.atan(ρ * .5),
         | 
| 57 | 
            +
                      sinc = Math.sin(c);
         | 
| 58 | 
            +
                  return [Math.atan2(zr * sinc, ρ * Math.cos(c)), ρ ? asin(zi * sinc / ρ) : 0];
         | 
| 59 | 
            +
                }
         | 
| 60 | 
            +
              };
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              return forward;
         | 
| 63 | 
            +
            }
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            var modifiedStereographicCoefficients = {
         | 
| 66 | 
            +
              alaska: [
         | 
| 67 | 
            +
                [ .9972523, 0],
         | 
| 68 | 
            +
                [ .0052513, -.0041175],
         | 
| 69 | 
            +
                [ .0074606,  .0048125],
         | 
| 70 | 
            +
                [-.0153783, -.1968253],
         | 
| 71 | 
            +
                [ .0636871, -.1408027],
         | 
| 72 | 
            +
                [ .3660976, -.2937382]
         | 
| 73 | 
            +
              ],
         | 
| 74 | 
            +
              gs48: [[.98879, 0], [0, 0], [-.050909, 0], [0, 0], [.075528, 0]],
         | 
| 75 | 
            +
              gs50: [
         | 
| 76 | 
            +
                [ .9842990, 0],
         | 
| 77 | 
            +
                [ .0211642,  .0037608],
         | 
| 78 | 
            +
                [-.1036018, -.0575102],
         | 
| 79 | 
            +
                [-.0329095, -.0320119],
         | 
| 80 | 
            +
                [ .0499471,  .1223335],
         | 
| 81 | 
            +
                [ .0260460,  .0899805],
         | 
| 82 | 
            +
                [ .0007388, -.1435792],
         | 
| 83 | 
            +
                [ .0075848, -.1334108],
         | 
| 84 | 
            +
                [-.0216473,  .0776645],
         | 
| 85 | 
            +
                [-.0225161,  .0853673]
         | 
| 86 | 
            +
              ],
         | 
| 87 | 
            +
              miller: [[.9245, 0], [0, 0], [.01943, 0]],
         | 
| 88 | 
            +
              lee: [[.721316, 0], [0, 0], [-.00881625, -.00617325]]
         | 
| 89 | 
            +
            };
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            function modifiedStereographicProjection() {
         | 
| 92 | 
            +
              var coefficients = modifiedStereographicCoefficients.miller,
         | 
| 93 | 
            +
                  m = projectionMutator(modifiedStereographic),
         | 
| 94 | 
            +
                  p = m(coefficients);
         | 
| 95 | 
            +
             | 
| 96 | 
            +
              p.coefficients = function(_) {
         | 
| 97 | 
            +
                if (!arguments.length) return coefficients;
         | 
| 98 | 
            +
                return m(coefficients = typeof _ === "string" ? modifiedStereographicCoefficients[_] : _);
         | 
| 99 | 
            +
              };
         | 
| 100 | 
            +
             | 
| 101 | 
            +
              return p;
         | 
| 102 | 
            +
            }
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            (d3.geo.modifiedStereographic = modifiedStereographicProjection).raw = modifiedStereographic;
         | 
| @@ -1,14 +1,50 @@ | |
| 1 1 | 
             
            // @import guyou
         | 
| 2 2 |  | 
| 3 3 | 
             
            function peirceQuincuncial(λ, φ) {
         | 
| 4 | 
            +
              var k_ = (Math.SQRT2 - 1) / (Math.SQRT2 + 1),
         | 
| 5 | 
            +
                  k = Math.sqrt(1 - k_ * k_),
         | 
| 6 | 
            +
                  K = ellipticF(π / 2, k * k);
         | 
| 7 | 
            +
             | 
| 4 8 | 
             
              var t = Math.abs(λ) < π / 2,
         | 
| 5 | 
            -
                  p = guyou( | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 9 | 
            +
                  p = guyou(λ + (λ < -π / 2 ? 1.5 : -.5) * π, φ);
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              p[0] += (t ? .5 : -.5) * K;
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              var x = (p[0] - p[1]) * Math.SQRT1_2,
         | 
| 14 | 
            +
                  y = (p[0] + p[1]) * Math.SQRT1_2;
         | 
| 15 | 
            +
             | 
| 8 16 | 
             
              if (t) return [x, y];
         | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 17 | 
            +
             | 
| 18 | 
            +
              var d = K * Math.SQRT1_2,
         | 
| 19 | 
            +
                  s = x > 0 ^ y > 0 ? -1 : 1;
         | 
| 20 | 
            +
             | 
| 11 21 | 
             
              return [s * x - sgn(y) * d, s * y - sgn(x) * d];
         | 
| 12 22 | 
             
            }
         | 
| 13 23 |  | 
| 24 | 
            +
            peirceQuincuncial.invert = function(x0, y0) {
         | 
| 25 | 
            +
              var k_ = (Math.SQRT2 - 1) / (Math.SQRT2 + 1),
         | 
| 26 | 
            +
                  k = Math.sqrt(1 - k_ * k_),
         | 
| 27 | 
            +
                  K = ellipticF(π / 2, k * k);
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              var x = (x0 + y0) * Math.SQRT1_2,
         | 
| 30 | 
            +
                  y = (y0 - x0) * Math.SQRT1_2;
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              var t = Math.abs(x) < .5 * K && Math.abs(y) < .5 * K;
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              if (!t) {
         | 
| 35 | 
            +
                var d = K * Math.SQRT1_2,
         | 
| 36 | 
            +
                    s = x > 0 ^ y > 0 ? -1 : 1,
         | 
| 37 | 
            +
                    x1 = -s * (x0 + (y > 0 ? 1 : -1) * d),
         | 
| 38 | 
            +
                    y1 = -s * (y0 + (x > 0 ? 1 : -1) * d);
         | 
| 39 | 
            +
                x = (-x1 - y1) * Math.SQRT1_2;
         | 
| 40 | 
            +
                y = (x1 - y1) * Math.SQRT1_2;
         | 
| 41 | 
            +
              }
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              x -= (t ? .5 : -.5) * K;
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              var p = guyou.invert(x, y);
         | 
| 46 | 
            +
              p[0] += .5 * π;
         | 
| 47 | 
            +
              return p;
         | 
| 48 | 
            +
            };
         | 
| 49 | 
            +
             | 
| 14 50 | 
             
            (d3.geo.peirceQuincuncial = function() { return projection(peirceQuincuncial).rotate([-90, -90, 45]).clipAngle(180 - 1e-6); }).raw = peirceQuincuncial;
         | 
| @@ -11,13 +11,17 @@ function polyconic(λ, φ) { | |
| 11 11 | 
             
            polyconic.invert = function(x, y) {
         | 
| 12 12 | 
             
              if (Math.abs(y) < ε) return [x, 0];
         | 
| 13 13 | 
             
              var k = x * x + y * y,
         | 
| 14 | 
            -
                  φ = y | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
                 | 
| 18 | 
            -
             | 
| 14 | 
            +
                  φ = y * .5,
         | 
| 15 | 
            +
                  i = 10, δ;
         | 
| 16 | 
            +
              do {
         | 
| 17 | 
            +
                var tanφ = Math.tan(φ),
         | 
| 18 | 
            +
                    secφ = 1 / Math.cos(φ),
         | 
| 19 | 
            +
                    j = k - 2 * y * φ + φ * φ;
         | 
| 20 | 
            +
                φ -= δ = (tanφ * j + 2 * (φ - y)) / (2 + j * secφ * secφ + 2 * (φ - y) * tanφ);
         | 
| 21 | 
            +
              } while (Math.abs(δ) > ε && --i > 0);
         | 
| 22 | 
            +
              tanφ = Math.tan(φ);
         | 
| 19 23 | 
             
              return [
         | 
| 20 | 
            -
                asin(x * Math.tan | 
| 24 | 
            +
                (Math.abs(y) < Math.abs(φ + 1 / tanφ) ? asin(x * tanφ) : sgn(x) * (acos(Math.abs(x * tanφ)) + π / 2)) / Math.sin(φ),
         | 
| 21 25 | 
             
                φ
         | 
| 22 26 | 
             
              ];
         | 
| 23 27 | 
             
            };
         | 
| @@ -27,3 +27,24 @@ function asin(x) { | |
| 27 27 | 
             
            function acos(x) {
         | 
| 28 28 | 
             
              return x > 1 ? 0 : x < -1 ? π : Math.acos(x);
         | 
| 29 29 | 
             
            }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            function tanh(x) {
         | 
| 32 | 
            +
              x = Math.exp(2 * x);
         | 
| 33 | 
            +
              return (x - 1) / (x + 1);
         | 
| 34 | 
            +
            }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            function sinh(x) {
         | 
| 37 | 
            +
              return .5 * (Math.exp(x) - Math.exp(-x));
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            function cosh(x) {
         | 
| 41 | 
            +
              return .5 * (Math.exp(x) + Math.exp(-x));
         | 
| 42 | 
            +
            }
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            function arsinh(x) {
         | 
| 45 | 
            +
              return Math.log(x + asqrt(x * x + 1));
         | 
| 46 | 
            +
            }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            function arcosh(x) {
         | 
| 49 | 
            +
              return Math.log(x + asqrt(x * x - 1));
         | 
| 50 | 
            +
            }
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            // @import parallel1
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            function rectangularPolyconic(φ0) {
         | 
| 4 | 
            +
              var sinφ0 = Math.sin(φ0);
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              function forward(λ, φ) {
         | 
| 7 | 
            +
                var A = sinφ0 ? Math.tan(λ * sinφ0 / 2) / sinφ0 : λ / 2;
         | 
| 8 | 
            +
                if (!φ) return [2 * A, -φ0];
         | 
| 9 | 
            +
                var E = 2 * Math.atan(A * Math.sin(φ)),
         | 
| 10 | 
            +
                    cotφ = 1 / Math.tan(φ);
         | 
| 11 | 
            +
                return [
         | 
| 12 | 
            +
                  Math.sin(E) * cotφ,
         | 
| 13 | 
            +
                  φ + (1 - Math.cos(E)) * cotφ - φ0
         | 
| 14 | 
            +
                ];
         | 
| 15 | 
            +
              }
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              // TODO return null for points outside outline.
         | 
| 18 | 
            +
              forward.invert = function(x, y) {
         | 
| 19 | 
            +
                if (Math.abs(y += φ0) < ε) return [sinφ0 ? 2 * Math.atan(sinφ0 * x / 2) / sinφ0 : x, 0];
         | 
| 20 | 
            +
                var k = x * x + y * y,
         | 
| 21 | 
            +
                    φ = 0,
         | 
| 22 | 
            +
                    i = 10, δ;
         | 
| 23 | 
            +
                do {
         | 
| 24 | 
            +
                  var tanφ = Math.tan(φ),
         | 
| 25 | 
            +
                      secφ = 1 / Math.cos(φ),
         | 
| 26 | 
            +
                      j = k - 2 * y * φ + φ * φ;
         | 
| 27 | 
            +
                  φ -= δ = (tanφ * j + 2 * (φ - y)) / (2 + j * secφ * secφ + 2 * (φ - y) * tanφ);
         | 
| 28 | 
            +
                } while (Math.abs(δ) > ε && --i > 0);
         | 
| 29 | 
            +
                var E = x * (tanφ = Math.tan(φ)),
         | 
| 30 | 
            +
                    A = Math.tan(Math.abs(y) < Math.abs(φ + 1 / tanφ) ? asin(E) * .5 : acos(E) * .5 + π / 4) / Math.sin(φ);
         | 
| 31 | 
            +
                return [
         | 
| 32 | 
            +
                  sinφ0 ? 2 * Math.atan(sinφ0 * A) / sinφ0 : 2 * A,
         | 
| 33 | 
            +
                  φ
         | 
| 34 | 
            +
                ];
         | 
| 35 | 
            +
              };
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              return forward;
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            (d3.geo.rectangularPolyconic = function() { return parallel1Projection(rectangularPolyconic); }).raw = rectangularPolyconic;
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require("./env");
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            var vows = require("vows"),
         | 
| 4 | 
            +
                assert = require("assert");
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            var suite = vows.describe("d3.geo.august");
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            suite.addBatch({
         | 
| 9 | 
            +
              "august": {
         | 
| 10 | 
            +
                topic: d3.geo.august,
         | 
| 11 | 
            +
                "projections and inverse projections": function(august) {
         | 
| 12 | 
            +
                  assert.equalInverse(august, [  0,   0], [480,        250]);
         | 
| 13 | 
            +
                  assert.equalInverse(august, [  0, -45], [480,        378.067905]);
         | 
| 14 | 
            +
                  assert.equalInverse(august, [  0,  45], [480,        121.932094]);
         | 
| 15 | 
            +
                  assert.equalInverse(august, [  0,  90], [480,       -150]);
         | 
| 16 | 
            +
                  assert.equalInverse(august, [  0,  80], [480,        -43.976545]);
         | 
| 17 | 
            +
                  assert.equalInverse(august, [-90,   0], [217.258300, 250]);
         | 
| 18 | 
            +
                  assert.equalInverse(august, [ 90,   0], [742.741699, 250]);
         | 
| 19 | 
            +
                  assert.equalInverse(august, [-80,  15], [254.414080, 199.297313]);
         | 
| 20 | 
            +
                  assert.equalInverse(august, [  1,   1], [482.617927, 247.381806]);
         | 
| 21 | 
            +
                  assert.equalInverse(august, [ 15,  80], [499.471722, -45.366200]);
         | 
| 22 | 
            +
                  assert.equalInverse(august, [100,  50], [732.424769,  43.602745]);
         | 
| 23 | 
            +
                }
         | 
| 24 | 
            +
              }
         | 
| 25 | 
            +
            });
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            suite.export(module);
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require("./env");
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            var vows = require("vows"),
         | 
| 4 | 
            +
                assert = require("assert");
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            var suite = vows.describe("d3.geo.berghaus");
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            suite.addBatch({
         | 
| 9 | 
            +
              "berghaus": {
         | 
| 10 | 
            +
                topic: d3.geo.berghaus,
         | 
| 11 | 
            +
                "projections and inverse projections": function(berghaus) {
         | 
| 12 | 
            +
                  assert.equalInverse(berghaus, [  0,   0], [480,        250]);
         | 
| 13 | 
            +
                  assert.equalInverse(berghaus, [  0, -45], [480,        367.809724]);
         | 
| 14 | 
            +
                  assert.equalInverse(berghaus, [  0,  45], [480,        132.190275]);
         | 
| 15 | 
            +
                  assert.equalInverse(berghaus, [-90,   0], [244.380550, 250]);
         | 
| 16 | 
            +
                  assert.equalInverse(berghaus, [ 90,   0], [715.619449, 250]);
         | 
| 17 | 
            +
                  assert.equalInverse(berghaus, [-80,  15], [277.038148, 194.777583]);
         | 
| 18 | 
            +
                  assert.equalInverse(berghaus, [  1,   1], [482.617728, 247.381873]);
         | 
| 19 | 
            +
                  assert.equalInverse(berghaus, [ 15,  45], [510.778518, 131.080938]);
         | 
| 20 | 
            +
                  assert.equalInverse(berghaus, [120,  30], [750.967904, 114.867516]);
         | 
| 21 | 
            +
                  assert.equalInverse(berghaus, [110,  10], [759.454234, 183.963114]);
         | 
| 22 | 
            +
                }
         | 
| 23 | 
            +
              }
         | 
| 24 | 
            +
            });
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            suite.export(module);
         | 
| @@ -7,17 +7,32 @@ var suite = vows.describe("d3.geo.craig"); | |
| 7 7 |  | 
| 8 8 | 
             
            suite.addBatch({
         | 
| 9 9 | 
             
              "craig": {
         | 
| 10 | 
            -
                 | 
| 11 | 
            -
             | 
| 12 | 
            -
                   | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 10 | 
            +
                "0° parallel": {
         | 
| 11 | 
            +
                  topic: d3.geo.craig,
         | 
| 12 | 
            +
                  "projections and inverse projections": function(craig) {
         | 
| 13 | 
            +
                    assert.equalInverse(craig, [   0,   0], [480,          250]);
         | 
| 14 | 
            +
                    assert.equalInverse(craig, [   0, -90], [480,          400]);
         | 
| 15 | 
            +
                    assert.equalInverse(craig, [   0,  90], [480,          100]);
         | 
| 16 | 
            +
                    assert.equalInverse(craig, [   0, -45], [480,          356.066017]);
         | 
| 17 | 
            +
                    assert.equalInverse(craig, [   0,  45], [480,          143.933982]);
         | 
| 18 | 
            +
                    assert.equalInverse(craig, [-180,   0], [  8.761101,   250]);
         | 
| 19 | 
            +
                    assert.equalInverse(craig, [ 180,   0], [951.238898,   250]);
         | 
| 20 | 
            +
                    assert.equalInverse(craig, [-179,  15], [ 11.3790958, 7198.585721]);
         | 
| 21 | 
            +
                    assert.equalInverse(craig, [   1,   1], [482.617993,   247.382404]);
         | 
| 22 | 
            +
                  }
         | 
| 23 | 
            +
                },
         | 
| 24 | 
            +
                "30° parallel": {
         | 
| 25 | 
            +
                  topic: function() {
         | 
| 26 | 
            +
                    return d3.geo.craig().parallel(30);
         | 
| 27 | 
            +
                  },
         | 
| 28 | 
            +
                  "projections and inverse projections": function(craig) {
         | 
| 29 | 
            +
                    assert.equalInverse(craig, [   0,   0], [480,        250]);
         | 
| 30 | 
            +
                    assert.equalInverse(craig, [   0, -30], [480,        313.397459]);
         | 
| 31 | 
            +
                    assert.equalInverse(craig, [   0,  30], [480,        163.397459]);
         | 
| 32 | 
            +
                    assert.equalInverse(craig, [   0, -45], [480,        330.700720]);
         | 
| 33 | 
            +
                    assert.equalInverse(craig, [   0,  45], [480,        118.568686]);
         | 
| 34 | 
            +
                    assert.equalInverse(craig, [   1,   1], [482.617993, 247.373611]);
         | 
| 35 | 
            +
                  }
         | 
| 21 36 | 
             
                }
         | 
| 22 37 | 
             
              }
         | 
| 23 38 | 
             
            });
         |