Let's say I don't want to implement a new algorithm from scratch. Instead, I want to…
- User
Let's say I don't want to implement a new algorithm from scratch. Instead, I want to start with the output from the Delaunay hull that I get from scipy. So, let's say I have the following points that would make a star: points=[ Point(0, 5), Point(1, 2), Point(4, 2), Point(2, 0), Point(3, -3), Point(0, -1), Point(-3, -3), Point(-2, 0), Point(-4, 2), Point(-1, 2), ]
From here, I can create a Delaunay hull using scipy. How can I filter out the simplexes that are not a part of the star? My end goal is to tell if a point is within the bounds of the star (including the edges). For example, Point(0.5, 3.5) and Point(4,0) should be within the star, but Point(3.158, -0.19) should not be within the star.
- Assistant
To filter out the simplexes that are not a part of the star, you can perform the following steps:
- Import the necessary libraries:
import numpy as np from scipy.spatial import Delaunay- Define the points:
points = np.array([ (0, 5), (1, 2), (4, 2), (2, 0), (3, -3), (0, -1), (-3, -3), (-2, 0), (-4, 2), (-1, 2) ])- Create the Delaunay triangulation:
tri = Delaunay(points)- Retrieve the simplices of the Delaunay triangulation:
- User
Although star is the example, I would need to get the simplices of any polygon regardless of it being concave or not. How would I best do this?
- Assistant
To filter out the simplexes that are not part of any given polygon, regardless of its concavity, you can follow these general steps:
- Import the necessary libraries:
import numpy as np from scipy.spatial import Delaunay- Define the points representing your polygon:
points = np.array([ (0, 5), (1, 2), (4, 2), (2, 0), (3, -3), (0, -1), (-3, -3), (-2, 0), (-4, 2), (-1, 2) ])- Create the Delaunay triangulation:
tri = Delaunay(points)