Class: Astronoby::Topocentric
- Inherits:
-
ReferenceFrame
- Object
- ReferenceFrame
- Astronoby::Topocentric
- Defined in:
- lib/astronoby/reference_frames/topocentric.rb
Overview
Topocentric reference frame. Represents a body’s position as seen from a specific observer on Earth’s surface, accounting for the observer’s geocentric position and Earth rotation.
Instance Attribute Summary
Attributes inherited from ReferenceFrame
#center, #instant, #position, #target_body, #velocity
Class Method Summary collapse
-
.build_from_apparent(apparent:, observer:, instant:, target_body:) ⇒ Astronoby::Topocentric
Builds a topocentric frame from an apparent frame and observer.
Instance Method Summary collapse
-
#ecliptic ⇒ Astronoby::Coordinates::Ecliptic
Ecliptic coordinates at the current instant (true ecliptic and equinox of date).
-
#horizontal(refraction: false) ⇒ Astronoby::Coordinates::Horizontal
Converts to horizontal coordinates (azimuth/altitude).
-
#initialize(position:, velocity:, instant:, center:, target_body:, observer:) ⇒ Topocentric
constructor
A new instance of Topocentric.
Methods inherited from ReferenceFrame
#distance, #equatorial, #separation_from
Constructor Details
#initialize(position:, velocity:, instant:, center:, target_body:, observer:) ⇒ Topocentric
Returns a new instance of Topocentric.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/astronoby/reference_frames/topocentric.rb', line 49 def initialize( position:, velocity:, instant:, center:, target_body:, observer: ) super( position: position, velocity: velocity, instant: instant, center: center, target_body: target_body ) @observer = observer end |
Class Method Details
.build_from_apparent(apparent:, observer:, instant:, target_body:) ⇒ Astronoby::Topocentric
Builds a topocentric frame from an apparent frame and observer.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/astronoby/reference_frames/topocentric.rb', line 15 def self.build_from_apparent( apparent:, observer:, instant:, target_body: ) matrix = observer.earth_fixed_rotation_matrix_for(instant) observer_position = Distance.vector_from_meters( matrix * observer.geocentric_position.map(&:m) ) observer_velocity = Velocity.vector_from_mps( matrix * observer.geocentric_velocity.map(&:mps) ) position = apparent.position - observer_position velocity = apparent.velocity - observer_velocity new( position: position, velocity: velocity, instant: instant, center: Center.topocentric(observer), target_body: target_body, observer: observer ) end |
Instance Method Details
#ecliptic ⇒ Astronoby::Coordinates::Ecliptic
Returns ecliptic coordinates at the current instant (true ecliptic and equinox of date).
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/astronoby/reference_frames/topocentric.rb', line 69 def ecliptic @ecliptic ||= begin return Coordinates::Ecliptic.zero if distance.zero? equatorial.to_ecliptic( instant: @instant, obliquity: TrueObliquity.at(@instant) ) end end |
#horizontal(refraction: false) ⇒ Astronoby::Coordinates::Horizontal
Converts to horizontal coordinates (azimuth/altitude).
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/astronoby/reference_frames/topocentric.rb', line 85 def horizontal(refraction: false) horizontal = equatorial.to_horizontal( time: @instant.to_time, observer: @observer ) if refraction Refraction.correct_horizontal_coordinates(coordinates: horizontal) else horizontal end end |