Write a program that enables the user to add/remove points by clicking the left/right mouse button, and

Question:

Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays a noncrossed polygon that links all the points, as shown in Figure 22.11a. A polygon is crossed if two or more sides intersect, as shown in Figure 22.11b. Use the following algorithm to construct a polygon from a set of points.image

Step 1: Given a set of points S, select the rightmost lowest point p0 in the set S.Step 2: Sort the points in S angularly along the x-axis with p0 as the center. If there is a tie and two points have the same angle, the one that is closer to p0 is considered greater. The points in S are now sorted as p0, p1, p2, ..., pn-1.Step 3: The sorted points form a non-cross polygon.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: