public static LatLonPoint moonPosition(long mssue){
  GregorianCalendar cal=new GregorianCalendar();
  cal.setTime(new Date(mssue));
  double julianDate=calculateJulianDate(cal);
  long gmtOffset=cal.get(Calendar.ZONE_OFFSET);
  cal.setTime(new Date(mssue - gmtOffset));
  double numDaysSinceEpoch=((mssue / 1000) - EPOCH_TIME_SECS) / (24.0f * 3600.0f);
  double M0=sunMeanAnomaly(numDaysSinceEpoch);
  double sunLongitude=sunEclipticLongitude(M0);
  double el=(13.1763966 * numDaysSinceEpoch * Math.PI / 180) + el0;
  el=adjustWithin2PI(el);
  double Mm=el - (.1114041 * numDaysSinceEpoch * Math.PI / 180) - P0;
  Mm=adjustWithin2PI(Mm);
  double N=N0 - (.0529539 * numDaysSinceEpoch * Math.PI / 180);
  N=adjustWithin2PI(N);
  double C=el - sunLongitude;
  double Ev=1.2739 * Math.sin(2 * C - Mm);
  double Ae=.1858 * Math.sin(M0);
  double A3=.37 * Math.sin(M0);
  double Mmp=Mm + Ev - Ae - A3;
  double Ec=6.2886 * Math.sin(Mmp);
  double A4=0.214 * Math.sin(2 * Mmp);
  double elp=el + Ev + Ec - Ae + A4;
  double V=.6583 * Math.sin(2 * (elp - sunLongitude));
  double elpp=elp + V;
  double Np=N - (.16 * Math.sin(M0));
  double y=Math.sin(elpp - Np) * Math.cos(eye);
  double x=Math.cos(elpp - Np);
  double amb=Math.atan2(y,x);
  double lambda_m=amb + Np;
  double beta_m=Math.asin(Math.sin(elpp - Np) * Math.sin(eye));
  double moonAscension=eclipticToEquatorialAscension(lambda_m,beta_m);
  double moonDeclination=eclipticToEquatorialDeclination(lambda_m,beta_m);
  double tmpAscension=moonAscension - (MoreMath.TWO_PI / 24) * greenwichSiderealTime(julianDate,cal);
  return new LatLonPoint.Double(moonDeclination,tmpAscension,true);
}

public static LatLonPoint moonPosition ( long mssue ) { GregorianCalendar cal = new GregorianCalendar ( ) ; cal . setTime ( new Date ( mssue ) ) ; double julianDate = calculateJulianDate ( cal ) ; long gmtOffset = cal . get ( Calendar . ZONE_OFFSET ) ; cal . setTime ( new Date ( mssue - gmtOffset ) ) ; double numDaysSinceEpoch = ( ( mssue / 1000 ) - EPOCH_TIME_SECS ) / ( 24.0f * 3600.0f ) ; double M0 = sunMeanAnomaly ( numDaysSinceEpoch ) ; double sunLongitude = sunEclipticLongitude ( M0 ) ; double el = ( 13.1763966 * numDaysSinceEpoch * Math . PI / 180 ) + el0 ; el = adjustWithin2PI ( el ) ; double Mm = el - ( .1114041 * numDaysSinceEpoch * Math . PI / 180 ) - P0 ; Mm = adjustWithin2PI ( Mm ) ; double N = N0 - ( .0529539 * numDaysSinceEpoch * Math . PI / 180 ) ; N = adjustWithin2PI ( N ) ; double C = el - sunLongitude ; double Ev = 1.2739 * Math . sin ( 2 * C - Mm ) ; double Ae = .1858 * Math . sin ( M0 ) ; double A3 = .37 * Math . sin ( M0 ) ; double Mmp = Mm + Ev - Ae - A3 ; double Ec = 6.2886 * Math . sin ( Mmp ) ; double A4 = 0.214 * Math . sin ( 2 * Mmp ) ; double elp = el + Ev + Ec - Ae + A4 ; double V = .6583 * Math . sin ( 2 * ( elp - sunLongitude ) ) ; double elpp = elp + V ; double Np = N - ( .16 * Math . sin ( M0 ) ) ; double y = Math . sin ( elpp - Np ) * Math . cos ( eye ) ; double x = Math . cos ( elpp - Np ) ; double amb = Math . atan2 ( y , x ) ; double lambda_m = amb + Np ; double beta_m = Math . asin ( Math . sin ( elpp - Np ) * Math . sin ( eye ) ) ; double moonAscension = eclipticToEquatorialAscension ( lambda_m , beta_m ) ; double moonDeclination = eclipticToEquatorialDeclination ( lambda_m , beta_m ) ; double tmpAscension = moonAscension - ( MoreMath . TWO_PI / 24 ) * greenwichSiderealTime ( julianDate , cal ) ; return new LatLonPoint . Double ( moonDeclination , tmpAscension , true ) ; }
given the number of milliseconds since the unix epoch , compute position on the earth ( lat , lon ) such that moon is directly overhead . from duffett - smith , chapter 65 . note : this is acting like it works , but i don ' t have anything to test it against . no promises .
