lunation 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,14 @@ module Lunation
4
4
  class Calculation
5
5
  module MoonPosition
6
6
  # rubocop:disable Layout/LineLength
7
- LONGITUDE_AND_DISTANCE_OF_MOON_PERIODIC_TERMS = YAML.load_file("config/periodic_terms_moon_longitude_distance.yml").freeze
8
- LATITUDE_OF_MOON_PERIODIC_TERMS = YAML.load_file("config/periodic_terms_moon_latitude.yml").freeze
9
- MOON_MEAN_LONGITUDE_CONSTANTS = [218.3164477, 481_267.88123421, -0.0015786, 1 / 538_841.0, -1 / 65_194_000.0].freeze
10
- MOON_MEAN_ELONGATION_CONSTANTS = [297.8501921, 445_267.1114034, -0.0018819, 1 / 545_868.0, -1 / 113_065_000.0].freeze
11
- MOON_MEAN_ANOMALY_CONSTANTS = [134.9633964, 477_198.8675055, 0.0087414, 1 / 69_699.0, -1 / 14_712_000.0].freeze
12
- MOON_ARGUMENT_OF_LATITUDE_CONSTANTS = [93.2720950, 483_202.0175233, -0.0036539, -1 / 3_526_000.0, 1 / 863_310_000.0].freeze
7
+ MOON_LONGITUDE_AND_DISTANCE_PERIOD_TERMS_PATH = File.expand_path("../../../config/periodic_terms_moon_longitude_distance.yml", __dir__).freeze
8
+ MOON_LATITUDE_PERIOD_TERMS_PATH = File.expand_path("../../../config/periodic_terms_moon_latitude.yml", __dir__).freeze
9
+ MOON_LONGITUDE_AND_DISTANCE_PERIOD_TERMS = YAML.load_file(MOON_LONGITUDE_AND_DISTANCE_PERIOD_TERMS_PATH).freeze
10
+ MOON_LATITUDE_PERIOD_TERMS = YAML.load_file(MOON_LATITUDE_PERIOD_TERMS_PATH).freeze
11
+ MOON_MEAN_LONGITUDE_CONSTANTS = [218.3164477, 481_267.88123421, -0.0015786, 1.fdiv(538_841), -1.fdiv(65_194_000)].freeze
12
+ MOON_MEAN_ELONGATION_CONSTANTS = [297.8501921, 445_267.1114034, -0.0018819, 1.fdiv(545_868), -1.fdiv(113_065_000)].freeze
13
+ MOON_MEAN_ANOMALY_CONSTANTS = [134.9633964, 477_198.8675055, 0.0087414, 1.fdiv(69_699), -1.fdiv(14_712_000)].freeze
14
+ MOON_ARGUMENT_OF_LATITUDE_CONSTANTS = [93.2720950, 483_202.0175233, -0.0036539, -1.fdiv(3_526_000), 1.fdiv(863_310_000)].freeze
13
15
  CORRECTION_ECCENTRICITY_OF_EARTH_CONSTANTS = [1, -0.002516, -0.0000074].freeze
14
16
  FIXED_DISTANCE_BETWEEN_EARTH_AND_MOON = 385_000.56
15
17
  RADIUS_OF_EARTH = 6378.14
@@ -75,22 +77,22 @@ module Lunation
75
77
  # UNIT: decimal degrees
76
78
  def moon_heliocentric_longitude
77
79
  @moon_heliocentric_longitude ||= begin
78
- result = LONGITUDE_AND_DISTANCE_OF_MOON_PERIODIC_TERMS.inject(0.0) do |acc, elem|
80
+ result = MOON_LONGITUDE_AND_DISTANCE_PERIOD_TERMS.inject(0.0) do |acc, elem|
79
81
  sine_argument = Angle.from_decimal_degrees(
80
- elem["moon_mean_elongation"] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
81
- elem["sun_mean_anomaly"] * sun_mean_anomaly2.decimal_degrees +
82
- elem["moon_mean_anomaly"] * moon_mean_anomaly_high_precision.decimal_degrees +
83
- elem["moon_argument_of_latitude"] * moon_argument_of_latitude_high_precision.decimal_degrees
82
+ elem[0] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
83
+ elem[1] * sun_mean_anomaly2.decimal_degrees +
84
+ elem[2] * moon_mean_anomaly_high_precision.decimal_degrees +
85
+ elem[3] * moon_argument_of_latitude_high_precision.decimal_degrees
84
86
  )
85
87
 
86
- if elem["sine_coefficient"].nil?
88
+ if elem[4].nil?
87
89
  next acc
88
- elsif [1, -1].include?(elem["sun_mean_anomaly"])
89
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
90
- elsif [-2, 2].include?(elem["sun_mean_anomaly"])
91
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
90
+ elsif [1, -1].include?(elem[1])
91
+ acc + elem[4] * correction_eccentricity_of_earth * sine_argument.sin
92
+ elsif [-2, 2].include?(elem[1])
93
+ acc + elem[4] * correction_eccentricity_of_earth**2 * sine_argument.sin
92
94
  else
93
- acc + elem["sine_coefficient"] * sine_argument.sin
95
+ acc + elem[4] * sine_argument.sin
94
96
  end
95
97
  end + 3958 * correction_venus.sin +
96
98
  1962 * (moon_mean_longitude - moon_argument_of_latitude_high_precision).sin +
@@ -103,22 +105,22 @@ module Lunation
103
105
  # UNIT: decimal degrees
104
106
  def moon_heliocentric_latitude
105
107
  @moon_heliocentric_latitude ||= begin
106
- result = LATITUDE_OF_MOON_PERIODIC_TERMS.inject(0.0) do |acc, elem|
108
+ result = MOON_LATITUDE_PERIOD_TERMS.inject(0.0) do |acc, elem|
107
109
  sine_argument = Angle.from_decimal_degrees(
108
- elem["moon_mean_elongation"] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
109
- elem["sun_mean_anomaly"] * sun_mean_anomaly2.decimal_degrees +
110
- elem["moon_mean_anomaly"] * moon_mean_anomaly_high_precision.decimal_degrees +
111
- elem["moon_argument_of_latitude"] * moon_argument_of_latitude_high_precision.decimal_degrees
110
+ elem[0] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
111
+ elem[1] * sun_mean_anomaly2.decimal_degrees +
112
+ elem[2] * moon_mean_anomaly_high_precision.decimal_degrees +
113
+ elem[3] * moon_argument_of_latitude_high_precision.decimal_degrees
112
114
  )
113
115
 
114
- if elem["sine_coefficient"].nil?
116
+ if elem[4].nil?
115
117
  next acc
116
- elsif [1, -1].include?(elem["sun_mean_anomaly"])
117
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
118
- elsif [-2, 2].include?(elem["sun_mean_anomaly"])
119
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
118
+ elsif [1, -1].include?(elem[1])
119
+ acc + elem[4] * correction_eccentricity_of_earth * sine_argument.sin
120
+ elsif [-2, 2].include?(elem[1])
121
+ acc + elem[4] * correction_eccentricity_of_earth**2 * sine_argument.sin
120
122
  else
121
- acc + elem["sine_coefficient"] * sine_argument.sin
123
+ acc + elem[4] * sine_argument.sin
122
124
  end
123
125
  end - 2235 * moon_mean_longitude.sin +
124
126
  382 * correction_latitude.sin +
@@ -134,22 +136,22 @@ module Lunation
134
136
  # UNIT: 1000 km
135
137
  def moon_heliocentric_distance
136
138
  @moon_heliocentric_distance ||= begin
137
- result = LONGITUDE_AND_DISTANCE_OF_MOON_PERIODIC_TERMS.inject(0.0) do |acc, elem|
139
+ result = MOON_LONGITUDE_AND_DISTANCE_PERIOD_TERMS.inject(0.0) do |acc, elem|
138
140
  cosine_argument = Angle.from_decimal_degrees(
139
- elem["moon_mean_elongation"] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
140
- elem["sun_mean_anomaly"] * sun_mean_anomaly2.decimal_degrees +
141
- elem["moon_mean_anomaly"] * moon_mean_anomaly_high_precision.decimal_degrees +
142
- elem["moon_argument_of_latitude"] * moon_argument_of_latitude_high_precision.decimal_degrees
141
+ elem[0] * moon_mean_elongation_from_sun_high_precision.decimal_degrees +
142
+ elem[1] * sun_mean_anomaly2.decimal_degrees +
143
+ elem[2] * moon_mean_anomaly_high_precision.decimal_degrees +
144
+ elem[3] * moon_argument_of_latitude_high_precision.decimal_degrees
143
145
  )
144
146
 
145
- if elem["cosine_coefficient"].nil?
147
+ if elem[5].nil?
146
148
  next acc
147
- elsif [1, -1].include?(elem["sun_mean_anomaly"])
148
- acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth * cosine_argument.cos
149
- elsif [-2, 2].include?(elem["sun_mean_anomaly"])
150
- acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth**2 * cosine_argument.cos
149
+ elsif [1, -1].include?(elem[1])
150
+ acc + elem[5] * correction_eccentricity_of_earth * cosine_argument.cos
151
+ elsif [-2, 2].include?(elem[1])
152
+ acc + elem[5] * correction_eccentricity_of_earth**2 * cosine_argument.cos
151
153
  else
152
- acc + elem["cosine_coefficient"] * cosine_argument.cos
154
+ acc + elem[5] * cosine_argument.cos
153
155
  end
154
156
  end
155
157
  result.round
@@ -160,7 +162,8 @@ module Lunation
160
162
  # UNIT: Angle
161
163
  def moon_ecliptic_longitude
162
164
  @moon_ecliptic_longitude ||= Angle.from_decimal_degrees(
163
- moon_mean_longitude.decimal_degrees + moon_heliocentric_longitude / 1_000_000.0
165
+ moon_mean_longitude.decimal_degrees +
166
+ moon_heliocentric_longitude.fdiv(1_000_000)
164
167
  )
165
168
  end
166
169
 
@@ -168,7 +171,7 @@ module Lunation
168
171
  # UNIT: Angle
169
172
  def moon_ecliptic_latitude
170
173
  @moon_ecliptic_latitude ||= Angle.from_decimal_degrees(
171
- moon_heliocentric_latitude / 1_000_000.0,
174
+ moon_heliocentric_latitude.fdiv(1_000_000),
172
175
  normalize: false
173
176
  )
174
177
  end
@@ -178,7 +181,7 @@ module Lunation
178
181
  def distance_between_earth_and_moon
179
182
  @distance_between_earth_and_moon ||= begin
180
183
  result = FIXED_DISTANCE_BETWEEN_EARTH_AND_MOON +
181
- (moon_heliocentric_distance / 1_000.0)
184
+ moon_heliocentric_distance.fdiv(1_000)
182
185
  result.round(1)
183
186
  end
184
187
  end
@@ -194,7 +197,8 @@ module Lunation
194
197
  # (apparent λ) Moon apparent longitude (A.A. p. 343)
195
198
  # UNIT: Angle
196
199
  def moon_apparent_ecliptic_longitude
197
- @moon_apparent_ecliptic_longitude ||= moon_ecliptic_longitude + nutation_in_longitude
200
+ @moon_apparent_ecliptic_longitude ||=
201
+ moon_ecliptic_longitude + nutation_in_longitude
198
202
  end
199
203
 
200
204
  # (α) geocentric (apparent) right ascension of the moon (13.3 A.A. p. 93)
