0
0
SciPydata~30 mins

Convex hull computation in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Convex Hull Computation with SciPy
📖 Scenario: Imagine you have a set of points on a map representing locations of trees in a park. You want to find the smallest fence that can enclose all these trees. This fence shape is called the convex hull.
🎯 Goal: You will create a list of points, configure a helper variable, compute the convex hull using SciPy, and finally print the vertices of the hull.
📋 What You'll Learn
Create a list of 2D points with exact coordinates
Create a variable to hold the number of points
Use SciPy's ConvexHull to compute the hull
Print the indices of the hull vertices
💡 Why This Matters
🌍 Real World
Convex hulls are used in geography to find boundaries around locations, in robotics for obstacle avoidance, and in computer graphics for shape analysis.
💼 Career
Understanding convex hulls helps in data analysis, spatial data processing, and computational geometry tasks common in data science and machine learning roles.
Progress0 / 4 steps
1
Create the list of points
Create a variable called points that is a list of these exact 2D points: [1, 1], [2, 5], [3, 3], [5, 3], [3, 2], [2, 2].
SciPy
Need a hint?

Use a list of lists to store the points exactly as shown.

2
Create a variable for the number of points
Create a variable called num_points that stores the number of points in the points list.
SciPy
Need a hint?

Use the len() function to count the points.

3
Compute the convex hull
Import ConvexHull from scipy.spatial. Then create a variable called hull by passing points to ConvexHull.
SciPy
Need a hint?

Use from scipy.spatial import ConvexHull and then call ConvexHull(points).

4
Print the convex hull vertices
Print the vertices attribute of the hull object to show the indices of points forming the convex hull.
SciPy
Need a hint?

Use print(hull.vertices) to show the hull points.