The question could be made equivalent to this:

Given two points on a sphere p1 and p2 find theta and phi such that

Rx(phi)*Rz(theta)*p1=p2

where Rx(phi) is a rotation about x axis by phidegrees and Rz(theta) is a rotation about z axis by theta degrees