Class: Poke::API::Geometry::S2Point

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, z) ⇒ S2Point

Returns a new instance of S2Point.



7
8
9
10
11
# File 'lib/poke-api/geometry/s2_point.rb', line 7

def initialize(x, y, z)
  @x = x
  @y = y
  @z = z
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

#zObject (readonly)

Returns the value of attribute z.



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

def z
  @z
end

Instance Method Details

#absObject



13
14
15
# File 'lib/poke-api/geometry/s2_point.rb', line 13

def abs
  [@x.abs, @y.abs, @z.abs]
end

#dot_prod(o) ⇒ Object



27
28
29
# File 'lib/poke-api/geometry/s2_point.rb', line 27

def dot_prod(o)
  @x * o.x + @y * o.y + @z * o.z
end

#largest_abs_componentObject



17
18
19
20
21
22
23
24
25
# File 'lib/poke-api/geometry/s2_point.rb', line 17

def largest_abs_component
  temp = abs

  if temp[0] > temp[1]
    temp[0] > temp[2] ? 0 : 2
  else
    temp[1] > temp[2] ? 1 : 2
  end
end