Module: Korba::OrbitUtils
- Included in:
- Car, Kep, KeplersEquation, Propagator::Kepler, Tle
- Defined in:
- lib/korba/orbit_utils.rb
Instance Method Summary collapse
- #deg_to_rad(deg) ⇒ Object
- #distance ⇒ Object
- #eccentric_anomaly ⇒ Object
- #height_at_apogee ⇒ Object
- #height_at_perigee ⇒ Object
- #normalize_deg(deg) ⇒ Object
- #normalize_rad(rad) ⇒ Object
- #path_angle ⇒ Object
- #period ⇒ Object
- #rad_to_deg(rad) ⇒ Object
- #semi_major_axis ⇒ Object
- #true_anomaly ⇒ Object
- #velocity ⇒ Object
Instance Method Details
#deg_to_rad(deg) ⇒ Object
51 52 53 54 |
# File 'lib/korba/orbit_utils.rb', line 51 def deg_to_rad(deg) rad = deg * Math::PI / 180.0 normalize_rad(rad) end |
#distance ⇒ Object
36 37 38 |
# File 'lib/korba/orbit_utils.rb', line 36 def distance semi_major_axis * (1 - eccentricity * Math.cos(deg_to_rad(eccentric_anomaly))) end |
#eccentric_anomaly ⇒ Object
22 23 24 25 |
# File 'lib/korba/orbit_utils.rb', line 22 def eccentric_anomaly kepler = KeplersEquation.new(eccentricity:, mean_anomaly:) rad_to_deg(kepler.solve) end |
#height_at_apogee ⇒ Object
18 19 20 |
# File 'lib/korba/orbit_utils.rb', line 18 def height_at_apogee semi_major_axis * (1 + eccentricity) - Constant::EARTH_RADIUS end |
#height_at_perigee ⇒ Object
14 15 16 |
# File 'lib/korba/orbit_utils.rb', line 14 def height_at_perigee semi_major_axis * (1 - eccentricity) - Constant::EARTH_RADIUS end |
#normalize_deg(deg) ⇒ Object
65 66 67 |
# File 'lib/korba/orbit_utils.rb', line 65 def normalize_deg(deg) deg % 360.0 end |
#normalize_rad(rad) ⇒ Object
56 57 58 |
# File 'lib/korba/orbit_utils.rb', line 56 def normalize_rad(rad) rad % (2.0 * Math::PI) end |
#path_angle ⇒ Object
44 45 46 47 48 49 |
# File 'lib/korba/orbit_utils.rb', line 44 def path_angle return 0.0 if eccentricity < 1e-15 factor = Math.sqrt(Constant::GME * semi_major_axis * (1 - eccentricity ** 2)) / (distance * velocity) rad_to_deg(Math.acos(factor)) end |
#period ⇒ Object
10 11 12 |
# File 'lib/korba/orbit_utils.rb', line 10 def period 2.0 * Math::PI * Math.sqrt(semi_major_axis ** 3 / Constant::GME) end |
#rad_to_deg(rad) ⇒ Object
60 61 62 63 |
# File 'lib/korba/orbit_utils.rb', line 60 def rad_to_deg(rad) deg = rad * 180.0 / Math::PI normalize_deg(deg) end |
#semi_major_axis ⇒ Object
5 6 7 8 |
# File 'lib/korba/orbit_utils.rb', line 5 def semi_major_axis # a = (μ / n^2)^(1/3) m (Constant::GME / (mean_motion * 2.0 * Math::PI / 86400.0) ** 2.0) ** (1.0 / 3.0) end |
#true_anomaly ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/korba/orbit_utils.rb', line 27 def true_anomaly e_rad = deg_to_rad(eccentric_anomaly) y = Math.sqrt(1 - eccentricity ** 2) * Math.sin(e_rad) x = Math.cos(e_rad) - eccentricity # atan2(y, x) で正確な位相(-pi から pi)を求める rad_to_deg(Math.atan2(y, x)) end |