Skip to content

Commit

Permalink
Fix #355 by swapping sign of subtracted velocity
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-rhodes committed Apr 10, 2020
1 parent 28efe9b commit bd37612
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Changelog
method that returns their raw ITRF coordinates.
`#354 <https://github.com/skyfielders/python-skyfield/issues/354>`_

* Fixed the sign of the velocity vector when two vectors are directly
geometrically subtracted.
`#355 <https://github.com/skyfielders/python-skyfield/issues/355>`_

1.18 — 2020 March 26
--------------------

Expand Down
2 changes: 1 addition & 1 deletion skyfield/positionlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __sub__(self, body):
if self.velocity is None or body.velocity is None:
v = None
else:
v = body.velocity.au_per_d - self.velocity.au_per_d
v = self.velocity.au_per_d - body.velocity.au_per_d
return ICRF(p, v, self.t)

def __getitem__(self, i):
Expand Down
7 changes: 7 additions & 0 deletions skyfield/tests/test_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
from skyfield.positionlib import ICRF
from skyfield.starlib import Star

def test_subtraction():
p0 = ICRF((10,20,30), (40,50,60))
p1 = ICRF((1,2,3), (4,5,6))
p = p0 - p1
assert tuple(p.position.au) == (9, 18, 27)
assert tuple(p.velocity.au_per_d) == (36, 45, 54)

def test_J2000_ecliptic_coordinates_with_and_without_a_time_array():
p0 = ICRF((1,0,0))
p1 = ICRF((0,1,0))
Expand Down

0 comments on commit bd37612

Please sign in to comment.