lunation 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fa0dd7f583acc8637dc405d5eaecc21479a93fa2ef414d2e2c3b641c29f0cc9
4
- data.tar.gz: 1d1bbbc4059997c19aa41a08eba39aada7d9adcd4f0ca20d72426ae1c56fe3ac
3
+ metadata.gz: 7456b667a5f453f75f3651057cec0f580b23272d991c34f604bbeb1feee23674
4
+ data.tar.gz: b5f66e7c32897e674af455196081d53270a76250f69787f360739cb8fd655bf2
5
5
  SHA512:
6
- metadata.gz: c74f7ebc1c6a57649f5bcfca2f4829471973445106552731ffb48b0422e33a36ebec2019b2b0d8bf65c007373e507a4454271d579eb69059241a134bcab48f53
7
- data.tar.gz: d5bf58d80ebb4f4621495244d36cb57f495cf2f1d1af294dcb2bb78206d5463feafbaed3859ef0e1326677e3a82ca50ba34fb7602002c663b1e84e65886d701b
6
+ metadata.gz: 1c308d38a6a871d33c87e153df11ac409afda0f4f2ddb26a294b5771d86f300491fe9da1881d38277c4ae889da541d79dc383b5e046f49fd9923eb38d7978b4b
7
+ data.tar.gz: 7c4b9014eef9efa616a045a97bf285b93bca7d5fdb23feaa230bc841dfced221dd6b92209fc26187b18336d49c7a3625f7659d57cd9d040c52a838d9279cc811
data/CHANGELOG.md CHANGED
@@ -1,12 +1,12 @@
1
- # [0.1.2] - 2024-12-28
1
+ ## [0.1.2] - 2024-12-28
2
2
 
3
3
  - Update README;
4
4
  - Bundle update.
5
5
 
6
- # [0.1.1] - 2024-12-28
6
+ ## [0.1.1] - 2024-12-28
7
7
 
8
8
  - Update readme
9
9
 
10
- # [0.1.0] - 2024-12-28
10
+ ## [0.1.0] - 2024-12-28
11
11
 
12
12
  - Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lunation
2
2
 
3
- This library provides a library of algorithms for computing positions and ephemeris of
3
+ Lunation provides a library of algorithms for computing positions and ephemeris of
4
4
  celestial objects using Jean Meeus's astronomical algorithms.
5
5
 
6
6
  ## Installation
@@ -73,6 +73,18 @@ module Lunation
73
73
  )
74
74
  end
75
75
 
76
+ def cos
77
+ Math.cos(radians)
78
+ end
79
+
80
+ def sin
81
+ Math.sin(radians)
82
+ end
83
+
84
+ def tan
85
+ Math.tan(radians)
86
+ end
87
+
76
88
  class << self
77
89
  def from_radians(radians, normalize: true)
