Class: Mindee::Geometry::Polygon

Inherits:
Array
  • Object
show all
Defined in:
lib/mindee/geometry/polygon.rb

Overview

Contains any number of vertex coordinates (Points).

Instance Method Summary collapse

Instance Method Details

#centroidMindee::Geometry::Point

Get the central point (centroid) of the polygon.



10
11
12
# File 'lib/mindee/geometry/polygon.rb', line 10

def centroid
  Geometry.get_centroid(self)
end

#point_in_y?(point) ⇒ Boolean

Determine if the Point is in the Polygon’s Y-axis.

Parameters:

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/mindee/geometry/polygon.rb', line 17

def point_in_y?(point)
  min_max = Geometry.get_min_max_y(self)
  min_max.min <= point.y && point.y <= min_max.max
end