Class: Korba::Orbit
Instance Attribute Summary collapse
-
#epoch ⇒ Object
readonly
Returns the value of attribute epoch.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tle ⇒ Object
readonly
Returns the value of attribute tle.
Class Method Summary collapse
- .from_cartesian(cartesian) ⇒ Object
- .from_keplerian(keplerian) ⇒ Object
- .from_tle(tle = nil, type: :string) ⇒ Object
Instance Method Summary collapse
- #cartesian ⇒ Object
-
#initialize(keplerian: nil, cartesian: nil, tle: nil, epoch: nil, name: nil) ⇒ Orbit
constructor
A new instance of Orbit.
- #keplerian ⇒ Object
- #propagate(type:, seconds_after_epoch:, disable_j2: false) ⇒ Object
Methods included from Converter
#cartesian_to_keplerian, #keplerian_to_cartesian, #tle_to_cartesian, #tle_to_keplerian
Constructor Details
#initialize(keplerian: nil, cartesian: nil, tle: nil, epoch: nil, name: nil) ⇒ Orbit
Returns a new instance of Orbit.
23 24 25 26 27 28 29 |
# File 'lib/korba/orbit.rb', line 23 def initialize(keplerian: nil, cartesian: nil, tle: nil, epoch: nil, name: nil) @keplerian = keplerian @cartesian = cartesian @tle = tle @epoch = epoch @name = name end |
Instance Attribute Details
#epoch ⇒ Object (readonly)
Returns the value of attribute epoch.
6 7 8 |
# File 'lib/korba/orbit.rb', line 6 def epoch @epoch end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/korba/orbit.rb', line 6 def name @name end |
#tle ⇒ Object (readonly)
Returns the value of attribute tle.
6 7 8 |
# File 'lib/korba/orbit.rb', line 6 def tle @tle end |
Class Method Details
.from_cartesian(cartesian) ⇒ Object
18 19 20 |
# File 'lib/korba/orbit.rb', line 18 def from_cartesian(cartesian) new(cartesian:, epoch: cartesian.epoch, name: cartesian.object_name) end |
.from_keplerian(keplerian) ⇒ Object
14 15 16 |
# File 'lib/korba/orbit.rb', line 14 def from_keplerian(keplerian) new(keplerian:, epoch: keplerian.epoch, name: keplerian.object_name) end |
Instance Method Details
#cartesian ⇒ Object
31 32 33 |
# File 'lib/korba/orbit.rb', line 31 def cartesian @cartesian ||= tle_to_cartesian(tle) || keplerian_to_cartesian(keplerian) end |
#keplerian ⇒ Object
35 36 37 |
# File 'lib/korba/orbit.rb', line 35 def keplerian @keplerian ||= tle_to_keplerian(tle) || cartesian_to_keplerian(cartesian) end |
#propagate(type:, seconds_after_epoch:, disable_j2: false) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/korba/orbit.rb', line 39 def propagate(type:, seconds_after_epoch:, disable_j2: false) case type.to_sym in :sgp4 propagated_cartesian = tle.propagate_to(seconds_after_epoch / 60.0) return Orbit.from_cartesian(propagated_cartesian) in :rk4 propagator = Propagator::Rk4.new(cartesian, disable_j2:) propagated_cartesian = propagator.propagate(seconds_after_epoch) return Orbit.from_cartesian(propagated_cartesian) in :kepler propagator = Propagator::Kepler.new(keplerian, disable_j2:) propagated_keplerian = propagator.propagate(seconds_after_epoch) return Orbit.from_keplerian(propagated_keplerian) end end |