Class: Orbit::OrbitGlobals
- Inherits:
-
Object
- Object
- Orbit::OrbitGlobals
- Defined in:
- lib/orbit/orbit_globals.rb
Constant Summary collapse
- PI =
3.141592653589793- TWO_PI =
2.0 * OrbitGlobals::PI
- RADS_PER_DEGREE =
OrbitGlobals::PI / 180.0
- DEGREES_PER_RAD =
180.0 / OrbitGlobals::PI
- GM =
Earth gravitational constant, km^3/sec^2
398601.2- GEO_SYNC_ALT =
km
42241.892- EARTHDIAM =
km
12800.0- DAYSIDEREAL =
sec
(23 * 3600) + (56 * 60) + 4.09
- DAYSOLAR =
sec
(24 * 3600.0)
- AE =
1.0- AU =
Astronomical unit (km) (IAU 76)
149597870.0- SR =
Solar radius (km) (IAU 76)
696000.0- XKMPER =
Earth equatorial radius - kilometers (WGS ‘72)
6378.135- F =
Earth flattening (WGS ‘72)
1.0 / 298.26
- GE =
Earth gravitational constant (WGS ‘72)
398600.8- J2 =
J2 harmonic (WGS ‘72)
1.0826158E-3- J3 =
J3 harmonic (WGS ‘72)
-2.53881E-6 # J3 harmonic (WGS '72)
- J4 =
J4 harmonic (WGS ‘72)
-1.65597E-6 # J4 harmonic (WGS '72)
- CK2 =
OrbitGlobals::J2 / 2.0
- CK4 =
-3.0 * OrbitGlobals::J4 / 8.0
- XJ3 =
OrbitGlobals::J3
- QO =
OrbitGlobals::AE + 120.0 / OrbitGlobals::XKMPER
- S =
OrbitGlobals::AE + 78.0 / OrbitGlobals::XKMPER
- MIN_PER_DAY =
Minutes per day (solar)
1440.0- SEC_PER_DAY =
Seconds per day (solar)
86400.0- OMEGAE =
Earth rotation per sidereal day
1.00273790934- XKE =
Math.sqrt(3600.0 * OrbitGlobals::GE / (OrbitGlobals::XKMPER * OrbitGlobals::XKMPER * OrbitGlobals::XKMPER))
- QOMS2T =
(QO - S)^4 ER^4
((OrbitGlobals::QO - OrbitGlobals::S) ** 4.0)
Class Method Summary collapse
-
.actan(sinx, cosx) ⇒ Object
// /////////////////////////////////////////////////////////////////////////// // Globals.AcTan() // ArcTangent of sin(x) / cos(x).
- .deg_to_rad(deg) ⇒ Object
- .fmod2p(arg) ⇒ Object
- .rad_to_deg(rad) ⇒ Object
- .sqr(n) ⇒ Object
- .time_to_gmst(t) ⇒ Object
-
.time_to_lmst(t, lon) ⇒ Object
///////////////////////////////////////////////////////////////////// ToLmst() Calculate Local Mean Sidereal Time for given longitude (for this date).
Class Method Details
.actan(sinx, cosx) ⇒ Object
// ///////////////////////////////////////////////////////////////////////////
// Globals.AcTan()
// ArcTangent of sin(x) / cos(x). The advantage of this function over arctan()
// is that it returns the correct quadrant of the angle.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/orbit/orbit_globals.rb', line 65 def self.actan( sinx, cosx) ret = nil if (cosx == 0.0) if (sinx > 0.0) ret = PI / 2.0 else ret = 3.0 * PI / 2.0 end else if (cosx > 0.0) ret = Math.atan(sinx / cosx) else ret = PI + Math.atan(sinx / cosx) end end return ret end |
.deg_to_rad(deg) ⇒ Object
42 43 44 |
# File 'lib/orbit/orbit_globals.rb', line 42 def self.deg_to_rad( deg ) deg * RADS_PER_DEGREE; end |
.fmod2p(arg) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/orbit/orbit_globals.rb', line 51 def self.fmod2p(arg) modu = (arg % TWO_PI); if (modu < 0.0) modu += TWO_PI end return modu end |
.rad_to_deg(rad) ⇒ Object
46 47 48 |
# File 'lib/orbit/orbit_globals.rb', line 46 def self.rad_to_deg( rad ) rad * DEGREES_PER_RAD; end |
.sqr(n) ⇒ Object
38 39 40 |
# File 'lib/orbit/orbit_globals.rb', line 38 def self.sqr( n ) n ** 2 end |
.time_to_gmst(t) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/orbit/orbit_globals.rb', line 85 def self.time_to_gmst(t) jd = t.to_date.jd - 0.5 seconds = (t.hour * 3600) + (t.min * 60) + (t.sec).to_f + (t.subsec).to_f fraction_of_day = seconds / 86400.0 jd += fraction_of_day #puts "jd: #{jd}" ut = (jd + 0.5 ) % 1.0; jd = jd - ut tu = (jd - 2451545.0) / 36525.0 gmst = 24110.54841 + tu * (8640184.812866 + tu * (0.093104 - tu * 6.2E-6)); gmst = ( gmst + 86400.0 * 1.00273790934 * ut ) % 86400.0 if (gmst < 0.0) gmst += 86400.0 # "wrap" negative modulo value end gmst = (OrbitGlobals::TWO_PI * (gmst / 86400.0)) # puts "gmst: #{gmst}" gmst end |
.time_to_lmst(t, lon) ⇒ Object
///////////////////////////////////////////////////////////////////// ToLmst() Calculate Local Mean Sidereal Time for given longitude (for this date). The longitude is assumed to be in radians measured west from Greenwich. The return value is the angle, in radians, measuring eastward from the Vernal Equinox to the given longitude.
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/orbit/orbit_globals.rb', line 116 def self.time_to_lmst (t, lon) gmst = OrbitGlobals.time_to_gmst( t ) lmst = ( gmst + lon ) % TWO_PI # puts "long: #{lon}" # puts "gmst: #{gmst}" # puts "lmst: #{lmst}" lmst end |