Class: Astronoby::Coordinates::Equatorial
- Inherits:
-
Object
- Object
- Astronoby::Coordinates::Equatorial
- Defined in:
- lib/astronoby/coordinates/equatorial.rb
Instance Attribute Summary collapse
-
#declination ⇒ Object
readonly
Returns the value of attribute declination.
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#hour_angle ⇒ Object
readonly
Returns the value of attribute hour_angle.
-
#right_ascension ⇒ Object
readonly
Returns the value of attribute right_ascension.
Instance Method Summary collapse
- #compute_hour_angle(time:, longitude:) ⇒ Object
-
#initialize(declination:, right_ascension:, hour_angle: nil, epoch: Epoch::DEFAULT_EPOCH) ⇒ Equatorial
constructor
A new instance of Equatorial.
-
#to_ecliptic(epoch:) ⇒ Object
Source: Title: Celestial Calculations Author: J.
- #to_epoch(epoch) ⇒ Object
- #to_horizontal(time:, observer:) ⇒ Object
Constructor Details
#initialize(declination:, right_ascension:, hour_angle: nil, epoch: Epoch::DEFAULT_EPOCH) ⇒ Equatorial
Returns a new instance of Equatorial.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 8 def initialize( declination:, right_ascension:, hour_angle: nil, epoch: Epoch::DEFAULT_EPOCH ) @right_ascension = right_ascension @declination = declination @hour_angle = hour_angle @epoch = epoch end |
Instance Attribute Details
#declination ⇒ Object (readonly)
Returns the value of attribute declination.
6 7 8 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 6 def declination @declination end |
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
6 7 8 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 6 def epoch @epoch end |
#hour_angle ⇒ Object (readonly)
Returns the value of attribute hour_angle.
6 7 8 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 6 def hour_angle @hour_angle end |
#right_ascension ⇒ Object (readonly)
Returns the value of attribute right_ascension.
6 7 8 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 6 def right_ascension @right_ascension end |
Instance Method Details
#compute_hour_angle(time:, longitude:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 20 def compute_hour_angle(time:, longitude:) lst = GreenwichSiderealTime .from_utc(time.utc) .to_lst(longitude: longitude) ha = (lst.time - @right_ascension.hours) ha += Constants::HOURS_PER_DAY if ha.negative? Angle.from_hours(ha) end |
#to_ecliptic(epoch:) ⇒ Object
Source:
Title: Celestial Calculations
Author: J. L. Lawrence
Edition: MIT Press
Chapter: 4 - Orbits and Coordinate Systems
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 60 def to_ecliptic(epoch:) mean_obliquity = MeanObliquity.for_epoch(epoch) y = Angle.from_radians( @right_ascension.sin * mean_obliquity.cos + @declination.tan * mean_obliquity.sin ) x = Angle.from_radians(@right_ascension.cos) r = Angle.atan(y.radians / x.radians) longitude = Util::Trigonometry.adjustement_for_arctangent(y, x, r) latitude = Angle.asin( @declination.sin * mean_obliquity.cos - @declination.cos * mean_obliquity.sin * @right_ascension.sin ) Ecliptic.new( latitude: latitude, longitude: longitude ) end |
#to_epoch(epoch) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 82 def to_epoch(epoch) Precession.for_equatorial_coordinates( coordinates: self, epoch: epoch ) end |
#to_horizontal(time:, observer:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/astronoby/coordinates/equatorial.rb', line 31 def to_horizontal(time:, observer:) latitude = observer.latitude longitude = observer.longitude ha = @hour_angle || compute_hour_angle(time: time, longitude: longitude) t0 = @declination.sin * latitude.sin + @declination.cos * latitude.cos * ha.cos altitude = Angle.asin(t0) t1 = @declination.sin - latitude.sin * altitude.sin t2 = t1 / (latitude.cos * altitude.cos) azimuth = Angle.acos(t2) if ha.sin.positive? azimuth = Angle.from_degrees(Constants::DEGREES_PER_CIRCLE - azimuth.degrees) end Horizontal.new( azimuth: azimuth, altitude: altitude, observer: observer ) end |