daavoo / pyntcloud

pyntcloud is a Python library for working with 3D point clouds.
http://pyntcloud.readthedocs.io
MIT License
1.39k stars 221 forks source link

Calculate height from base of a 3D point cloud #292

Open cravisjan97 opened 3 years ago

cravisjan97 commented 3 years ago

I am finding it difficult to find an algorithm to calculate the height of a 3D shape given a point cloud. This feature is useful for many shape analysis operations

daavoo commented 3 years ago

I'm not sure if I'm fully understanding the question but I think that you could get the height by computing the (maximum - minimum) of the z coordinate as follows:

from pyntcloud import PyntCloud
anky = PyntCloud.from_file("data/ankylosaurus_mesh.ply")
anky_cloud = anky.get_sample("mesh_random", n=100000, rgb=True, normals=True, as_PyntCloud=True)
height = anky_cloud.points["z"].ptp()