0

I'm trying to find points inside a non-uniform polygon (N edges) drawn on a canvas(JavaScript) by doing the following: First getting all the lines across the width of the canvas and looping through it to find the intersection of each line with how many polygon edges. If intersection is more than two then trying to get the points of intersection. Using this i'm trying to get the points between these points of intersection which will be the points inside polygon.

pavithra
  • 15
  • 6
  • 2
    yes, not "more than two", but "odd": https://en.wikipedia.org/wiki/Point_in_polygon – georg Apr 07 '19 at 08:29
  • What do you mean with N-dimensional polygon? You mean a series of connected N -dimensional shapes in a N+1 dimensional space? Or are you referring to the number of edges in a polygon? – trincot Apr 07 '19 at 08:31
  • I meant the number of edges. – pavithra Apr 07 '19 at 13:56
  • If every polygon has a different background color you may use the `getImageData()` method to get the colour of that particular pixel, and the compare it with the colors of the polygons. You may find the 2-nd & the 3-rd point of [this answer](https://stackoverflow.com/questions/55286455/how-to-determine-if-a-coordinate-is-inside-svg-close-path/55325957#55325957) useful. You also can use the `isPointInPath()` method – enxaneta Apr 07 '19 at 17:52

0 Answers0