(0, 0) (0, 1) (1, 1) (1, 0)describes a cube with the above four as its corners. Similarly,
(0, 0) (2, 2) (4, 0)describes a triangle. In general a sequence
(x1, y1) (x2, y2) (x3, y3) ... (xn, yn)describes the polygon formed by the lines
You are asked to solve the following problem: Given a polygon, described by a sequence of points, and a point, described by its x- and y-coordinate, does the point lie within the polygon?
For example, the points (0, 0) and (1, 1) lie within the polygon
(0, 0) (2, 2) (4, 0)but the point (0, 1) does not lie with that polygon.
To solve this problem, you may want to have a look at the API of the class contest.Polygon which can be found at the URL here. The class is already part of your classpath. For those using eclipse or NetBeans, a jar file containing the contest.Polygon class can be found here.
0 0 2 2 4 0 1 1
true