78
90
  new(
@@ -5,16 +5,16 @@ module Lunation
5
5
  # UNIT: fraction (decimal)
6
6
  def moon_illuminated_fraction
7
7
  @moon_illuminated_fraction ||=
8
- ((1 + Math.cos(moon_phase_angle.radians)) / 2.0).round(4)
8
+ ((1 + moon_phase_angle.cos) / 2.0).round(4)
9
9
  end
10
10
 
11
11
  # (i) phase angle of the moon (48.3, A.A. p. 346)
12
12
  # UNIT: Angle
13
13
  def moon_phase_angle
14
14
  @moon_phase_angle ||= begin
15
- numerator = distance_between_earth_and_sun_in_kilometers * Math.sin(moon_elongation_from_sun.radians)
15
+ numerator = distance_between_earth_and_sun_in_kilometers * moon_elongation_from_sun.sin
16
16
  denominator = distance_between_earth_and_moon -
17
- distance_between_earth_and_sun_in_kilometers * Math.cos(moon_elongation_from_sun.radians)
17
+ distance_between_earth_and_sun_in_kilometers * moon_elongation_from_sun.cos
18
18
  Angle.from_radians(Math.atan2(numerator, denominator))
19
19
  end
20
20
  end
@@ -23,11 +23,11 @@ module Lunation
23
23
  # UNIT: Angle
24
24
  def moon_elongation_from_sun
25
25
  @moon_elongation_from_sun ||= begin
26
- result = Math.sin(sun_declination.radians) *
27
- Math.sin(moon_declination.radians) +
28
- Math.cos(sun_declination.radians) *
29
- Math.cos(moon_declination.radians) *
30
- Math.cos((sun_right_ascension - moon_right_ascension).radians)
26
+ result = sun_declination.sin *
27
+ moon_declination.sin +
28
+ sun_declination.cos *
29
+ moon_declination.cos *
30
+ (sun_right_ascension - moon_right_ascension).cos
31
31
  Angle.from_radians(Math.acos(result))
32
32
  end
33
33
  end
@@ -36,13 +36,13 @@ module Lunation
36
36
  # UNIT: Angle
37
37
  def moon_position_angle_of_bright_limb
38
38
  @moon_position_angle_of_bright_limb ||= begin
39
- numerator = Math.cos(sun_declination.radians) *
40
- Math.sin((sun_right_ascension - moon_right_ascension).radians)
41
- denominator = Math.sin(sun_declination.radians) *
42
- Math.cos(moon_declination.radians) -
43
- Math.cos(sun_declination.radians) *
44
- Math.sin(moon_declination.radians) *
45
- Math.cos((sun_right_ascension - moon_right_ascension).radians)
39
+ numerator = sun_declination.cos *
40
+ (sun_right_ascension - moon_right_ascension).sin
41
+ denominator = sun_declination.sin *
42
+ moon_declination.cos -
43
+ sun_declination.cos *
44
+ moon_declination.sin *
45
+ (sun_right_ascension - moon_right_ascension).cos
46
46
  Angle.from_radians(Math.atan2(numerator, denominator))
47
47
  end
48
48
  end
@@ -86,15 +86,15 @@ module Lunation
86
86
  if elem["sine_coefficient"].nil?
87
87
  next acc
88
88
  elsif [1, -1].include?(elem["sun_mean_anomaly"])
89
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * Math.sin(sine_argument.radians)
89
+ acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
90
90
  elsif [-2, 2].include?(elem["sun_mean_anomaly"])
91
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * Math.sin(sine_argument.radians)
91
+ acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
92
92
  else
93
- acc + elem["sine_coefficient"] * Math.sin(sine_argument.radians)
93
+ acc + elem["sine_coefficient"] * sine_argument.sin
94
94
  end
95
- end + 3958 * Math.sin(correction_venus.radians) +
96
- 1962 * Math.sin((moon_mean_longitude - moon_argument_of_latitude_high_precision).radians) +
97
- 318 * Math.sin(correction_jupiter.radians)
95
+ end + 3958 * correction_venus.sin +
96
+ 1962 * (moon_mean_longitude - moon_argument_of_latitude_high_precision).sin +
97
+ 318 * correction_jupiter.sin
98
98
  result.round
99
99
  end
100
100
  end
@@ -114,18 +114,18 @@ module Lunation
114
114
  if elem["sine_coefficient"].nil?
115
115
  next acc
116
116
  elsif [1, -1].include?(elem["sun_mean_anomaly"])
117
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * Math.sin(sine_argument.radians)
117
+ acc + elem["sine_coefficient"] * correction_eccentricity_of_earth * sine_argument.sin
118
118
  elsif [-2, 2].include?(elem["sun_mean_anomaly"])
119
- acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * Math.sin(sine_argument.radians)
119
+ acc + elem["sine_coefficient"] * correction_eccentricity_of_earth**2 * sine_argument.sin
120
120
  else
121
- acc + elem["sine_coefficient"] * Math.sin(sine_argument.radians)
121
+ acc + elem["sine_coefficient"] * sine_argument.sin
122
122
  end
123
- end - 2235 * Math.sin(moon_mean_longitude.radians) +
124
- 382 * Math.sin(correction_latitude.radians) +
125
- 175 * Math.sin((correction_venus - moon_argument_of_latitude_high_precision).radians) +
126
- 175 * Math.sin((correction_venus + moon_argument_of_latitude_high_precision).radians) +
127
- 127 * Math.sin((moon_mean_longitude - moon_mean_anomaly_high_precision).radians) +
128
- -115 * Math.sin((moon_mean_longitude + moon_mean_anomaly_high_precision).radians)
123
+ end - 2235 * moon_mean_longitude.sin +
124
+ 382 * correction_latitude.sin +
125
+ 175 * (correction_venus - moon_argument_of_latitude_high_precision).sin +
126
+ 175 * (correction_venus + moon_argument_of_latitude_high_precision).sin +
127
+ 127 * (moon_mean_longitude - moon_mean_anomaly_high_precision).sin +
128
+ -115 * (moon_mean_longitude + moon_mean_anomaly_high_precision).sin
129
129
  result.round
130
130
  end
131
131
  end
@@ -145,11 +145,11 @@ module Lunation
145
145
  if elem["cosine_coefficient"].nil?
146
146
  next acc
147
147
  elsif [1, -1].include?(elem["sun_mean_anomaly"])
148
- acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth * Math.cos(cosine_argument.radians)
148
+ acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth * cosine_argument.cos
149
149
  elsif [-2, 2].include?(elem["sun_mean_anomaly"])
150
- acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth**2 * Math.cos(cosine_argument.radians)
150
+ acc + elem["cosine_coefficient"] * correction_eccentricity_of_earth**2 * cosine_argument.cos
151
151
  else
152
- acc + elem["cosine_coefficient"] * Math.cos(cosine_argument.radians)
152
+ acc + elem["cosine_coefficient"] * cosine_argument.cos
153
153
  end
154
154
  end
155
155
  result.round
@@ -201,11 +201,11 @@ module Lunation
201
201
  # UNIT: Angle
202
202
  def moon_right_ascension
203
203
  @moon_right_ascension ||= begin
204
- numerator = Math.sin(moon_apparent_ecliptic_longitude.radians) *
205
- Math.cos(obliquity_of_ecliptic.radians) -
206
- Math.tan(moon_ecliptic_latitude.radians) *
207
- Math.sin(obliquity_of_ecliptic.radians)
208
- denominator = Math.cos(moon_apparent_ecliptic_longitude.radians)
204
+ numerator = moon_apparent_ecliptic_longitude.sin *
205
+ obliquity_of_ecliptic.cos -
206
+ moon_ecliptic_latitude.tan *
207
+ obliquity_of_ecliptic.sin
208
+ denominator = moon_apparent_ecliptic_longitude.cos
209
209
  Angle.from_radians(Math.atan2(numerator, denominator))
210
210
  end
211
211
  end
@@ -214,11 +214,11 @@ module Lunation
214
214
  # UNIT: Angle
215
215
  def moon_declination
216
216
  @moon_declination ||= begin
217
- result = Math.sin(moon_ecliptic_latitude.radians) *
218
- Math.cos(obliquity_of_ecliptic.radians) +
219
- Math.cos(moon_ecliptic_latitude.radians) *
220
- Math.sin(obliquity_of_ecliptic.radians) *
221
- Math.sin(moon_apparent_ecliptic_longitude.radians)
217
+ result = moon_ecliptic_latitude.sin *
218
+ obliquity_of_ecliptic.cos +
219
+ moon_ecliptic_latitude.cos *
220
+ obliquity_of_ecliptic.sin *
221
+ moon_apparent_ecliptic_longitude.sin
222
222
  Angle.from_radians(Math.asin(result))
223
223
  end
224
224
  end
@@ -70,7 +70,7 @@ module Lunation
70
70
  elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
71
71
  )
