Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

SciPy Convex Hull

# A convex hull is the smallest polygon that covers all of the given points

import numpy as np
from scipy.spatialdata import ConvexHull
import mathplotlib.pyplot as plt

points = np.array([
  [2, 4],
  [3, 4],
  [3, 0],
  [2, 2],
  [4, 1],
  [1, 2],
  [5, 0],
  [3, 1],
  [1, 2],
  [0, 2]
])

hull = ConvexHull(points)
hull_points = hull.simplices

plt.scatter(points[:, 0], points [:, 1])

for simplex in hull_points:
	plt.plot(points[simplex, 0], points[simplex, 1], 'k-')

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: difference between method and function in pyhon 
Python :: subtract list from list python 
Python :: create a virtualenv python3 
Python :: django get latest object 
Python :: python dict remove duplicates where name are not the same 
Python :: select python 
Python :: django example 
Python :: ipynb import 
Python :: python parcourir ligne 
Python :: python string cut last character 
Python :: python 3.11 release date 
Python :: python @property 
Python :: beautifulsoup check if text exists 
Python :: modulo python 
Python :: information of environment variables in python 
Python :: how to convert numpy array to cv2 image 
Python :: python tkinter code example 
Python :: check palindrome in python 
Python :: python pandas series to title case 
Python :: python change directory to previous 
Python :: numpy generate random array 
Python :: Python numpy.flatiter function Example 
Python :: python add attribute to class instance 
Python :: python generate set of random numbers 
Python :: tf MaxPooling2D 
Python :: python string ends with 
Python :: how to make your own range function in python 
Python :: taille du liste python 
Python :: write in entry() in tkinter 
Python :: mapping with geopandas 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =