cdm/src/main/java/ucar/unidata/geoloc/projection/Stereographic.java
public float[][] projToLatLon(float[][] from, float[][] to) {
    int cnt = from[0].length;
    float[] fromXA = from[INDEX_X];
    float[] fromYA = from[INDEX_Y];
    float[] toLatA = to[INDEX_LAT];
    float[] toLonA = to[INDEX_LON];
    double phi, lam;
    double toLat, toLon;
    for (int i = 0; i < cnt; i++) {
      double fromX = fromXA[i] - falseEasting;
      double fromY = fromYA[i] - falseNorthing;

      double rho = Math.sqrt(fromX * fromX + fromY * fromY);
      double c = 2.0 * Math.atan2(rho, 2.0 * scale);
      double sinc = Math.sin(c);
      double cosc = Math.cos(c);

      if (Math.abs(rho) < TOLERANCE) {
        phi = latt;
      } else {
        phi = Math.asin(cosc * sinlatt
                + fromY * sinc * coslatt / rho);
      }

      toLat = Math.toDegrees(phi);

      if ((Math.abs(fromX) < TOLERANCE)
              && (Math.abs(fromY) < TOLERANCE)) {
        lam = lont;
      } else if (Math.abs(coslatt) < TOLERANCE) {
        lam = lont + Math.atan2(fromX, ((latt > 0)
                ? -fromY
                : fromY));
      } else {
        lam = lont
                + Math.atan2(fromX * sinc,
                rho * coslatt * cosc
                        - fromY * sinc * sinlatt);
      }

      toLon = Math.toDegrees(lam);

      toLatA[i] = (float) toLat;
      toLonA[i] = (float) toLon;
    }
    return to;
  }
public float[][] projToLatLon(float[][] from, float[][] to) {
    int cnt = from[0].length;
    float[] fromXA = from[INDEX_X];
    float[] fromYA = from[INDEX_Y];
    float[] toLatA = to[INDEX_LAT];
    float[] toLonA = to[INDEX_LON];
    double phi, lam;
    double toLat, toLon;
    for (int i = 0; i < cnt; i++) {
      double fromX = fromXA[i] - falseEasting;
      double fromY = fromYA[i] - falseNorthing;

      double rho = Math.sqrt(fromX * fromX + fromY * fromY);
      double c = 2.0 * Math.atan2(rho, 2.0 * scale);
      double sinc = Math.sin(c);
      double cosc = Math.cos(c);

      if (Math.abs(rho) < TOLERANCE) {
        phi = latt;
      } else {
        phi = Math.asin(cosc * sinlatt
                + fromY * sinc * coslatt / rho);
      }

      toLat = Math.toDegrees(phi);

      if ((Math.abs(fromX) < TOLERANCE)
              && (Math.abs(fromY) < TOLERANCE)) {
        lam = lont;
      } else if (Math.abs(coslatt) < TOLERANCE) {
        lam = lont + Math.atan2(fromX, ((latt > 0)
                ? -fromY
                : fromY));
      } else {
        lam = lont
                + Math.atan2(fromX * sinc,
                rho * coslatt * cosc
                        - fromY * sinc * sinlatt);
      }

      toLon = Math.toDegrees(lam);

      toLatA[i] = (float) toLat;
      toLonA[i] = (float) toLon;
    }
    return to;
  }
public float [ ] [ ] projToLatLon ( float [ ] [ ] from , float [ ] [ ] to ) { int cnt = from [ 0 ] . length ; float [ ] fromXA = from [ INDEX_X ] ; float [ ] fromYA = from [ INDEX_Y ] ; float [ ] toLatA = to [ INDEX_LAT ] ; float [ ] toLonA = to [ INDEX_LON ] ; double phi , lam ; double toLat , toLon ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromX = fromXA [ i ] - falseEasting ; double fromY = fromYA [ i ] - falseNorthing ; double rho = Math . sqrt ( fromX * fromX + fromY * fromY ) ; double c = 2.0 * Math . atan2 ( rho , 2.0 * scale ) ; double sinc = Math . sin ( c ) ; double cosc = Math . cos ( c ) ; if ( Math . abs ( rho ) < TOLERANCE ) { phi = latt ; } else { phi = Math . asin ( cosc * sinlatt + fromY * sinc * coslatt / rho ) ; } toLat = Math . toDegrees ( phi ) ; if ( ( Math . abs ( fromX ) < TOLERANCE ) && ( Math . abs ( fromY ) < TOLERANCE ) ) { lam = lont ; } else if ( Math . abs ( coslatt ) < TOLERANCE ) { lam = lont + Math . atan2 ( fromX , ( ( latt > 0 ) ? - fromY : fromY ) ) ; } else { lam = lont + Math . atan2 ( fromX * sinc , rho * coslatt * cosc - fromY * sinc * sinlatt ) ; } toLon = Math . toDegrees ( lam ) ; toLatA [ i ] = ( float ) toLat ; toLonA [ i ] = ( float ) toLon ; } return to ; }
Convert projection coordinates to lat/lon coordinate.

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