Skip to content

Commit

Permalink
Assume Moon's equatorial coordinates are geocentric
Browse files Browse the repository at this point in the history
During my researches, I discover that equatorial coordinates don't
necessarily have to be geocentric. Thinking I would have to make the
difference in the Moon's public API, I created
`Moon#apparent_geocentric_equatorial_coordinates`.

After some more work, I understood only the geocentric parallax was
necessary to apply to have topocentric coordinates. Because they are
only necessary for topocentric coordinates, such as horizontal
coordinates, and for consistent method names, this change renames
`Moon#apparent_geocentric_equatorial_coordinates` into
`Moon#aparent_equatorial_coordinates`.

No behaviour change was introduced.
  • Loading branch information
rhannequin committed May 24, 2024
1 parent 147caee commit 500db51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
11 changes: 5 additions & 6 deletions lib/astronoby/bodies/moon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ def apparent_ecliptic_coordinates

# @return [Astronoby::Coordinates::Equatorial] Apparent geocentric
# equatorial coordinates of the Moon
def apparent_geocentric_equatorial_coordinates
@apparent_geocentric_equatorial_coordinates ||= begin
ecliptic = apparent_ecliptic_coordinates
ecliptic.to_apparent_equatorial(epoch: Epoch.from_time(@time))
end
def apparent_equatorial_coordinates
@apparent_equatorial_coordinates ||=
apparent_ecliptic_coordinates
.to_apparent_equatorial(epoch: Epoch.from_time(@time))
end

def horizontal_coordinates(observer:)
Expand All @@ -51,7 +50,7 @@ def horizontal_coordinates(observer:)
longitude: observer.longitude,
elevation: observer.elevation,
time: @time,
coordinates: apparent_geocentric_equatorial_coordinates,
coordinates: apparent_equatorial_coordinates,
distance: distance
)

Expand Down
12 changes: 6 additions & 6 deletions spec/astronoby/bodies/moon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
end
end

describe "#apparent_geocentric_equatorial_coordinates" do
describe "#apparent_equatorial_coordinates" do
# Source:
# Title: Astronomical Algorithms
# Author: Jean Meeus
Expand All @@ -133,7 +133,7 @@
time -= Astronoby::Util::Time.terrestrial_universal_time_delta(time)
moon = described_class.new(time: time)

coordinates = moon.apparent_geocentric_equatorial_coordinates
coordinates = moon.apparent_equatorial_coordinates

expect(coordinates.right_ascension.str(:hms)).to eq "8h 58m 45.21s"
# Result from the book: 8h 58m 45.1s
Expand All @@ -152,7 +152,7 @@
it "returns the apparent geocentric equatorial coordinates for 2015-01-01" do
moon = described_class.new(time: Time.new(2015, 1, 1, 22, 0, 0, "-05:00"))

coordinates = moon.apparent_geocentric_equatorial_coordinates
coordinates = moon.apparent_equatorial_coordinates

expect(coordinates.right_ascension.str(:hms)).to eq "4h 16m 35.1442s"
# Result from the book: 4h 15m 27.7703s (4.257714h)
Expand All @@ -171,7 +171,7 @@
it "returns the apparent geocentric equatorial coordinates for 2000-08-09" do
moon = described_class.new(time: Time.new(2000, 8, 9, 12, 0, 0, "-05:00"))

coordinates = moon.apparent_geocentric_equatorial_coordinates
coordinates = moon.apparent_equatorial_coordinates

expect(coordinates.right_ascension.str(:hms)).to eq "17h 6m 3.1276s"
# Result from the book: 17h 5m 41.2872s (17.094802h)
Expand All @@ -190,7 +190,7 @@
it "returns the apparent geocentric equatorial coordinates for 2010-05-15" do
moon = described_class.new(time: Time.new(2010, 5, 15, 14, 30, 0, "-04:00"))

coordinates = moon.apparent_geocentric_equatorial_coordinates
coordinates = moon.apparent_equatorial_coordinates

expect(coordinates.right_ascension.str(:hms)).to eq "5h 0m 44.3733s"
# Result from the book: 4h 59m 54.1103s (4.998364h)
Expand All @@ -209,7 +209,7 @@
it "returns the apparent geocentric equatorial coordinates for 2003-09-01" do
moon = described_class.new(time: Time.utc(2003, 9, 1))

coordinates = moon.apparent_geocentric_equatorial_coordinates
coordinates = moon.apparent_equatorial_coordinates

expect(coordinates.right_ascension.str(:hms)).to eq "14h 12m 12.2352s"
# Result from the book: 14h 12m 42s
Expand Down

0 comments on commit 500db51

Please sign in to comment.