Class: Ephem::Core::State
- Inherits:
-
Object
- Object
- Ephem::Core::State
- Defined in:
- lib/ephem/core/state.rb
Overview
Represents the state of a celestial object in space, consisting of its position and velocity vectors. This class is fundamental for describing orbital motion and performing astronomical calculations.
Instance Attribute Summary collapse
-
#position ⇒ Ephem::Vector
readonly
The position vector of the object.
-
#velocity ⇒ Ephem::Vector
readonly
The velocity vector of the object.
Class Method Summary collapse
-
.from_arrays(position, velocity) ⇒ Ephem::State
Creates a State instance from arrays of position and velocity components.
Instance Method Summary collapse
-
#initialize(position, velocity) ⇒ State
constructor
Creates a new State instance.
-
#to_arrays ⇒ Array<Array<Numeric>>
Converts the state vectors to arrays.
Constructor Details
#initialize(position, velocity) ⇒ State
Creates a new State instance.
29 30 31 32 |
# File 'lib/ephem/core/state.rb', line 29 def initialize(position, velocity) @position = position @velocity = velocity end |
Instance Attribute Details
#position ⇒ Ephem::Vector (readonly)
Returns The position vector of the object.
15 16 17 |
# File 'lib/ephem/core/state.rb', line 15 def position @position end |
#velocity ⇒ Ephem::Vector (readonly)
Returns The velocity vector of the object.
18 19 20 |
# File 'lib/ephem/core/state.rb', line 18 def velocity @velocity end |
Class Method Details
.from_arrays(position, velocity) ⇒ Ephem::State
Creates a State instance from arrays of position and velocity components.
47 48 49 50 51 52 |
# File 'lib/ephem/core/state.rb', line 47 def self.from_arrays(position, velocity) new( Vector.new(position[0], position[1], position[2]), Vector.new(velocity[0], velocity[1], velocity[2]) ) end |
Instance Method Details
#to_arrays ⇒ Array<Array<Numeric>>
Converts the state vectors to arrays.
61 62 63 |
# File 'lib/ephem/core/state.rb', line 61 def to_arrays [position.to_a, velocity.to_a] end |