Class: Astronoby::Precession

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coordinates, epoch) ⇒ Precession

Returns a new instance of Precession.



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

def initialize(coordinates, epoch)
  @coordinates = coordinates
  @epoch = epoch
end

Class Method Details

.for_equatorial_coordinates(coordinates:, epoch:) ⇒ Object



7
8
9
# File 'lib/astronoby/precession.rb', line 7

def self.for_equatorial_coordinates(coordinates:, epoch:)
  new(coordinates, epoch).precess
end

Instance Method Details

#precessObject

Source:

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


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/astronoby/precession.rb', line 21

def precess
  matrix_a = matrix_for_epoch(@coordinates.epoch)
  matrix_b = matrix_for_epoch(@epoch).transpose

  vector = Vector[
    @coordinates.right_ascension.cos * @coordinates.declination.cos,
    @coordinates.right_ascension.sin * @coordinates.declination.cos,
    @coordinates.declination.sin
  ]

  s = matrix_a * vector
  w = matrix_b * s

  Coordinates::Equatorial.new(
    right_ascension: Util::Trigonometry.adjustement_for_arctangent(
      Angle.from_radians(w[1]),
      Angle.from_radians(w[0]),
      Angle.atan(w[1] / w[0])
    ),
    declination: Angle.asin(w[2]),
    epoch: @epoch
  )
end