cdm/src/main/java/ucar/unidata/geoloc/projection/RotatedLatLon.java
private double[] rotate(double[] lonlat, double rot1, double rot2, double s) {

    /* original code
      double e = DEG2RAD * (lonlat[0] - rot1); //east
      double n = DEG2RAD * lonlat[1]; //north
      double cn = Math.cos(n);
      double x = cn * Math.cos(e);
      double y = cn * Math.sin(e);
      double z = Math.sin(n);
      double x2 = cosDlat * x + s * z;
      double z2 = -s * x + cosDlat * z;
      double R = Math.sqrt(x2 * x2 + y * y);
      double e2 = Math.atan2(y, x2);
      double n2 = Math.atan2(z2, R);
      double rlon = RAD2DEG * e2 - rot2;
      double rlat = RAD2DEG * n2;
      return new double[]{rlon, rlat};
     */

    double e = Math.toRadians(lonlat[0] - rot1); //east
    double n = Math.toRadians(lonlat[1]); //north
    double cn = Math.cos(n);
    double x = cn * Math.cos(e);
    double y = cn * Math.sin(e);
    double z = Math.sin(n);
    double x2 = cosDlat * x + s * z;
    double z2 = -s * x + cosDlat * z;
    double R = Math.sqrt(x2 * x2 + y * y);
    double e2 = Math.atan2(y, x2);
    double n2 = Math.atan2(z2, R);
    double rlon = Math.toDegrees(e2) - rot2;
    double rlat =  Math.toDegrees(n2);
    return new double[]{rlon, rlat};

  }
private double[] rotate(double[] lonlat, double rot1, double rot2, double s) {

    /* original code
      double e = DEG2RAD * (lonlat[0] - rot1); //east
      double n = DEG2RAD * lonlat[1]; //north
      double cn = Math.cos(n);
      double x = cn * Math.cos(e);
      double y = cn * Math.sin(e);
      double z = Math.sin(n);
      double x2 = cosDlat * x + s * z;
      double z2 = -s * x + cosDlat * z;
      double R = Math.sqrt(x2 * x2 + y * y);
      double e2 = Math.atan2(y, x2);
      double n2 = Math.atan2(z2, R);
      double rlon = RAD2DEG * e2 - rot2;
      double rlat = RAD2DEG * n2;
      return new double[]{rlon, rlat};
     */

    double e = Math.toRadians(lonlat[0] - rot1); //east
    double n = Math.toRadians(lonlat[1]); //north
    double cn = Math.cos(n);
    double x = cn * Math.cos(e);
    double y = cn * Math.sin(e);
    double z = Math.sin(n);
    double x2 = cosDlat * x + s * z;
    double z2 = -s * x + cosDlat * z;
    double R = Math.sqrt(x2 * x2 + y * y);
    double e2 = Math.atan2(y, x2);
    double n2 = Math.atan2(z2, R);
    double rlon = Math.toDegrees(e2) - rot2;
    double rlat =  Math.toDegrees(n2);
    return new double[]{rlon, rlat};

  }
private double [ ] rotate ( double [ ] lonlat , double rot1 , double rot2 , double s ) { /* original code
      double e = DEG2RAD * (lonlat[0] - rot1); //east
      double n = DEG2RAD * lonlat[1]; //north
      double cn = Math.cos(n);
      double x = cn * Math.cos(e);
      double y = cn * Math.sin(e);
      double z = Math.sin(n);
      double x2 = cosDlat * x + s * z;
      double z2 = -s * x + cosDlat * z;
      double R = Math.sqrt(x2 * x2 + y * y);
      double e2 = Math.atan2(y, x2);
      double n2 = Math.atan2(z2, R);
      double rlon = RAD2DEG * e2 - rot2;
      double rlat = RAD2DEG * n2;
      return new double[]{rlon, rlat};
     */ double e = Math . toRadians ( lonlat [ 0 ] - rot1 ) ; //east
 double n = Math . toRadians ( lonlat [ 1 ] ) ; //north
 double cn = Math . cos ( n ) ; double x = cn * Math . cos ( e ) ; double y = cn * Math . sin ( e ) ; double z = Math . sin ( n ) ; double x2 = cosDlat * x + s * z ; double z2 = - s * x + cosDlat * z ; double R = Math . sqrt ( x2 * x2 + y * y ) ; double e2 = Math . atan2 ( y , x2 ) ; double n2 = Math . atan2 ( z2 , R ) ; double rlon = Math . toDegrees ( e2 ) - rot2 ; double rlat = Math . toDegrees ( n2 ) ; return new double [ ] { rlon , rlat } ; }
Tor's transform algorithm renamed to rotate for clarity
Tor s transform algorithm renamed to rotate for clarity