Ignore:
Timestamp:
2014-04-16T02:29:53+02:00 (6 years ago)
Author:
Don-vip
Message:

sonar - fix some more issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java

    r6974 r6987  
    237237     * convert cartesian coordinates to ellipsoidal coordinates
    238238     *
    239      * @param XYZ the coordinates in meters (X, Y, Z)
     239     * @param xyz the coordinates in meters (X, Y, Z)
    240240     * @return The corresponding latitude and longitude in degrees
    241241     */
    242     public LatLon cart2LatLon(double[] XYZ) {
    243         return cart2LatLon(XYZ, 1e-11);
    244     }
    245     public LatLon cart2LatLon(double[] XYZ, double epsilon) {
    246         double norm = Math.sqrt(XYZ[0] * XYZ[0] + XYZ[1] * XYZ[1]);
    247         double lg = 2.0 * Math.atan(XYZ[1] / (XYZ[0] + norm));
    248         double lt = Math.atan(XYZ[2] / (norm * (1.0 - (a * e2 / Math.sqrt(XYZ[0] * XYZ[0] + XYZ[1] * XYZ[1] + XYZ[2] * XYZ[2])))));
     242    public LatLon cart2LatLon(double[] xyz) {
     243        return cart2LatLon(xyz, 1e-11);
     244    }
     245
     246    public LatLon cart2LatLon(double[] xyz, double epsilon) {
     247        double norm = Math.sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1]);
     248        double lg = 2.0 * Math.atan(xyz[1] / (xyz[0] + norm));
     249        double lt = Math.atan(xyz[2] / (norm * (1.0 - (a * e2 / Math.sqrt(xyz[0] * xyz[0] + xyz[1] * xyz[1] + xyz[2] * xyz[2])))));
    249250        double delta = 1.0;
    250251        while (delta > epsilon) {
    251252            double s2 = Math.sin(lt);
    252253            s2 *= s2;
    253             double l = Math.atan((XYZ[2] / norm)
     254            double l = Math.atan((xyz[2] / norm)
    254255                    / (1.0 - (a * e2 * Math.cos(lt) / (norm * Math.sqrt(1.0 - e2 * s2)))));
    255256            delta = Math.abs(l - lt);
     
    270271
    271272        double Rn = a / Math.sqrt(1 - e2 * Math.pow(Math.sin(phi), 2));
    272         double[] XYZ = new double[3];
    273         XYZ[0] = Rn * Math.cos(phi) * Math.cos(lambda);
    274         XYZ[1] = Rn * Math.cos(phi) * Math.sin(lambda);
    275         XYZ[2] = Rn * (1 - e2) * Math.sin(phi);
    276 
    277         return XYZ;
     273        double[] xyz = new double[3];
     274        xyz[0] = Rn * Math.cos(phi) * Math.cos(lambda);
     275        xyz[1] = Rn * Math.cos(phi) * Math.sin(lambda);
     276        xyz[2] = Rn * (1 - e2) * Math.sin(phi);
     277
     278        return xyz;
    278279    }
    279280}
Note: See TracChangeset for help on using the changeset viewer.