Class: Astronoby::Refraction

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

Constant Summary collapse

LOW_ALTITUDE_BODY_ANGLE =
Angle.from_degrees(15)
ZENITH =
Angle.from_degrees(90)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coordinates) ⇒ Refraction

Returns a new instance of Refraction.



16
17
18
# File 'lib/astronoby/refraction.rb', line 16

def initialize(coordinates)
  @coordinates = coordinates
end

Class Method Details

.angle(coordinates:) ⇒ Object



8
9
10
# File 'lib/astronoby/refraction.rb', line 8

def self.angle(coordinates:)
  new(coordinates).refraction_angle
end

.correct_horizontal_coordinates(coordinates:) ⇒ Object



12
13
14
# File 'lib/astronoby/refraction.rb', line 12

def self.correct_horizontal_coordinates(coordinates:)
  new(coordinates).refract
end

Instance Method Details

#refractObject

Source:

Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 37 - Refraction


25
26
27
28
29
30
31
# File 'lib/astronoby/refraction.rb', line 25

def refract
  Coordinates::Horizontal.new(
    azimuth: @coordinates.azimuth,
    altitude: @coordinates.altitude + refraction_angle,
    observer: @coordinates.observer
  )
end

#refraction_angleObject



33
34
35
36
37
38
39
# File 'lib/astronoby/refraction.rb', line 33

def refraction_angle
  if @coordinates.altitude > LOW_ALTITUDE_BODY_ANGLE
    high_altitude_angle
  else
    low_altitude_angle
  end
end