nabeelamjad/poke-api

View on GitHub
lib/poke-api/geometry/s2_lat_lon.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Poke
  module API
    module Geometry
      class S2LatLon
        def initialize(lat_degrees, lon_degrees)
          @lat = lat_degrees * Math::PI / 180
          @lon = lon_degrees * Math::PI / 180
        end

        def to_point
          phi    = @lat
          theta  = @lon
          cosphi = Math.cos(phi)
          S2Point.new(Math.cos(theta) * cosphi, Math.sin(theta) * cosphi, Math.sin(phi))
        end
      end
    end
  end
end