Skip to content

Commit

Permalink
Merge pull request #712 from panangam/centroid_for_path3d
Browse files Browse the repository at this point in the history
add centroid property to Path3D class
  • Loading branch information
mikedh committed Feb 8, 2020
2 parents 67ebc30 + ff0f789 commit 2cabc6f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions trimesh/path/path.py
Expand Up @@ -1017,6 +1017,19 @@ def plot_entities(self, show=False):
if show:
plt.show()

@caching.cache_decorator
def centroid(self):
"""
Return the centroid of the path object.
Returns
-----------
centroid : (d,) float
Approximate centroid of the path
"""
centroid = self.vertices.mean(axis=0)
return centroid


class Path2D(Path):

Expand Down

0 comments on commit 2cabc6f

Please sign in to comment.