cdm/src/main/java/ucar/unidata/geoloc/projection/FlatEarth.java
public float[][] latLonToProj(float[][] from, float[][] to, int latIndex,
                                int lonIndex) {
    int cnt = from[0].length;
    float[] fromLatA = from[latIndex];
    float[] fromLonA = from[lonIndex];
    float[] resultXA = to[INDEX_X];
    float[] resultYA = to[INDEX_Y];
    double toX, toY;

    for (int i = 0; i < cnt; i++) {
      double fromLat = fromLatA[i];
      double fromLon = fromLonA[i];

      fromLat = Math.toRadians(fromLat);
      double dy = radius * (fromLat - lat0);
      double dx = radius * Math.cos(fromLat)
              * (Math.toRadians(fromLon) - lon0);


      toX = cosRot * dx - sinRot * dy;
      toY = sinRot * dx + cosRot * dy;

      resultXA[i] = (float) toX;
      resultYA[i] = (float) toY;
    }
    return to;
  }
public float[][] latLonToProj(float[][] from, float[][] to, int latIndex,
                                int lonIndex) {
    int cnt = from[0].length;
    float[] fromLatA = from[latIndex];
    float[] fromLonA = from[lonIndex];
    float[] resultXA = to[INDEX_X];
    float[] resultYA = to[INDEX_Y];
    double toX, toY;

    for (int i = 0; i < cnt; i++) {
      double fromLat = fromLatA[i];
      double fromLon = fromLonA[i];

      fromLat = Math.toRadians(fromLat);
      double dy = radius * (fromLat - lat0);
      double dx = radius * Math.cos(fromLat)
              * (Math.toRadians(fromLon) - lon0);


      toX = cosRot * dx - sinRot * dy;
      toY = sinRot * dx + cosRot * dy;

      resultXA[i] = (float) toX;
      resultYA[i] = (float) toY;
    }
    return to;
  }
public float [ ] [ ] latLonToProj ( float [ ] [ ] from , float [ ] [ ] to , int latIndex , int lonIndex ) { int cnt = from [ 0 ] . length ; float [ ] fromLatA = from [ latIndex ] ; float [ ] fromLonA = from [ lonIndex ] ; float [ ] resultXA = to [ INDEX_X ] ; float [ ] resultYA = to [ INDEX_Y ] ; double toX , toY ; for ( int i = 0 ; i < cnt ; i ++ ) { double fromLat = fromLatA [ i ] ; double fromLon = fromLonA [ i ] ; fromLat = Math . toRadians ( fromLat ) ; double dy = radius * ( fromLat - lat0 ) ; double dx = radius * Math . cos ( fromLat ) * ( Math . toRadians ( fromLon ) - lon0 ) ; toX = cosRot * dx - sinRot * dy ; toY = sinRot * dx + cosRot * dy ; resultXA [ i ] = ( float ) toX ; resultYA [ i ] = ( float ) toY ; } 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,
where to[0][i], to[1][i] is the (x,y) coordinate
of the ith point
@param latIndex index of latitude in "from"
@param lonIndex index of longitude in "from"
@return the "to" array.
Convert lat / lon coordinates to projection coordinates .