Class: Korba::Kep
Instance Attribute Summary collapse
-
#arg_of_pericenter ⇒ Object
readonly
Returns the value of attribute arg_of_pericenter.
-
#eccentricity ⇒ Object
readonly
Returns the value of attribute eccentricity.
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#inclination ⇒ Object
readonly
Returns the value of attribute inclination.
-
#mean_anomaly ⇒ Object
readonly
Returns the value of attribute mean_anomaly.
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
-
#ra_of_asc_node ⇒ Object
readonly
Returns the value of attribute ra_of_asc_node.
-
#semi_major_axis ⇒ Object
readonly
Returns the value of attribute semi_major_axis.
Instance Method Summary collapse
-
#initialize(object_name:, epoch:, semi_major_axis:, eccentricity:, inclination:, ra_of_asc_node:, arg_of_pericenter:, mean_anomaly:) ⇒ Kep
constructor
A new instance of Kep.
- #to_car ⇒ Object
Methods included from OrbitUtils
#deg_to_rad, #distance, #eccentric_anomaly, #height_at_apogee, #height_at_perigee, #normalize_deg, #normalize_rad, #path_angle, #rad_to_deg, #true_anomaly, #velocity
Constructor Details
#initialize(object_name:, epoch:, semi_major_axis:, eccentricity:, inclination:, ra_of_asc_node:, arg_of_pericenter:, mean_anomaly:) ⇒ Kep
Returns a new instance of Kep.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/korba/kep.rb', line 10 def initialize(object_name:, epoch:, semi_major_axis:, eccentricity:, inclination:, ra_of_asc_node:, arg_of_pericenter:, mean_anomaly:) @object_name = object_name @epoch = epoch @semi_major_axis = semi_major_axis @eccentricity = eccentricity @inclination = inclination @ra_of_asc_node = ra_of_asc_node @arg_of_pericenter = arg_of_pericenter @mean_anomaly = mean_anomaly end |
Instance Attribute Details
#arg_of_pericenter ⇒ Object (readonly)
Returns the value of attribute arg_of_pericenter.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def arg_of_pericenter @arg_of_pericenter end |
#eccentricity ⇒ Object (readonly)
Returns the value of attribute eccentricity.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def eccentricity @eccentricity end |
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def epoch @epoch end |
#inclination ⇒ Object (readonly)
Returns the value of attribute inclination.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def inclination @inclination end |
#mean_anomaly ⇒ Object (readonly)
Returns the value of attribute mean_anomaly.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def mean_anomaly @mean_anomaly end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def object_name @object_name end |
#ra_of_asc_node ⇒ Object (readonly)
Returns the value of attribute ra_of_asc_node.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def ra_of_asc_node @ra_of_asc_node end |
#semi_major_axis ⇒ Object (readonly)
Returns the value of attribute semi_major_axis.
8 9 10 |
# File 'lib/korba/kep.rb', line 8 def semi_major_axis @semi_major_axis end |
Instance Method Details
#to_car ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/korba/kep.rb', line 21 def to_car # 特異点対応: inclinationが0(または極めて小さい)場合の処理 is_equatorial = inclination.abs < 1e-10 if is_equatorial # 赤道面内の場合、x軸を基準にする vector_omega = Vector[1.0, 0.0, 0.0] vector_m = Vector[0.0, 1.0, 0.0] vector_n = Vector[0.0, 0.0, 1.0] else vector_n = Vector[ Math.sin(deg_to_rad(inclination)) * Math.sin(deg_to_rad(ra_of_asc_node)), -Math.sin(deg_to_rad(inclination)) * Math.cos(deg_to_rad(ra_of_asc_node)), Math.cos(deg_to_rad(inclination)) ] vector_omega = Vector[Math.cos(deg_to_rad(ra_of_asc_node)), Math.sin(deg_to_rad(ra_of_asc_node)), 0.0] vector_m = vector_n.cross(vector_omega) end r_angle_factor = deg_to_rad(arg_of_pericenter + true_anomaly) vector_r = distance * (Math.cos(r_angle_factor) * vector_omega + Math.sin(r_angle_factor) * vector_m) v_angle_factor = deg_to_rad(arg_of_pericenter + true_anomaly - path_angle) vector_v = velocity * (-Math.sin(v_angle_factor) * vector_omega + (Math.cos(v_angle_factor)) * vector_m) # NOTE: こっちでもいい # factor_matrix = Matrix[[Math.cos(deg_to_rad(ra_of_asc_node)), -Math.sin(deg_to_rad(ra_of_asc_node)) * Math.cos(deg_to_rad(inclination))], # [Math.sin(deg_to_rad(ra_of_asc_node)), Math.cos(deg_to_rad(ra_of_asc_node)) * Math.cos(deg_to_rad(inclination))], # [0, Math.sin(deg_to_rad(inclination))]] * # Matrix[[Math.cos(deg_to_rad(arg_of_pericenter)), -Math.sin(deg_to_rad(arg_of_pericenter))], [Math.sin(deg_to_rad(arg_of_pericenter)), Math.cos(deg_to_rad(arg_of_pericenter))]] # vector_r = Vector[*(factor_matrix * Matrix[[Math.cos(deg_to_rad(true_anomaly)) - eccentricity], [Math.sqrt(1 - eccentricity ** 2) * Math.sin(deg_to_rad(true_anomaly))]] * semi_major_axis).to_a.flatten] # vector_v = Vector[*(factor_matrix * Matrix[[-Math.sin(deg_to_rad(true_anomaly))], [Math.sqrt(1 - eccentricity ** 2) * Math.cos(deg_to_rad(true_anomaly))]] * Math.sqrt(Constant::GME * semi_major_axis) / vector_r.norm).to_a.flatten] Car.new(object_name:, epoch:, x: vector_r[0], y: vector_r[1], z: vector_r[2], vx: vector_v[0], vy: vector_v[1], vz: vector_v[2]) end |