A closed polygon may be described by an N x 2 array of nodes, where the last node and the first node are the same. Each row of the array is a 2-element vector giving the x and y coordinates of a node. The polygon is described by straight-line segments that go from node to node.
In this problem, we provide you with a polygon p of this type, and with a number of points r, each having an x and y coordinate. You are to determine whether each point falls inside or outside the polygon. If the point is inside the polygon, return the value 1. If outside, return the value 0.
HINT: One way to solve this is to find a point 'p_test' that is outside of the polygon, and then to count the number of times that a line from 'r' to 'p_test' crosses the sides of the polygon.
1914 Solvers
1594 Solvers
1317 Solvers
357 Solvers
I've got the power! (Inspired by Project Euler problem 29)
75 Solvers