Class: Poke::API::Geometry::S2Point
- Inherits:
-
Object
- Object
- Poke::API::Geometry::S2Point
- Defined in:
- lib/poke-api/geometry/s2_point.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
-
#z ⇒ Object
readonly
Returns the value of attribute z.
Instance Method Summary collapse
- #abs ⇒ Object
- #dot_prod(o) ⇒ Object
-
#initialize(x, y, z) ⇒ S2Point
constructor
A new instance of S2Point.
- #largest_abs_component ⇒ Object
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
#x ⇒ Object (readonly)
Returns the value of attribute x.
5 6 7 |
# File 'lib/poke-api/geometry/s2_point.rb', line 5 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
5 6 7 |
# File 'lib/poke-api/geometry/s2_point.rb', line 5 def y @y end |
#z ⇒ Object (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
#abs ⇒ Object
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_component ⇒ Object
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 |