Class: Orbit::Orbit

Inherits:
Object
  • Object
show all
Defined in:
lib/orbit/orbit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tle) ⇒ Orbit

Returns a new instance of Orbit.



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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/orbit/orbit.rb', line 27

def initialize( tle )
  @tle = tle


  @epoch = tle.epoch
  # puts "Orbit @epoch is now: #{@epoch}"


  @m_Inclination   = OrbitGlobals.deg_to_rad(@tle.inclination)
  @m_Eccentricity  = @tle.eccentricity
  @m_RAAN          = OrbitGlobals.deg_to_rad(@tle.raan)
  @m_ArgPerigee    = OrbitGlobals.deg_to_rad(@tle.arg_perigee)
  @m_BStar         = @tle.bstar_drag
  @m_Drag          = @tle.mean_motion_dt
  @m_MeanAnomaly   = OrbitGlobals.deg_to_rad(@tle.mean_anomaly)
  @m_TleMeanMotion = @tle.mean_motion

  # Recover the original mean motion and semimajor axis from the
  # input elements.
  mm     = tle_mean_motion
  rpmin  = mm * OrbitGlobals::TWO_PI / OrbitGlobals::MIN_PER_DAY   # rads per minute

  a1     = (OrbitGlobals::XKE / rpmin) ** (2.0 / 3.0)
  e      = eccentricity
  i      = inclination
  temp   = (1.5 * OrbitGlobals::CK2 * (3.0 * (Math.cos(i) ** 2) - 1.0) /
                  ( (1.0 - e * e) ** 1.5 ) )
  delta1 = temp / (a1 * a1)
  a0     = a1 *
                 (1.0 - delta1 *
                 ((1.0 / 3.0) + delta1 *
                 (1.0 + 134.0 / 81.0 * delta1)))

  delta0 = temp / (a0 * a0)

  @m_rmMeanMotionRec    = rpmin / (1.0 + delta0)
  @m_aeAxisSemiMajorRec = a0 / (1.0 - delta0)
  @m_aeAxisSemiMinorRec = @m_aeAxisSemiMajorRec * Math.sqrt(1.0 - (e * e))
  @m_kmPerigeeRec       = OrbitGlobals::XKMPER * (m_aeAxisSemiMajorRec * (1.0 - e) - OrbitGlobals::AE)
  @m_kmApogeeRec        = OrbitGlobals::XKMPER * (m_aeAxisSemiMajorRec * (1.0 + e) - OrbitGlobals::AE)



  @period_minutes = calculate_period_minutes

  if @period_minutes > 225
    @norad_model = NoradSDP4.new( self )
  else
    @norad_model = NoradSGP4.new( self )
  end
end

Instance Attribute Details

#epochObject

Returns the value of attribute epoch.



22
23
24
# File 'lib/orbit/orbit.rb', line 22

def epoch
  @epoch
end

#m_aeAxisSemiMajorRecObject

Caching variables recovered from the input TLE elements



16
17
18
# File 'lib/orbit/orbit.rb', line 16

def m_aeAxisSemiMajorRec
  @m_aeAxisSemiMajorRec
end

#m_aeAxisSemiMinorRecObject

semiminor axis, in AE units



17
18
19
# File 'lib/orbit/orbit.rb', line 17

def m_aeAxisSemiMinorRec
  @m_aeAxisSemiMinorRec
end

#m_ArgPerigeeObject

Returns the value of attribute m_ArgPerigee.



9
10
11
# File 'lib/orbit/orbit.rb', line 9

def m_ArgPerigee
  @m_ArgPerigee
end

#m_BStarObject

Returns the value of attribute m_BStar.



10
11
12
# File 'lib/orbit/orbit.rb', line 10

def m_BStar
  @m_BStar
end

#m_DragObject

Returns the value of attribute m_Drag.



11
12
13
# File 'lib/orbit/orbit.rb', line 11

def m_Drag
  @m_Drag
end

#m_EccentricityObject

Returns the value of attribute m_Eccentricity.



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

def m_Eccentricity
  @m_Eccentricity
end

#m_InclinationObject

TLE caching variables



6
7
8
# File 'lib/orbit/orbit.rb', line 6

def m_Inclination
  @m_Inclination
end

#m_kmApogeeRecObject

apogee, in km



20
21
22
# File 'lib/orbit/orbit.rb', line 20

def m_kmApogeeRec
  @m_kmApogeeRec
end

#m_kmPerigeeRecObject

perigee, in km



19
20
21
# File 'lib/orbit/orbit.rb', line 19

def m_kmPerigeeRec
  @m_kmPerigeeRec
end

#m_MeanAnomalyObject

Returns the value of attribute m_MeanAnomaly.



13
14
15
# File 'lib/orbit/orbit.rb', line 13

def m_MeanAnomaly
  @m_MeanAnomaly
end

