# Calculating the Suns vector and distance from the Earth at one time

I am developing a C++ program where I'd like to be able to see the Suns direction vector and distance from Earth at a given time, since 2000 Jan 0.0 TDT. The reference frame I want to calculate it is from the Earth, with the up vector running along the axis of the poles.

What I have tried so far has been based off http://www.stjarnhimlen.se/comp/tutorial.html#5, but its not entirely the output I'm after; and I feel I can probably achieve this much easier.

Any ideas? Sorry if this is off-topic.

-

For stuff like that, JPL NAIF's SPICE toolkit is useful. http://naif.jpl.nasa.gov/naif/ It allows determination of vectors between any heavenly bodies in our solar system, get their orientations, allows for choosing between where a body appears to be due to the finite speed of light vs. where it actually is at the same time, account for leap seconds and so on.

-