summaryrefslogtreecommitdiff
path: root/src/projection/stereographic.js
blob: 5f9694aac27a5d41e9ee3b0a438a73660999daac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import {atan, cos, sin} from "../math.js";
import {azimuthalInvert} from "./azimuthal.js";
import projection from "./index.js";

export function stereographicRaw(x, y) {
  var cy = cos(y), k = 1 + cos(x) * cy;
  return [cy * sin(x) / k, sin(y) / k];
}

stereographicRaw.invert = azimuthalInvert(function(z) {
  return 2 * atan(z);
});

export default function() {
  return projection(stereographicRaw)
      .scale(250)
      .clipAngle(142);
}