From 43fce5753318ad807552a29889f549912e6f96a5 Mon Sep 17 00:00:00 2001 From: Justin Kunimune Date: Sat, 2 Nov 2024 17:31:53 -0400 Subject: [PATCH] make Lagrange projection extendable actually this atan2 was really bizzare in the first place. I must have seen the arctangent of a fraction in some book somewhere and just assumed it was supposed to be fully signed. --- src/maps/Lenticular.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/maps/Lenticular.java b/src/maps/Lenticular.java index 28996c9..a27bcd3 100644 --- a/src/maps/Lenticular.java +++ b/src/maps/Lenticular.java @@ -229,12 +229,10 @@ public class Lenticular { public double[] inverse(double x, double y) { double r2 = x*x + y*y; - if (r2 > 1) - return null; double th = 2*y/(1 + r2); double t = pow((1 + th)/(1 - th), 2); double lat = asin((t - 1)/(t + 1)); - double lon = 2*atan2(2*x, 1 - r2); + double lon = 2*atan(2*x/(1 - r2)) + ((r2 > 1) ? 2*PI*signum(x) : 0); return new double[] {lat, lon}; } };