Kirkpatrick gives a data structure for point location in triangulated subdivisions with O(n) storage space and O(log n) query time. The general idea is to build a hierarchy of triangles. To perform a query, we start by finding the top-level triangle that contains the query point.
- The user is prompted to enter a region name and vertices.
- Vertices are processed, and some may be removed based on certain conditions.
- The program then asks the user to input coordinates for a point to check if it lies within a region.
- The result is printed, indicating whether the point is in the region or not.
- The user is given the option to continue or exit the program.
Enter a region name (or 'q' to quit): R1
Enter a region name (or 'q' to quit): q
Vertices: [(-100.80645161290323, 72.29437229437224), (-107.25806451612904, 37.66233766233765), (-64.9193548387097, 59.848484848484816), (-79.03225806451614, 80.9523809523809)]
Removing vertex: (-79.03225806451614, 80.9523809523809)
Independent points: [(-64.9193548387097, 59.848484848484816), (150, 0), (-150, 150), (-100.80645161290323, 72.29437229437224)]
Removing vertex: (-107.25806451612904, 37.66233766233765)
Independent points: [(-64.9193548387097, 59.848484848484816), (-100.80645161290323, 72.29437229437224), (-150, 150), (-150, -150)]
Removing vertex: (-100.80645161290323, 72.29437229437224)
Independent points: [(-64.9193548387097, 59.848484848484816), (150, 0), (-150, 150), (-150, -150)]
Enter the coordinates of the point to search: 0 1
Point lies in the region: External Region
Enter 1 to continue the program or -1 to exit: 1
Enter the coordinates of the point to search: 0 0
Point lies in the region: External Region
Enter 1 to continue the program or -1 to exit: -1
Follow these steps to run the project on your local machine:
-
Ensure you have Python installed on your system.
-
Install the required dependencies using the following command:
pip install matplotlib
-
Unzip the project repository.
-
Navigate to the project directory:
cd your-project
-
Run the main file:
python main_file.py