Class: Orbit::NoradSGP4

Inherits:
NoradBase show all
Defined in:
lib/orbit/norad_sgp4.rb

Instance Attribute Summary collapse

Attributes inherited from NoradBase

#m_aodp, #m_aycof, #m_betao, #m_betao2, #m_c1, #m_c3, #m_c4, #m_coef, #m_coef1, #m_cosio, #m_eeta, #m_eosq, #m_eta, #m_etasq, #m_omgdot, #m_perigee, #m_qoms24, #m_s4, #m_satEcc, #m_satInc, #m_sinio, #m_t2cof, #m_theta2, #m_tsi, #m_x1mth2, #m_x3thm1, #m_x7thm1, #m_xlcof, #m_xmdot, #m_xnodcf, #m_xnodot, #m_xnodp

Instance Method Summary collapse

Methods inherited from NoradBase

#final_position

Constructor Details

#initialize(orbit) ⇒ NoradSGP4

Returns a new instance of NoradSGP4.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/orbit/norad_sgp4.rb', line 13

def initialize( orbit )
  @orbit = orbit

  super

  @m_c5     = 2.0 * @m_coef1 * @m_aodp * @m_betao2 *
             (1.0 + 2.75 * (@m_etasq + @m_eeta) + @m_eeta * @m_etasq)
  @m_omgcof = orbit.bstar * @m_c3 * Math.cos(orbit.arg_perigee)
  @m_xmcof  = -(2.0 / 3.0) * @m_coef * orbit.bstar * OrbitGlobals::AE / @m_eeta
  @m_delmo  = ((1.0 + @m_eta * Math.cos(orbit.mean_anomaly) ) ** 3.0)
  @m_sinmo  = Math.sin(orbit.mean_anomaly)

end

Instance Attribute Details

#m_c5Object

Returns the value of attribute m_c5.



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

def m_c5
  @m_c5
end

#m_delmoObject

Returns the value of attribute m_delmo.



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

def m_delmo
  @m_delmo
end

#m_omgcofObject

Returns the value of attribute m_omgcof.



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

def m_omgcof
  @m_omgcof
end

#m_sinmoObject

Returns the value of attribute m_sinmo.



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

def m_sinmo
  @m_sinmo
end

#m_xmcofObject

Returns the value of attribute m_xmcof.



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

def m_xmcof
  @m_xmcof
end

#orbitObject

Returns the value of attribute orbit.



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

def orbit
  @orbit
end

Instance Method Details

#get_position(tsince) ⇒ Object



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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/orbit/norad_sgp4.rb', line 27

def get_position(tsince)
# puts "get_position( #{tsince} )"

# For @m_perigee less than 220 kilometers, the isimp flag is set and
# the equations are truncated to linear variation in Math.Sqrt a and
# quadratic variation in mean anomaly.  Also, the @m_c3 term, the
# delta omega term, and the delta m term are dropped.
isimp = false
if ((@m_aodp * (1.0 - @m_satEcc) / OrbitGlobals::AE) < (220.0 / OrbitGlobals::XKMPER + OrbitGlobals::AE))
 isimp = true
end

  d2 = 0.0
  d3 = 0.0
  d4 = 0.0

  t3cof = 0.0
  t4cof = 0.0
  t5cof = 0.0

  if (!isimp)
    c1sq = @m_c1 * @m_c1

    d2 = 4.0 * @m_aodp * @m_tsi * c1sq

    temp = d2 * @m_tsi * @m_c1 / 3.0

    d3 = (17.0 * @m_aodp + @m_s4) * temp
    d4 = 0.5 * temp * @m_aodp * @m_tsi *
      (221.0 * @m_aodp + 31.0 * @m_s4) * @m_c1
    t3cof = d2 + 2.0 * c1sq
    t4cof = 0.25 * (3.0 * d3 + @m_c1 * (12.0 * d2 + 10.0 * c1sq))
    t5cof = 0.2 * (3.0 * d4 + 12.0 * @m_c1 * d3 + 6.0 *
      d2 * d2 + 15.0 * c1sq * (2.0 * d2 + c1sq))
  end

  # Update for secular gravity and atmospheric drag.
  xmdf   = orbit.mean_anomaly + @m_xmdot * tsince
  omgadf = orbit.arg_perigee + @m_omgdot * tsince
  xnoddf = orbit.raan + @m_xnodot * tsince
  omega  = omgadf
  xmp    = xmdf
  tsq    = tsince * tsince
  xnode  = xnoddf + @m_xnodcf * tsq
  tempa  = 1.0 - @m_c1 * tsince
  tempe  = orbit.bstar * @m_c4 * tsince
  templ  = @m_t2cof * tsq

  if (!isimp)
     delomg = @m_omgcof * tsince
     delm = @m_xmcof * (((1.0 + @m_eta * Math.cos(xmdf) ) ** 3.0) - @m_delmo)
     temp = delomg + delm

     xmp = xmdf + temp
     omega = omgadf - temp

     tcube = tsq * tsince
     tfour = tsince * tcube

     tempa = tempa - d2 * tsq - d3 * tcube - d4 * tfour
     tempe = tempe + orbit.bstar * @m_c5 * (Math.sin(xmp) - @m_sinmo)
     templ = templ + t3cof * tcube + tfour * (t4cof + tsince * t5cof)
   end

  a  = @m_aodp * (tempa ** 2)
  e  = @m_satEcc - tempe


  xl = xmp + omega + xnode + @m_xnodp * templ
  xn = OrbitGlobals::XKE / (a ** 1.5)

  return final_position(@m_satInc, omgadf, e, a, xl, xnode, xn, tsince)
end