@@ -2,13 +2,14 @@ module Lunation
2
2
  class Calculation
3
3
  module NutationAndObliquity
4
4
  # rubocop:disable Layout/LineLength
5
- NUTATION_IN_OBLIQUITY_PERIODIC_TERMS = YAML.load_file("config/periodic_terms_earth_nutation.yml").freeze
5
+ NUTATION_IN_OBLIQUITY_PERIODIC_TERMS_PATH = File.expand_path("../../../config/periodic_terms_earth_nutation.yml", __dir__)
6
+ NUTATION_IN_OBLIQUITY_PERIODIC_TERMS = YAML.load_file(NUTATION_IN_OBLIQUITY_PERIODIC_TERMS_PATH).freeze
6
7
  ECLIPTIC_MEAN_OBLIQUITY_CONSTANTS = [21.448, -4680.93, -1.55, 1_999.25, -51.38, -249.67, -39.05, 7.12, 27.87, 5.79, 2.45].freeze
7
- MOON_MEAN_ELONGATION_FROM_SUN_CONSTANTS = [297.85036, 445_267.111480, -0.0019142, 1 / 189_474.0].freeze
8
- SUN_MEAN_ANOMALY_CONSTANTS = [357.52772, 35_999.050340, -0.0001603, -1 / 300_000.0].freeze
9
- MOON_MEAN_ANOMALY_CONSTANTS = [134.96298, 477_198.867398, 0.0086972, 1 / 56_250.0].freeze
10
- MOON_ARGUMENT_OF_LATITUDE_CONSTANTS = [93.27191, 483_202.017538, -0.0036825, 1 / 327_270.0].freeze
11
- LONGITUDE_OF_THE_ASCENDING_NODE_CONSTANTS = [125.04452, -1934.136261, 0.0020708, 1 / 450_000.0].freeze
8
+ MOON_MEAN_ELONGATION_FROM_SUN_CONSTANTS = [297.85036, 445_267.111480, -0.0019142, 1.fdiv(189_474)].freeze
9
+ SUN_MEAN_ANOMALY_CONSTANTS = [357.52772, 35_999.050340, -0.0001603, -1.fdiv(300_000)].freeze
10
+ MOON_MEAN_ANOMALY_CONSTANTS = [134.96298, 477_198.867398, 0.0086972, 1.fdiv(56_250)].freeze
11
+ MOON_ARGUMENT_OF_LATITUDE_CONSTANTS = [93.27191, 483_202.017538, -0.0036825, 1.fdiv(327_270)].freeze
12
+ LONGITUDE_OF_THE_ASCENDING_NODE_CONSTANTS = [125.04452, -1934.136261, 0.0020708, 1.fdiv(450_000)].freeze
12
13
  # rubocop:enable Layout/LineLength
13
14
 
14
15
  # (D) Mean elongation of the moon from the sun (A.A. p. 144)
@@ -63,13 +64,13 @@ module Lunation
63
64
  @nutation_in_longitude ||= begin
64
65
  result = NUTATION_IN_OBLIQUITY_PERIODIC_TERMS.inject(0.0) do |acc, elem|
65
66
  argument = Angle.from_decimal_degrees(
66
- elem["moon_mean_elongation"] * moon_mean_elongation_from_sun.decimal_degrees +
67
- elem["sun_mean_anomaly"] * sun_mean_anomaly.decimal_degrees +
68
- elem["moon_mean_anomaly"] * moon_mean_anomaly.decimal_degrees +
69
- elem["moon_argument_of_latitude"] * moon_argument_of_latitude.decimal_degrees +
70
- elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
67
+ elem[0] * moon_mean_elongation_from_sun.decimal_degrees +
68
+ elem[1] * sun_mean_anomaly.decimal_degrees +
69
+ elem[2] * moon_mean_anomaly.decimal_degrees +
70
+ elem[3] * moon_argument_of_latitude.decimal_degrees +
71
+ elem[4] * longitude_of_ascending_node.decimal_degrees
71
72
  )
72
- coefficient = elem["sine_coefficient_first_term"] + elem["sine_coefficient_second_term"] * time
73
+ coefficient = elem[5] + elem[6] * time
73
74
  acc + coefficient * argument.sin
74
75
  end / 10_000.0
75
76
  Angle.from_decimal_arcseconds(result)
@@ -82,13 +83,13 @@ module Lunation
82
83
  @nutation_in_obliquity ||= begin
83
84
  result = NUTATION_IN_OBLIQUITY_PERIODIC_TERMS.inject(0.0) do |acc, elem|
84
85
  argument = Angle.from_decimal_degrees(
85
- elem["moon_mean_elongation"] * moon_mean_elongation_from_sun.decimal_degrees +
86
- elem["sun_mean_anomaly"] * sun_mean_anomaly.decimal_degrees +
87
- elem["moon_mean_anomaly"] * moon_mean_anomaly.decimal_degrees +
88
- elem["moon_argument_of_latitude"] * moon_argument_of_latitude.decimal_degrees +
89
- elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
86
+ elem[0] * moon_mean_elongation_from_sun.decimal_degrees +
87
+ elem[1] * sun_mean_anomaly.decimal_degrees +
88
+ elem[2] * moon_mean_anomaly.decimal_degrees +
89
+ elem[3] * moon_argument_of_latitude.decimal_degrees +
90
+ elem[4] * longitude_of_ascending_node.decimal_degrees
90
91
  )
91
- coefficient = elem["cosine_coefficient_first_term"] + elem["cosine_coefficient_second_term"] * time
92
+ coefficient = elem[7] + elem[8] * time
92
93
  acc + coefficient * argument.cos
93
94
  end / 10_000.0
94
95
  Angle.from_decimal_arcseconds(result)
@@ -58,7 +58,10 @@ module Lunation
58
58
  # UNIT: Astronomical Units (AU)
59
59
  def distance_between_earth_and_sun_in_astronomical_units
60
60
  @distance_between_earth_and_sun_in_astronomical_units ||= begin
61
- result = 1.000001018 * (1 - earth_orbit_eccentricity**2) / (1 + earth_orbit_eccentricity * sun_anomaly.cos)
61
+ result = 1.000001018 *
62
+ (1 - earth_orbit_eccentricity**2) / (
63
+ (1 + earth_orbit_eccentricity * sun_anomaly.cos)
64
+ )
62
65
  result.round(7)
63
66
  end
64
67
  end
@@ -70,8 +73,8 @@ module Lunation
70
73
  (distance_between_earth_and_sun_in_astronomical_units * 149_597_870).floor
71
74
  end
72
75
 
73
- # (Ω) Longitude of the ascending node of the Moon's mean orbit on the ecliptic (low precision)
74
- # A.A. p. 164
76
+ # (Ω) Longitude of the ascending node of the Moon's mean orbit on the ecliptic
77
+ # (low precision) A.A. p. 164
75
78
  # UNIT: Angle
76
79
  def longitude_of_ascending_node_low_precision
77
80
  @longitude_of_ascending_node_low_precision ||=
@@ -7,14 +7,14 @@ module Lunation
7
7
  # rubocop:disable Layout/LineLength
8
8
  DELTA_T_500BC_500AD = [10_583.6, -1_014.41, 33.78311, -5.952053, -0.1798452, 0.022174192, 0.0090316521].freeze
9
9
  DELTA_T_500AD_1600AD = [1_574.2, -556.01, 71.23472, 0.319781, -0.8503463, -0.005050998, 0.0083572073].freeze
10
- DELTA_T_1600AD_1700AD = [120, -0.9808, -0.01532, 1 / 7_129.0].freeze
11
- DELTA_T_1700AD_1800AD = [8.83, 0.1603, -0.0059285, 0.00013336, -1 / 1_174_000.0].freeze
10
+ DELTA_T_1600AD_1700AD = [120, -0.9808, -0.01532, 1.fdiv(7_129)].freeze
11
+ DELTA_T_1700AD_1800AD = [8.83, 0.1603, -0.0059285, 0.00013336, -1.fdiv(1_174_000)].freeze
12
12
  DELTA_T_1800AD_1860AD = [13.72, -0.332447, 0.0068612, 0.0041116, -0.00037436, 0.0000121272, -0.0000001699, 0.000000000875].freeze
13
- DELTA_T_1860AD_1900AD = [7.62, 0.5737, -0.251754, 0.01680668, -0.0004473624, 1 / 233_174.0].freeze
13
+ DELTA_T_1860AD_1900AD = [7.62, 0.5737, -0.251754, 0.01680668, -0.0004473624, 1.fdiv(233_174)].freeze
14
14
  DELTA_T_1900AD_1920AD = [-2.79, 1.494119, -0.0598939, 0.0061966, -0.000197].freeze
15
15
  DELTA_T_1920AD_1941AD = [21.20, 0.84493, -0.076100, 0.0020936].freeze
16
- DELTA_T_1941AD_1961AD = [29.07, 0.407, -1 / 233.0, 1 / 2_547.0].freeze
17
- DELTA_T_1961AD_1986AD = [45.45, 1.067, -1 / 260.0, -1 / 718.0].freeze
16
+ DELTA_T_1941AD_1961AD = [29.07, 0.407, -1.fdiv(233), 1.fdiv(2_547)].freeze
17
+ DELTA_T_1961AD_1986AD = [45.45, 1.067, -1.fdiv(260), -1.fdiv(718)].freeze
18
18
  DELTA_T_1986AD_2005AD = [63.86, 0.3345, -0.060374, 0.0017275, 0.000651814, 0.00002373599].freeze
19
19
  DELTA_T_2005AD_2050AD = [62.92, 0.32217, 0.005589].freeze
20
20
  # rubocop:enable Layout/LineLength
@@ -23,7 +23,7 @@ module Lunation
23
23
  # UNIT: centuries from the Epoch J2000.0
24
24
  def time
25
25
  @time ||=
26
- ((julian_ephemeris_day - EPOCH_J2000_JDE) / JULIAN_CENTURY_IN_DAYS).round(12)
26
+ (julian_ephemeris_day - EPOCH_J2000_JDE).fdiv(JULIAN_CENTURY_IN_DAYS).round(12)
27
27
  end
28
28
 
29
29
  # ΔT Difference between Dynamical Time (TD) and Universal Time (UT, more commonly
@@ -36,12 +36,12 @@ module Lunation
36
36
  @delta_t ||= begin
37
37
  result = case datetime.year
38
38
  when -1_999...-500
39
- elapsed_years = (@decimal_year - 1_820) / 100
39
+ elapsed_years = (@decimal_year - 1_820).fdiv(100)
40
40
  -20 + 32 * elapsed_years**2
41
41
  when -500...500
42
- Horner.compute(@decimal_year / 100.0, DELTA_T_500BC_500AD)
42
+ Horner.compute(@decimal_year.fdiv(100), DELTA_T_500BC_500AD)
43
43
  when 500...1_600
44
- Horner.compute((@decimal_year - 1_000.0) / 100.0, DELTA_T_500AD_1600AD)
44
+ Horner.compute((@decimal_year - 1_000.0).fdiv(100), DELTA_T_500AD_1600AD)
45
45
  when 1_600...1_700
46
46
  Horner.compute(@decimal_year - 1_600.0, DELTA_T_1600AD_1700AD)
47
47
  when 1_700...1_800
@@ -63,7 +63,8 @@ module Lunation
63
63
  when 2_005...2_050
64
64
  Horner.compute(@decimal_year - 2_000, DELTA_T_2005AD_2050AD)
