cdm/src/main/java/ucar/unidata/geoloc/projection/FlatEarth.java
public double[][] projToLatLon(double[][] from, double[][] to) {
    int cnt = from[0].length;
    double[] fromXA = from[INDEX_X];
    double[] fromYA = from[INDEX_Y];
    double[] toLatA = to[INDEX_LAT];
    double[] toLonA = to[INDEX_LON];

    double toLat, toLon;
    for (int i = 0; i < cnt; i++) {
      double fromX = fromXA[i];
      double fromY = fromYA[i];

      double xp = cosRot * fromX + sinRot * fromY;
      double yp = -sinRot * fromX + cosRot * fromY;

      //toLat =  lat0 + Math.toDegrees(yp);
      toLat = Math.toDegrees(lat0)
              + Math.toDegrees(yp / radius);
      double cosl = Math.cos(Math.toRadians(toLat));

      if (Math.abs(cosl) < TOLERANCE) {
        toLon = Math.toDegrees(lon0);
      } else {
        toLon = Math.toDegrees(lon0)
                + Math.toDegrees(xp / cosl / radius);
      }

      toLon = LatLonPointImpl.lonNormal(toLon);

      toLatA[i] = toLat;
      toLonA[i] = toLon;

    }
    return to;
  }
public double[][] projToLatLon(double[][] from, double[][] to) {
    int cnt = from[0].length;
    double[] fromXA = from[INDEX_X];
    double[] fromYA = from[INDEX_Y];
    double[] toLatA = to[INDEX_LAT];
    double[] toLonA = to[INDEX_LON];

    double toLat, toLon;
    for (int i = 0; i < cnt; i++) {
      double fromX = fromXA[i];
      double fromY = fromYA[i];

      double xp = cosRot * fromX + sinRot * fromY;
      double yp = -sinRot * fromX + cosRot * fromY;

      //toLat =  lat0 + Math.toDegrees(yp);
      toLat = Math.toDegrees(lat0)
              + Math.toDegrees(yp / radius);
      double cosl = Math.cos(Math.toRadians(toLat));

      if (Math.abs(cosl) < TOLERANCE) {
        toLon = Math.toDegrees(lon0);
      } else {
        toLon = Math.toDegrees(lon0)
                + Math.toDegrees(xp / cosl / radius);
      }

      toLon = LatLonPointImpl.lonNormal(toLon);

      toLatA[i] = toLat;
      toLonA[i] = toLon;

    }
    return to;
  }
Convert lat/lon coordinates to projection coordinates.

@param from array of lat/lon coordinates: from[2][n], where
(from[0][i], from[1][i]) is the (lat,lon) coordinate
of the ith point
@param to   resulting array of projection coordinates: to[2][n]
where (to[0][i], to[1][i]) is the (x,y) coordinate
of the ith point
@return the "to" array