#m_RAANObject

Returns the value of attribute m_RAAN.



8
9
10
# File 'lib/orbit/orbit.rb', line 8

def m_RAAN
  @m_RAAN
end

#m_rmMeanMotionRecObject

radians per minute



18
19
20
# File 'lib/orbit/orbit.rb', line 18

def m_rmMeanMotionRec
  @m_rmMeanMotionRec
end

#m_TleMeanMotionObject

Returns the value of attribute m_TleMeanMotion.



12
13
14
# File 'lib/orbit/orbit.rb', line 12

def m_TleMeanMotion
  @m_TleMeanMotion
end

#norad_modelObject

Returns the value of attribute norad_model.



24
25
26
# File 'lib/orbit/orbit.rb', line 24

def norad_model
  @norad_model
end

#periodObject

Returns the value of attribute period.



25
26
27
# File 'lib/orbit/orbit.rb', line 25

def period
  @period
end

#tleObject

Returns the value of attribute tle.



3
4
5
# File 'lib/orbit/orbit.rb', line 3

def tle
  @tle
end

Instance Method Details

#apogeeObject



124
125
126
# File 'lib/orbit/orbit.rb', line 124

def apogee
 return @m_kmApogeeRec
end

#arg_perigeeObject



137
138
139
# File 'lib/orbit/orbit.rb', line 137

def arg_perigee
 return @m_ArgPerigee
end

#bstarObject



140
141
142
# File 'lib/orbit/orbit.rb', line 140

def bstar
 return @m_BStar
end

#calculate_period_minutesObject



79
80
81
82
83
84
85
86
87
# File 'lib/orbit/orbit.rb', line 79

def calculate_period_minutes
  if @tle.mean_motion == 0
    minutes = 0.0
  else
    minutes = (OrbitGlobals::TWO_PI / @tle.mean_motion)
  end

  minutes
end

#dragObject



143
144
145
# File 'lib/orbit/orbit.rb', line 143

def drag
 return @m_Drag
end

#eccentricityObject



131
132
133
# File 'lib/orbit/orbit.rb', line 131

def eccentricity
 return @m_Eccentricity
end

#epoch_timeObject



102
103
104
# File 'lib/orbit/orbit.rb', line 102

def epoch_time
  @epoch
end

#get_position(minutesPastEpoch) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/orbit/orbit.rb', line 89

def get_position(minutesPastEpoch)
  # puts "Orbit.get_position( #{minutesPastEpoch} )"

  eci = @norad_model.get_position(minutesPastEpoch)

  # puts "Position: #{eci.m_Position.m_x}"

  eci.scale_pos_vector(OrbitGlobals::XKMPER / OrbitGlobals::AE)      # km
  eci.scale_vel_vector((OrbitGlobals::XKMPER / OrbitGlobals::AE) *
                    (OrbitGlobals::MIN_PER_DAY / 86400.0))      # km/sec
  return eci
end

#inclinationObject



128
129
130
# File 'lib/orbit/orbit.rb', line 128

def inclination
 return @m_Inclination
end

#majorObject



115
116
117
# File 'lib/orbit/orbit.rb', line 115

def major
 return 2.0 * SemiMajor
end

#mean_anomalyObject



146
147
148
# File 'lib/orbit/orbit.rb', line 146

def mean_anomaly
 return @m_MeanAnomaly
end

#mean_motionObject



112
113
114
# File 'lib/orbit/orbit.rb', line 112

def mean_motion
 return @m_rmMeanMotionRec
end

#minorObject



118
119
120
# File 'lib/orbit/orbit.rb', line 118

def minor
 return 2.0 * SemiMinor
end

#perigeeObject



121
122
123
# File 'lib/orbit/orbit.rb', line 121

def perigee
 return @m_kmPerigeeRec
end

#raanObject



134
135
136
# File 'lib/orbit/orbit.rb', line 134

def raan
 return @m_RAAN
end

#sat_nameObject



156
157
158
# File 'lib/orbit/orbit.rb', line 156

def sat_name
 return @tle.name
end

#sat_name_longObject



159
160
161
# File 'lib/orbit/orbit.rb', line 159

def sat_name_long
 return SatName + " #" + SatNoradId
end

#sat_norad_idObject



153
154
155
# File 'lib/orbit/orbit.rb', line 153

def sat_norad_id
 return @tle.norad_number
end

#semi_majorObject



106
107
108
# File 'lib/orbit/orbit.rb', line 106

def semi_major
 return @m_aeAxisSemiMajorRec
end

#semi_minorObject



109
110
111
# File 'lib/orbit/orbit.rb', line 109

def semi_minor
 return @m_aeAxisSemiMinorRec
end

#tle_mean_motionObject



149
150
151
# File 'lib/orbit/orbit.rb', line 149

def tle_mean_motion
 return @m_TleMeanMotion
end