Class: GeometricPointInPolygon

Inherits:
Struct
  • Object
show all
Extended by:
Memoist
Defined in:
lib/flash_math/modules/geometry/geometric_point_in_polygon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointObject

Returns the value of attribute point

Returns:

  • (Object)

    the current value of point



1
2
3
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 1

def point
  @point
end

#polygonObject

Returns the value of attribute polygon

Returns:

  • (Object)

    the current value of polygon



1
2
3
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 1

def polygon
  @polygon
end

Instance Method Details

#inside?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 4

def inside?
  point_location == :inside
end

#on_the_boundary?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 12

def on_the_boundary?
  point_location == :on_the_boundary
end

#outside?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 8

def outside?
  point_location == :outside
end

#point_locationObject



16
17
18
19
20
21
# File 'lib/flash_math/modules/geometry/geometric_point_in_polygon.rb', line 16

def point_location
  return :outside unless bounding_box.contains?(point)
  return :on_the_boundary if point_is_vertex? || point_on_edge?

  intersection_count(choose_good_ray).odd? ? :inside : :outside
end