Class: Daylight::EquationOfCenterForEarth

Inherits:
Object
  • Object
show all
Defined in:
lib/trigger_switch_d/daylight.rb

Overview

Equation of Center for Earth

Constant Summary collapse

COEFFICIENTS =

:nodoc:all

[1.9148, 0.0200, 0.0003]

Instance Method Summary collapse

Constructor Details

#initialize(mean_anomaly_as_rad) ⇒ EquationOfCenterForEarth

Returns a new instance of EquationOfCenterForEarth.



72
73
74
75
76
77
78
# File 'lib/trigger_switch_d/daylight.rb', line 72

def initialize(mean_anomaly_as_rad)
  sum = 0
  COEFFICIENTS.each_with_index do |coefficient, multiplier|
    sum += coefficient * Math.sin((multiplier + 1) * mean_anomaly_as_rad)
  end
  @center = sum
end

Instance Method Details

#to_fObject



79
80
81
# File 'lib/trigger_switch_d/daylight.rb', line 79

def to_f
  @center
end