Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/geodesic.rb
Overview
Additions to Float for conversion between various units.
Instance Method Summary collapse
-
#to_bearing ⇒ Object
Convert radians to bearing.
-
#to_degrees ⇒ Object
Convert radians to degrees.
-
#to_radians ⇒ Object
Convert decimal degrees to radians.
Instance Method Details
#to_bearing ⇒ Object
Convert radians to bearing. Return degrees range 0.0 to 360.0.
34 35 36 |
# File 'lib/geodesic.rb', line 34 def to_bearing (self.to_degrees()+360.0) % 360.0 end |
#to_degrees ⇒ Object
Convert radians to degrees. Return range is -180.0 to 180.0.
29 30 31 |
# File 'lib/geodesic.rb', line 29 def to_degrees self * 180 / Math::PI end |
#to_radians ⇒ Object
Convert decimal degrees to radians. Input range is either -180.0 to 180.0 for longitudes, or -90.0 to 90.0 for latitudes.
24 25 26 |
# File 'lib/geodesic.rb', line 24 def to_radians self * Math::PI / 180.0 end |