65
65
  when 2_050...2_150
66
- -20 + 32 * ((@decimal_year - 1_820) / 100)**2 - 0.5628 * (2_150 - @decimal_year)
66
+ -20 + 32 * ((@decimal_year - 1_820) / 100)**2 - 0.5628 *
67
+ (2_150 - @decimal_year)
67
68
  when 2_150..3_000
68
69
  -20 + 32 * @decimal_year**2
69
70
  end
@@ -74,7 +75,7 @@ module Lunation
74
75
  # (TD) Dynamical time (A.A. p. 77)
75
76
  # UNIT: ISO 8601 Date and time with offset
76
77
  def dynamical_time
77
- @dynamical_time ||= datetime + delta_t.round.to_f / SECONDS_PER_DAY
78
+ @dynamical_time ||= datetime + delta_t.round.fdiv(SECONDS_PER_DAY)
78
79
  end
79
80
 
80
81
  # (JDE) Julian ephemeris day (A.A. p. 59)
@@ -86,13 +87,13 @@ module Lunation
86
87
  # (t) time, measured in Julian millennia from the epoch J2000.0 (32.1, A.A. p. 218)
87
88
  # UNIT: millennia from the Epoch J2000.0
88
89
  def time_millennia
89
- @time_millennia ||= (time / 10.0).round(12)
90
+ @time_millennia ||= time.fdiv(10).round(12)
90
91
  end
91
92
 
92
93
  # (U) Time measured in units of 10_000 Julian years from J2000.0 (A.A. p. 147)
93
94
  # UNIT: 10_000 years (myriads) from the Epoch J2000.0
94
95
  def time_myriads
95
- @time_myriads ||= time / 100.0
96
+ @time_myriads ||= time.fdiv(100)
96
97
  end
97
98
  end
98
99
  end
@@ -25,11 +25,14 @@ module Lunation
25
25
 
26
26
  def to_h
27
27
  {
28
+ # rubocop:disable Layout/LineLength
28
29
  corrected_obliquity_of_ecliptic: corrected_obliquity_of_ecliptic,
29
30
  correction_eccentricity_of_earth: correction_eccentricity_of_earth,
30
31
  correction_jupiter: correction_jupiter,
31
32
  correction_latitude: correction_latitude,
32
33
  correction_venus: correction_venus,
34
+ datetime: datetime,
35
+ decimal_year: decimal_year,
33
36
  delta_t: delta_t,
34
37
  distance_between_earth_and_moon: distance_between_earth_and_moon,
35
38
  distance_between_earth_and_sun_in_astronomical_units: distance_between_earth_and_sun_in_astronomical_units,
@@ -78,11 +81,12 @@ module Lunation
78
81
  time_millennia: time_millennia,
79
82
  time_myriads: time_myriads,
80
83
  time: time,
84
+ # rubocop:enable Layout/LineLength
81
85
  }
82
86
  end
83
87
 
84
88
  def to_s
85
- <<-HEREDOC
89
+ <<~HEREDOC
86
90
  DATE AND TIME (UT): #{datetime}
87
91
  ----------------------------------------------------------------------------------
88
92
  DECIMAL YEAR: #{decimal_year}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lunation
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lunation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivo Kalverboer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-30 00:00:00.000000000 Z
11
+ date: 2024-12-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Lunation offers a Ruby implementation of Meeus's Astronomical Algorithms.
14
14
  email:
@@ -59,7 +59,7 @@ licenses:
59
59
  metadata:
60
60
  homepage_uri: https://www.github.com/valerius/lunation
61
61
  source_code_uri: https://www.github.com/valerius/lunation
62
- changelog_uri: https://www.github.com/valerius/lunation/CHANGELOG.md
62
+ changelog_uri: https://github.com/valerius/lunation/blob/main/CHANGELOG.md
63
63
  post_install_message:
64
64
  rdoc_options: []
65
65
  require_paths: