Class: Poke::API::Geometry::S2LatLon

Inherits:
Object
  • Object
show all
Defined in:
lib/poke-api/geometry/s2_lat_lon.rb

Instance Method Summary collapse

Constructor Details

#initialize(lat_degrees, lon_degrees) ⇒ S2LatLon

Returns a new instance of S2LatLon.



5
6
7
8
# File 'lib/poke-api/geometry/s2_lat_lon.rb', line 5

def initialize(lat_degrees, lon_degrees)
  @lat = lat_degrees * Math::PI / 180
  @lon = lon_degrees * Math::PI / 180
end

Instance Method Details

#to_pointObject



10
11
12
13
14
15
# File 'lib/poke-api/geometry/s2_lat_lon.rb', line 10

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