Skip to content

Commit

Permalink
An approximate inverse for Cahill-Keyes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed May 31, 2020
1 parent 01f2242 commit 69200f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cahillKeyes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { abs, cos, degrees, pi, radians, sin, sign, sqrt, tan } from "./math.js"
import { cartesianCross, cartesianDegrees, cartesianDot, sphericalDegrees } from "./cartesian.js";
import polyhedral from "./polyhedral/index.js";
import { geoProjectionMutator as projectionMutator } from "d3-geo";
import {solve2d} from "./newton.js";

export default function(faceProjection) {
faceProjection =
Expand Down Expand Up @@ -669,6 +670,8 @@ export function cahillKeyesRaw(mg) {
return mm;
}

forward.invert = solve2d(forward);

return forward;
}

Expand Down
13 changes: 13 additions & 0 deletions test/invert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ tape("inverse Imago, tetrahedralLee", function(test) {
test.end();
});

tape("inverse Cahill-Keyes", function(test) {

[ d3.geoCahillKeyes() ]
.forEach(function(projection) {
[ [-23, 12], [10,10], [100,-45] ]
.forEach(function(location) {
projection.angle(Math.random()*360);
test.projectionEqual(projection, location, projection(location), 1e-5);
});
});
test.end();
});

tape("inverse complex log", function(test) {

[ d3.geoComplexLog() ]
Expand Down

0 comments on commit 69200f9

Please sign in to comment.