Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Oignon convex hull
#4
Here is my new code :
Oups,made a mistake with the code ... I don't know how to edit :(
Can you explain me my mistake ?
Thanks a lot,
Scientifix

Here is the correct one :
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
import numpy as np

points = np.random.rand(30, 2)

Plot = True

def min_convex(points):
 
    oignon_layers = []    
 
    while len(points) > 4:
        layer = ConvexHull(points)
        oignon_layers.append(layer)
        points =  points = np.delete(points, layer.vertices, axis=0)
 
    if Plot == True:
          plt.plot(points[:,0], points[:,1], 'o')
          for layer in oignon_layers:
              for simplex in layer.simplices:
                 plt.plot(points[simplex, 0], points[simplex, 1], 'k-')  
    plt.show()
with the error:
Error:
plt.plot(points[simplex, 0], points[simplex, 1],'k-')  IndexError: index 24 is out of bounds for axis 0 with size 4
Reply


Messages In This Thread
Oignon convex hull - by Scientifix - Oct-25-2016, 07:59 PM
RE: Oignon convex hull - by Yoriz - Oct-25-2016, 08:20 PM
RE: Oignon convex hull - by Scientifix - Oct-26-2016, 07:25 AM
RE: Oignon convex hull - by Scientifix - Oct-29-2016, 08:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help in solving Oignon convex hull petermarsi 1 1,819 Apr-28-2021, 10:23 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020