This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 4c5e164547b00877b00e7cb60840d5a03ef6d628 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Feb 7 10:44:32 2022 +0100 Simplify the formulas for φ, ∂y/∂λ and ∂y/∂φ (atan2 replaced by asin). --- .../operation/transform/PoleRotation.java | 21 ++++++++------------- .../operation/transform/PoleRotationTest.java | 4 +++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java index cba2077..4910a94 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/PoleRotation.java @@ -42,7 +42,6 @@ import org.apache.sis.util.ComparisonMode; import org.apache.sis.util.Debug; import static java.lang.Math.*; -import static org.apache.sis.internal.referencing.Formulas.fastHypot; /** @@ -395,11 +394,9 @@ public class PoleRotation extends AbstractMathTransform2D implements Serializabl final double zcosφp = z * cosφp; final double xt = zcosφp - xsinφp; final double zt = -xcosφp - zsinφp; - final double r2 = xt*xt + y2; // yt = y in ihis algorithm. - final double r = sqrt(r2); // The slower hypot(…) is not needed because values are close to 1. if (dstPts != null) { dstPts[dstOff] = atan2(y, xt); - dstPts[dstOff+1] = atan2(zt, r); + dstPts[dstOff+1] = asin(zt); } if (!derivate) { return null; @@ -410,16 +407,15 @@ public class PoleRotation extends AbstractMathTransform2D implements Serializabl * * https://svn.apache.org/repos/asf/sis/analysis/Rotated%20pole.wxmx */ + final double r2 = xt*xt + y2; // yt = y in ihis algorithm. + final double zr = sqrt(1 - zt*zt); final double dxφ = cosλ * zsinφp + cosφ * cosφp; final double dyφ = cosλ * zcosφp - cosφ * sinφp; - final double zλ = z * sinλ; - final double zr = zt / r; - final double rc = r2 + zt*zt; return new Matrix2( - (xt*x - y2*sinφp) / r2, // ∂x/∂λ - -(xt*zλ + y*dxφ) / r2, // ∂x/∂φ - (r*cosφp - zr*(x + sinφp*xt))*y / rc, // ∂y/∂λ - (r*dyφ + zr*(y*zλ - dxφ*xt)) / rc); // ∂y/∂φ + (xt*x - y2*sinφp) / r2, // ∂x/∂λ + -(xt*z*sinλ + y*dxφ) / r2, // ∂x/∂φ + y*cosφp / zr, // ∂y/∂λ + dyφ / zr); // ∂y/∂φ } /** @@ -446,9 +442,8 @@ public class PoleRotation extends AbstractMathTransform2D implements Serializabl double x = cos(λ) * cosφ; double xt = cosφp * z - sinφp * x; double zt = -cosφp * x - sinφp * z; - double r = fastHypot(xt, y); dstPts[dstOff++] = atan2(y, xt); - dstPts[dstOff++] = atan2(zt, r); + dstPts[dstOff++] = asin(zt); } } diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java index bb0525e..f346857 100644 --- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java +++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/PoleRotationTest.java @@ -255,9 +255,11 @@ public final strictfp class PoleRotationTest extends MathTransformTestCase { * * {@preformat shell * cs2cs -I -E -f %g "EPSG:4326" +to +type=crs +proj=ob_tran +o_proj=longlat +datum=WGS84 +no_defs \ - * +o_lat_p=70 +o_lon_p=40 +lon_0=10 coords.txt + * +o_lat_p=70 +o_lon_p=40 +lon_0=190 coords.txt * } * + * Note that a 180° offset must be added to the {@code +lon_0} parameter. + * * @throws FactoryException if the transform can not be created. * @throws TransformException if an error occurred while transforming a point. */