def convex_hull_area(pts):
"""
Calculates the surface area from a given point cloud using simplices of
its convex hull. For the estimation of the synapse contact area, divide by
a factor of two, in order to get the area of only one face (we assume that
the contact site is sufficiently thin represented by the points).
:param pts: np.array of coordinates in nm (scaled)
:return: Area of the point cloud (nm^2)
"""
if len(pts) < 4:
return 0
area = 0
try:
ch = ConvexHull(pts)
triangles = ch.points[ch.simplices]
for triangle in triangles:
area += poly_area(triangle)
except QhullError as e:
# warnings.warn("%s encountered during calculation of convex hull "
# "area with %d points. Returning 0 nm^2." %
# (e, len(pts)), RuntimeWarning)
pass
return area
评论列表
文章目录