Converting Geocentric Coordinates into Ecliptic Coordinates makes it easier to take into account the precession that takes place over time. In each coordinate frame the principal directions are that of the Equinox, E, the Solstice directions, S and S', and that of the Poles, P and P'. In each frame the direction of the Equinox is the same and we can use primes to indicate the two directions in the Ecliptic frame of reference. The two frames are related by a rotation through the angle of the Inclination of the Ecliptic, ε, about the direction of the Equinox. One can compute these vectors in the Ecliptic frame given those in the Geocentric frame by right multiplying the basis vectors by a rotation matrix and vice versa. To go back to the original basis we do the same but with ε replaced by -ε.
Any direction in the Geocentric frame, e_G, can be found by starting at the Equinox and rotating an angle of α along the equator and then an angle δ towards the pole. The same direction can be found in the Ecliptic frame, e_K, with the angles labeled λ and β. Each representation of the direction can be used to find the components in the Ecliptic frame by repeatedly taking the dot product with one of the principal directions in the Ecliptic frame. The result is a relation between the two sets of angles.
It is easiest to convert from one set of angles to the other if we use the vector representing the direction as an intermediary. The relation between them suggests the use of the following functions.
The function "xy2φ" defined above is the equivalent of the "angle" function found in Mathcad. Converting from the direction along the poles is treated separately since both of the components used are zero. The angle λ is indeterminate and is arbitrarily set to zero. Under these circumstances some other condition might be useful in determining λ. Sgn is the sign function*.
Going back to the Geocentric frame after precession in the Ecliptic frame is essentially the same but again one uses -ε instead of ε. Precession is a similar rotation about the Pole of the Ecliptic but only involves adding an angle corresponding to the accumulated precession to the Ecliptic Longitude, λ. The Ecliptic Latitude, β, is unchanged by precession.
*Supplemental: Made a slight change to the definition so xy2φ(1,0) = 0°. Another name for the sign function is signum. The earlier sgn(x) assumed the usual rule for intergers with only negative numbers carring a negative sign. There are older two valued definitions of the sgn function so one has to be careful. The condition y<0 is equivalent to sgn(y)=-1 so sgn(y) is only needed if zero needs special consideration.