Class: Float

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

Overview

Additions to Float for conversion between various units.

Instance Method Summary collapse

Instance Method Details

#to_bearingObject

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_degreesObject

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_radiansObject

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