// (C)2007 Attila Kovacs <attila@submm.caltech.edu>



public abstract class ZenithalProjection extends SphericalProjection {

	public ZenithalProjection() { 
		isPolar = true; 
		referenceNative.set(0.0, 0.5 * Math.PI);
	}
		
	public final double phi(CoordinatePair offset) {
		return Vector2D.getAngle(-offset.y, offset.x);
	}
	
	public final double theta(CoordinatePair offset) {
		return thetaOfR(Math.sqrt(offset.x*offset.x + offset.y*offset.y));
	}
	
	public final void getOffsets(double theta, double phi, CoordinatePair toOffset) {
		double R = R(theta);
		// What is in Calabretta and Greisen 2002
		toOffset.x = R * Math.sin(phi);
		toOffset.y = -R * Math.cos(phi);
	}
	
	
	public abstract double R(double theta);
	
	public abstract double thetaOfR(double value);
	

}
