Skyfield: why are these coordinates negative?

Question:

I’ve an example of how to get a geocentric position of Mars (x,y,z cords) relative to the Earth, using class skyfield.positionlib.Geocentric(position_au, velocity_au_per_d=None, t=None, center=None, target=None) (without accounting for light-travel time or the effect of relativity on the light itself).

There it is:

t = ts.utc(2022, 9, 16)  

e = earth.at(t) 
m = mars.at(t)  

p = e.position.au - m.position.au 
if e.velocity is None or m.velocity is None:     
   v = None 
else:     
   v = e.velocity.au_per_d - m.velocity.au_per_d  

astrometric = e.observe(mars).xyz 
geocentric = Geocentric(p, v, e.t).xyz  

print(astrometric) 
print(geocentric) 

Output:

[0.24429594 0.77369215 0.31846684] au

[-0.24426364 -0.77375285 -0.31849556] au

Is it good? And why second coords are < 0?

P.S. Sun coords are more confusing! Why?

[-0.99764586 0.11540818 0.05003455] au

[ 0.99764586 -0.11540813 -0.05003453] au

Asked By: denken

||

Answers:

The way that vector math works, a positive vector +v goes toward that position, whereas a negative vector -v goes backwards away from that position to the origin. So if you say a - b with two vectors, you are asking to be taken mathematically from the place where b is and to the place where a is.

So your math for v = is backwards. You are asking for the vector going Mars → Earth, or, in other words, for the mars-centric position of Earth, whereas you really want the opposite.

Answered By: Brandon Rhodes
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.