You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for making this repository, I have a little request to support on 3d points
I take a look on the repository, and seems like I only need to change the triangle area calculation.
Is it correct to do it like this?
def triangle_area(p1, p2, p3):
"""
calculates the area of a triangle given its vertices
"""
return np.linalg.norm(np.cross(p2 - p1, p3 - p1)) / 2
def triangle_areas_from_array(arr):
"""
take an (N,2) or (N,3) array of points and return an (N,1)
array of the areas of those triangles, where the first
and last areas are np.inf
see triangle_area for algorithm
"""
result = np.empty((len(arr),), arr.dtype)
result[0] = np.inf
result[-1] = np.inf
p1 = arr[:-2]
p2 = arr[1:-1]
p3 = arr[2:]
area = np.cross(p2 - p1, p3 - p1, axis=1)
if len(area.shape) > 1:
area = np.linalg.norm(area, axis=1) / 2
else:
area = np.abs(area) / 2
result[1:-1] = area
return result
The text was updated successfully, but these errors were encountered:
This looks pretty good. I just added these commits to a new branch and it doesn't seem to break anything. Before merging, I would like to add some tests that use 3d points
Thank you for making this repository, I have a little request to support on 3d points
I take a look on the repository, and seems like I only need to change the triangle area calculation.
Is it correct to do it like this?
The text was updated successfully, but these errors were encountered: