Class: Korba::Car

Inherits:
Object
  • Object
show all
Includes:
OrbitUtils
Defined in:
lib/korba/car.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OrbitUtils

#deg_to_rad, #height_at_apogee, #height_at_perigee, #normalize_deg, #normalize_rad, #path_angle, #rad_to_deg

Constructor Details

#initialize(object_name:, epoch:, x:, y:, z:, vx:, vy:, vz:) ⇒ Car

Returns a new instance of Car.



9
10
11
12
13
14
15
16
17
18
# File 'lib/korba/car.rb', line 9

def initialize(object_name:, epoch:, x:, y:, z:, vx:, vy:, vz:)
  @object_name = object_name
  @epoch = epoch
  @x = x
  @y = y
  @z = z
  @vx = vx
  @vy = vy
  @vz = vz
end

Instance Attribute Details

#epochObject (readonly)

Returns the value of attribute epoch.



7
8
9
# File 'lib/korba/car.rb', line 7

def epoch
  @epoch
end

#object_nameObject (readonly)

Returns the value of attribute object_name.



7
8
9
# File 'lib/korba/car.rb', line 7

def object_name
  @object_name
end

#vxObject (readonly)

Returns the value of attribute vx.



7
8
9
# File 'lib/korba/car.rb', line 7

def vx
  @vx
end

#vyObject (readonly)

Returns the value of attribute vy.



7
8
9
# File 'lib/korba/car.rb', line 7

def vy
  @vy
end

#vzObject (readonly)

Returns the value of attribute vz.



7
8
9
# File 'lib/korba/car.rb', line 7

def vz
  @vz
end

#xObject (readonly)

Returns the value of attribute x.



7
8
9
# File 'lib/korba/car.rb', line 7

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



7
8
9
# File 'lib/korba/car.rb', line 7

def y
  @y
end

#zObject (readonly)

Returns the value of attribute z.



7
8
9
# File 'lib/korba/car.rb', line 7

def z
  @z
end

Instance Method Details

#to_kepObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/korba/car.rb', line 20

def to_kep
  inclination = rad_to_deg(Math.atan2(Math.sqrt(specific_angular_momentum_vector[0] ** 2 + specific_angular_momentum_vector[1] ** 2), specific_angular_momentum_vector[2]))
  ra_of_asc_node = rad_to_deg(Math.atan2(specific_angular_momentum_vector[0], -specific_angular_momentum_vector[1]))

  Kep.new(object_name:,
          epoch:,
          semi_major_axis:,
          eccentricity:,
          inclination:,
          ra_of_asc_node:,
          arg_of_pericenter: normalize_deg(arg_of_latitude - true_anomaly),
          mean_anomaly: rad_to_deg(deg_to_rad(eccentric_anomaly) - eccentricity * Math.sin(deg_to_rad(eccentric_anomaly))))
end