Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The goal of this task is the implementation of a class Polygon. This class shall provide some basic features for simple polygons, i.e. polygons without
The goal of this task is the implementation of a class Polygon. This class shall provide some basic features for simple polygons, i.e. polygons without holes that do not intersect them- selves. Once such a polygon is created, further modification is not desired. It is initialized with an array of n Points which themselves are defined through 2-dimensional coordinates (x and y). Besides the points, each polygon stores information about its bounding box. The class Polygon provides one method for getting the bounding box as an array of double values and another method for getting the number of points defining the polygon. Further, there are methods for computing the area and the perimeter of a polygon. Finally, there are two different methods for finding out whether a point is contained within a polygon or not: one that considers the bounding box and one that does not. Set up a UML class diagram and implement the model in Java. Task 2 Test the implementation of Task 1 with the following experimental set up. Consider regular n-gons inscribed in a circle with radius 1 with center (0, 0) for different n e {3, 4, ..., 10000} that all contain the point (0, 1). (0, 1) a) Compare every n-gon to the circle C with radius 1 and center (0, 0). For this purpose, compute for every P the Jaccard index (0, 0) area(P n C) J(P, C) = (0,1) area(P C) b) Compare the running times for the methods check- ing whether a point is contained within a polygon. Determine the time it takes to check for each n- gn whether a point (0, -0.99999995) is contained or not. Use the method System.nano Time(). (0, 0) Figure 1: Regular n-gons for n 3 (red), n 4 (green), n = 5 (violet), and n = 6 (orange) The goal of this task is the implementation of a class Polygon. This class shall provide some basic features for simple polygons, i.e. polygons without holes that do not intersect them- selves. Once such a polygon is created, further modification is not desired. It is initialized with an array of n Points which themselves are defined through 2-dimensional coordinates (x and y). Besides the points, each polygon stores information about its bounding box. The class Polygon provides one method for getting the bounding box as an array of double values and another method for getting the number of points defining the polygon. Further, there are methods for computing the area and the perimeter of a polygon. Finally, there are two different methods for finding out whether a point is contained within a polygon or not: one that considers the bounding box and one that does not. Set up a UML class diagram and implement the model in Java. Task 2 Test the implementation of Task 1 with the following experimental set up. Consider regular n-gons inscribed in a circle with radius 1 with center (0, 0) for different n e {3, 4, ..., 10000} that all contain the point (0, 1). (0, 1) a) Compare every n-gon to the circle C with radius 1 and center (0, 0). For this purpose, compute for every P the Jaccard index (0, 0) area(P n C) J(P, C) = (0,1) area(P C) b) Compare the running times for the methods check- ing whether a point is contained within a polygon. Determine the time it takes to check for each n- gn whether a point (0, -0.99999995) is contained or not. Use the method System.nano Time(). (0, 0) Figure 1: Regular n-gons for n 3 (red), n 4 (green), n = 5 (violet), and n = 6 (orange)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started