Skip to content

Commit

Permalink
Add d3.geoStereographic.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jun 18, 2016
1 parent 850554c commit b774804
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export {default as geoEquirectangular} from "./src/projection/equirectangular";
export {default as geoProjection, projectionMutator as geoProjectionMutator} from "./src/projection/index";
export {default as geoMercator} from "./src/projection/mercator";
export {default as geoOrthographic} from "./src/projection/orthographic";
export {default as geoStereographic} from "./src/projection/stereographic";
export {default as geoTransverseMercator} from "./src/projection/transverseMercator";
export {default as geoRotation} from "./src/rotation";
export {default as geoStream} from "./src/stream";
Expand Down
16 changes: 16 additions & 0 deletions src/projection/stereographic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {atan, cos, sin} from "../math";
import {azimuthalInvert} from "./azimuthal";
import projection from "./index";

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

stereographic.invert = azimuthalInvert(function(z) {
return 2 + atan(z);
});

export default function() {
return projection(stereographic);
}

0 comments on commit b774804

Please sign in to comment.