convex-hull

Perimeter of a 2D convex hull in Python

萝らか妹 提交于 2021-02-10 20:46:29
问题 How can I calculate the perimeter of a convex hull in Python? I know SciPy has the area parameter for convex hulls; however, I need the perimeter . 回答1: You can iterate over the points of the convex hull and compute the distance between consecutive points: import numpy as np from scipy.spatial.qhull import ConvexHull from scipy.spatial.distance import euclidean points = np.random.rand(30, 2) hull = ConvexHull(points) vertices = hull.vertices.tolist() + [hull.vertices[0]] perimeter = np.sum(

Perimeter of a 2D convex hull in Python

半世苍凉 提交于 2021-02-10 20:44:32
问题 How can I calculate the perimeter of a convex hull in Python? I know SciPy has the area parameter for convex hulls; however, I need the perimeter . 回答1: You can iterate over the points of the convex hull and compute the distance between consecutive points: import numpy as np from scipy.spatial.qhull import ConvexHull from scipy.spatial.distance import euclidean points = np.random.rand(30, 2) hull = ConvexHull(points) vertices = hull.vertices.tolist() + [hull.vertices[0]] perimeter = np.sum(

Perimeter of a 2D convex hull in Python

北城以北 提交于 2021-02-10 20:43:01
问题 How can I calculate the perimeter of a convex hull in Python? I know SciPy has the area parameter for convex hulls; however, I need the perimeter . 回答1: You can iterate over the points of the convex hull and compute the distance between consecutive points: import numpy as np from scipy.spatial.qhull import ConvexHull from scipy.spatial.distance import euclidean points = np.random.rand(30, 2) hull = ConvexHull(points) vertices = hull.vertices.tolist() + [hull.vertices[0]] perimeter = np.sum(

Fit maximum convex hull to interior of a set of points

守給你的承諾、 提交于 2021-02-07 09:46:51
问题 I'd like to find the largest convex hull which fits in the interior of a set of points. I have a set of points which are roughly circular, with a large number of outlier points outside of the circle I'd like to fit. Imagine a circle with "solar flares"... I want to fit the circle and completely ignore the flares. I've tried various fit and culling strategies, but they aren't working well. I've searched quite a bit and not found a solution. Thanks in advance. 回答1: The notion you need may be

Fit maximum convex hull to interior of a set of points

浪子不回头ぞ 提交于 2021-02-07 09:45:49
问题 I'd like to find the largest convex hull which fits in the interior of a set of points. I have a set of points which are roughly circular, with a large number of outlier points outside of the circle I'd like to fit. Imagine a circle with "solar flares"... I want to fit the circle and completely ignore the flares. I've tried various fit and culling strategies, but they aren't working well. I've searched quite a bit and not found a solution. Thanks in advance. 回答1: The notion you need may be

How do I find the Pareto-optimal points in O(nh) and O(nlog(h)) complexity?

心已入冬 提交于 2021-01-29 04:00:37
问题 Can anybody suggest an algorithm to find Pareto-optimal points (to form a staircase) just as given in diagram in O(n*h) and O(n*log(h)) time complexity, where h is the number of Pareto-optimal points? I used gift wrapping algorithm to solve this (in O(n*h) ), but it only finds convex hulls type of staircase and misses those points who form concave angles. 回答1: To put suggestion in one place. Idea is to use divide and conquer strategy. If we can find pareto point P which splits rest of pareto

Alpha shapes in 3D

一个人想着一个人 提交于 2021-01-20 19:55:35
问题 Is there an "alpha shape" function in 3 dimensions in python, other than the CGAL python bindings? Alternatively, is there a way to extend the example below into 3D? 2D example: draw a smooth polygon around data points in a scatter plot, in matplotlib I'm currently calculating volume using this ConvexHull example, but for my purposes the volumes are inflated due to the "convex" constraint. Thanks, 回答1: I wrote some code for finding alpha shape surface. I hope this helps. from scipy.spatial

Alpha shapes in 3D

北城余情 提交于 2021-01-20 19:52:44
问题 Is there an "alpha shape" function in 3 dimensions in python, other than the CGAL python bindings? Alternatively, is there a way to extend the example below into 3D? 2D example: draw a smooth polygon around data points in a scatter plot, in matplotlib I'm currently calculating volume using this ConvexHull example, but for my purposes the volumes are inflated due to the "convex" constraint. Thanks, 回答1: I wrote some code for finding alpha shape surface. I hope this helps. from scipy.spatial

Calculating and displaying a pentagon

安稳与你 提交于 2020-06-29 03:42:29
问题 I'm trying to calculate and show a convex hull for some random points in python. This is my current code: import numpy as np import random import matplotlib.pyplot as plt import cv2 points = np.random.rand(25,2) hull = ConvexHull(points) plt.plot(points[:,0], points[:,1], 'o',color='c') for simplex in hull.simplices: plt.plot(points[simplex, 0], points[simplex, 1], 'r') plt.plot(points[hull.vertices,0], points[hull.vertices,1], 'r', lw=-1) plt.plot(points[hull.vertices[0],0], points[hull

calculate overlapping areas

一世执手 提交于 2020-06-28 08:08:32
问题 I am following the example here and successfully created convex hulls. But I have a question on how to calculate the shared areas between each convex hull in the following figure: Thanks! 回答1: Here's an example to get the intersection of Manhattan and the Bronx. You could use pd.concat() before .overlay() if you want to combine boroughs. import geopandas as gpd nybb_path = gpd.datasets.get_path('nybb') boros = gpd.read_file(nybb_path) boros.set_index('BoroCode', inplace=True) boros.sort_index