private static void calculatePolynomialApproximation(ApparentPlace ap,
			double t0, double ghapoly[], double decpoly[], double hppoly[]) {
		double gha[] = new double[3];
		double dec[] = new double[3];
		double hp[] = new double[3];
		double earthRadius = 6378137.0/ap.getObserver().getEphemeris().getAU();
		boolean isMoon = ap.getTarget().getBodyCode() == JPLEphemeris.MOON;
		
		for (int i = 0; i < 3; i++) {
			double t = t0 + 0.5 * (double)i;
			
			try {
				ap.calculateApparentPlace(t);
			}
			catch (JPLEphemerisException jee) {
			}
			
			double gast = ap.getEarthRotationModel().greenwichApparentSiderealTime(t);
			
			gha[i] = (gast - ap.getRightAscension()) % TWOPI;
			
			if (gha[i] < 0.0)
				gha[i] += TWOPI;
			
			dec[i] = ap.getDeclination();
			
			if (isMoon) {
				hp[i] = Math.asin(earthRadius/ap.getGeometricDistance());
			}
		}
		
		while (gha[1] < gha[0])
			gha[1] += TWOPI;
		
		while (gha[2] < gha[1])
			gha[2] += TWOPI;
		
		calculatePolynomialCoefficients(gha, ghapoly);
		calculatePolynomialCoefficients(dec, decpoly);
		
		if (isMoon)
			calculatePolynomialCoefficients(hp, hppoly);
	}