72
72
  coefficient = elem["sine_coefficient_first_term"] + elem["sine_coefficient_second_term"] * time
73
- acc + coefficient * Math.sin(argument.radians)
73
+ acc + coefficient * argument.sin
74
74
  end / 10_000.0
75
75
  Angle.from_decimal_arcseconds(result)
76
76
  end
@@ -89,7 +89,7 @@ module Lunation
89
89
  elem["longitude_of_ascending_node"] * longitude_of_ascending_node.decimal_degrees
90
90
  )
91
91
  coefficient = elem["cosine_coefficient_first_term"] + elem["cosine_coefficient_second_term"] * time
92
- acc + coefficient * Math.cos(argument.radians)
92
+ acc + coefficient * argument.cos
93
93
  end / 10_000.0
94
94
  Angle.from_decimal_arcseconds(result)
95
95
  end
@@ -35,7 +35,7 @@ module Lunation
35
35
  def sun_equation_of_center
36
36
  @sun_equation_of_center ||= begin
37
37
  result = Horner.compute(time, [1.914602, -0.004817, -0.000014]) *
38
- Math.sin(sun_mean_anomaly2.radians) +
38
+ sun_mean_anomaly2.sin +
39
39
  (0.019993 - 0.000101 * time) * Math.sin(2 * sun_mean_anomaly2.radians) +
