Class: Orbit::GeocentricCoordinates
- Inherits:
-
Object
- Object
- Orbit::GeocentricCoordinates
- Defined in:
- lib/orbit/geocentric_coordinates.rb
Instance Attribute Summary collapse
-
#altitude ⇒ Object
Returns the value of attribute altitude.
-
#latitude_rad ⇒ Object
Returns the value of attribute latitude_rad.
-
#longitude_rad ⇒ Object
Returns the value of attribute longitude_rad.
Instance Method Summary collapse
-
#initialize(lat = nil, lon = nil, alt = 0) ⇒ GeocentricCoordinates
constructor
A new instance of GeocentricCoordinates.
- #latitude ⇒ Object
- #longitude ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(lat = nil, lon = nil, alt = 0) ⇒ GeocentricCoordinates
Returns a new instance of GeocentricCoordinates.
7 8 9 10 11 |
# File 'lib/orbit/geocentric_coordinates.rb', line 7 def initialize( lat = nil, lon = nil, alt = 0 ) @latitude_rad = lat @longitude_rad = lon @altitude = alt end |
Instance Attribute Details
#altitude ⇒ Object
Returns the value of attribute altitude.
5 6 7 |
# File 'lib/orbit/geocentric_coordinates.rb', line 5 def altitude @altitude end |
#latitude_rad ⇒ Object
Returns the value of attribute latitude_rad.
3 4 5 |
# File 'lib/orbit/geocentric_coordinates.rb', line 3 def latitude_rad @latitude_rad end |
#longitude_rad ⇒ Object
Returns the value of attribute longitude_rad.
4 5 6 |
# File 'lib/orbit/geocentric_coordinates.rb', line 4 def longitude_rad @longitude_rad end |
Instance Method Details
#latitude ⇒ Object
13 14 15 |
# File 'lib/orbit/geocentric_coordinates.rb', line 13 def latitude OrbitGlobals.rad_to_deg( @latitude_rad ) end |
#longitude ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/orbit/geocentric_coordinates.rb', line 17 def longitude l = OrbitGlobals.rad_to_deg( @longitude_rad ) if l > 180 l = 360 - l l *= -1 end l end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/orbit/geocentric_coordinates.rb', line 32 def to_s "Lat: #{latitude}, Lng: #{longitude}, Alt: #{altitude}" end |