-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce MeanOfDate reference frame (#138)
> The mean coordinates of the date are related to the ecliptic or the mean equator and the mean equinox of the date. These are the geometric coordinates corrected for the precessional motion of the Earth’s rotation axis. This introduces `MeanOfDate` reference frame, from `Geometric`, with precession of the date applied. By "date", we actually mean "instant", although the precession only changes slightly from one day to the next. In Astronoby, the `MeanOfDate` reference frame is geocentric (like `Astrometric`). Mean of date coordinates don't _have to_ be geocentric, but that's the design choice for Astronoby at the moment. Like `Geometric` and `Astrometry`, the `MeanOfDate` reference frame offers equatorial and ecliptic coordinates, among with the Cartesian position and velocity, and the distance to the Earth's center. ```rb instant = Astronoby::Instant.from_time(Time.utc(2025, 2, 7)) ephem = Astronoby::Ephem.load("de440s.bsp") sun = Astronoby::Sun.new(instant: instant, ephem: ephem) sun.mean_of_date.position.map(&:km).map(&:round) # => Vector[110436790, -89767243, -38912451] sun.mean_of_date.velocity.map(&:kmpd).map(&:round) # => Vector[1747570, 1776918, 770305] sun.mean_of_date.equatorial.right_ascension.str(:hms) # => "21h 23m 34.6729s" sun.mean_of_date.equatorial.declination.str(:dms) # => "-15° 17′ 31.1747″" sun.mean_of_date.ecliptic.latitude.str(:dms) # => "+0° 0′ 0.4003″" sun.mean_of_date.ecliptic.longitude.str(:dms) # => "+318° 27′ 41.6839″" sun.mean_of_date.distance.km.round # => 147541931 ```
- Loading branch information
1 parent
f26cb05
commit 3ee65c1
Showing
18 changed files
with
852 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
module Astronoby | ||
class MeanOfDate < ReferenceFrame | ||
def self.build_from_geometric( | ||
ephem:, | ||
instant:, | ||
target_geometric:, | ||
target_body: | ||
) | ||
earth_geometric = Earth.geometric(ephem: ephem, instant: instant) | ||
position = target_geometric.position - earth_geometric.position | ||
velocity = target_geometric.velocity - earth_geometric.velocity | ||
precession_matrix = Precession.matrix_for(instant) | ||
corrected_position = Vector | ||
.elements(precession_matrix * position.map(&:m)) | ||
.map { Distance.from_meters(_1) } | ||
corrected_velocity = Vector[*precession_matrix * velocity | ||
.map(&:aupd)].map { Velocity.from_astronomical_units_per_day(_1) } | ||
|
||
new( | ||
position: corrected_position, | ||
velocity: corrected_velocity, | ||
instant: instant, | ||
center_identifier: SolarSystemBody::EARTH, | ||
target_body: target_body | ||
) | ||
end | ||
|
||
def ecliptic | ||
@ecliptic ||= begin | ||
return Coordinates::Ecliptic.zero if distance.zero? | ||
|
||
equatorial.to_ecliptic(epoch: @instant.tdb) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.