40
40
  0.000289 * Math.sin(3 * sun_mean_anomaly2.radians)
41
41
  Angle.from_decimal_degrees(result, normalize: false)
@@ -58,7 +58,7 @@ 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 * Math.cos(sun_anomaly.radians))
61
+ result = 1.000001018 * (1 - earth_orbit_eccentricity**2) / (1 + earth_orbit_eccentricity * sun_anomaly.cos)
62
62
  result.round(7)
63
63
  end
64
64
  end
@@ -84,7 +84,7 @@ module Lunation
84
84
  @sun_ecliptic_longitude ||= begin
85
85
  result = sun_true_longitude.decimal_degrees +
86
86
  - 0.00569 +
87
- - 0.00478 * Math.sin(longitude_of_ascending_node_low_precision.radians)
87
+ - 0.00478 * longitude_of_ascending_node_low_precision.sin
88
88
  Angle.from_decimal_degrees(result)
89
89
  end
90
90
  end
@@ -94,7 +94,7 @@ module Lunation
94
94
  def corrected_obliquity_of_ecliptic
95
95
  @corrected_obliquity_of_ecliptic ||= begin
96
96
  result = mean_obliquity_of_ecliptic.decimal_degrees +
97
- 0.00256 * Math.cos(longitude_of_ascending_node.radians)
97
+ 0.00256 * longitude_of_ascending_node.cos
98
98
  Angle.from_decimal_degrees(result)
99
99
  end
100
100
  end
@@ -103,9 +103,9 @@ module Lunation
103
103
  # UNIT: Angle
104
104
  def sun_right_ascension
105
105
  @sun_right_ascension ||= begin
106
- numerator = Math.cos(corrected_obliquity_of_ecliptic.radians) *
107
- Math.sin(sun_ecliptic_longitude.radians)
108
- denominator = Math.cos(sun_ecliptic_longitude.radians)
106
+ numerator = corrected_obliquity_of_ecliptic.cos *
107
+ sun_ecliptic_longitude.sin
108
+ denominator = sun_ecliptic_longitude.cos
109
109
  Angle.from_radians(Math.atan2(numerator, denominator))
110
110
  end
111
111
  end
@@ -114,8 +114,8 @@ module Lunation
114
114
  # UNIT: Angle
115
115
  def sun_declination
116
116
  @sun_declination ||= begin
117
- result = Math.sin(corrected_obliquity_of_ecliptic.radians) *
118
- Math.sin(sun_ecliptic_longitude.radians)
117
+ result = corrected_obliquity_of_ecliptic.sin *
118
+ sun_ecliptic_longitude.sin
119
119
  Angle.from_radians(Math.asin(result), normalize: false)
120
120
  end
121
121
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lunation
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
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.2
4
+ version: 0.1.3
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-28 00:00:00.000000000 Z
11
+ date: 2024-12-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Lunation offers a Ruby implementation of Meeus's Astronomical Algorithms.
14
14
  email: