Class: Astronoby::GeocentricParallax

Inherits:
Object
  • Object
show all
Defined in:
lib/astronoby/geocentric_parallax.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(observer, time, coordinates, distance) ⇒ GeocentricParallax

Returns a new instance of GeocentricParallax.

Parameters:



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/astronoby/geocentric_parallax.rb', line 48

def initialize(
  observer,
  time,
  coordinates,
  distance
)
  @observer = observer
  @time = time
  @coordinates = coordinates
  @distance = distance
end

Class Method Details

.angle(distance:) ⇒ Astronoby::Angle

Equatorial horizontal parallax

Parameters:

Returns:



15
16
17
# File 'lib/astronoby/geocentric_parallax.rb', line 15

def self.angle(distance:)
  Angle.from_radians(Angle.from_dms(0, 0, 8.794).sin / distance.au)
end

.for_equatorial_coordinates(observer:, time:, coordinates:, distance:) ⇒ Astronoby::Coordinates::Equatorial

Correct equatorial coordinates with the equatorial horizontal parallax

Parameters:

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/astronoby/geocentric_parallax.rb', line 28

def self.for_equatorial_coordinates(
  observer:,
  time:,
  coordinates:,
  distance:
)
  new(
    observer,
    time,
    coordinates,
    distance
  ).apply
end

Instance Method Details

#applyObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/astronoby/geocentric_parallax.rb', line 60

def apply
  term1 = Angle.atan(Constants::EARTH_FLATTENING_CORRECTION * latitude.tan)
  quantity1 = term1.cos + elevation_ratio * latitude.cos
  quantity2 = Constants::EARTH_FLATTENING_CORRECTION * term1.sin +
    elevation_ratio * latitude.sin

  term1 = -quantity1 * equatorial_horizontal_parallax.sin * hour_angle.sin
  term2 = declination.cos - quantity1 * equatorial_horizontal_parallax.sin * hour_angle.cos
  delta_right_ascension = Angle.atan(term1 / term2)

  term1 = (declination.sin - quantity2 * equatorial_horizontal_parallax.sin) * delta_right_ascension.cos
  term2 = declination.cos - quantity1 * equatorial_horizontal_parallax.sin * hour_angle.cos
  new_declination = Angle.atan(term1 / term2)

  Coordinates::Equatorial.new(
    right_ascension: delta_right_ascension + right_ascension,
    declination: new_declination,
    epoch: @coordinates.epoch
  )
end