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
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.
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.
INSTRUCTION Add: Left Click Remove: Right Click (a) (b) Crossed polygon
Step by Step Solution
3.47 Rating (173 Votes )
There are 3 Steps involved in it
Program Plan Create a class nonCrossPolygon which extends Application In class nonCrossPolygon Create an inner class View which inherits Pane Create a ... View full answer
Get step-by-step solutions from verified subject matter experts
