Point Cloud Geometry
Point clouds represent scenarios where topology is completely implicit, in a sense that the only relationship among points is their proximity. Data may be associated as additional components p = [x, y, z, w, ..., ω]
or couplings ( p, v ) = ( [x, y, z], [w, ..., ω] )
. The density of a point cloud can be computed as the number of points per cubic unit.
Most point cloud operations require computing the nearest neighbors of each point. For instance, to compute the normal of the implicit surface through a point, a list of nearest neighbors is first collected, up to some distance threshold, and a plane is fitted. Curvature is computed in exactly the same way but a quadratic surface is fitted instead.
Extracting surfaces and solids from point clouds requires an intermediate structure such as a regular voxel grid or an irregular tetrahedralization, from which surface elements are interpolated. Thus, point clouds even though they are simple, they require significantly more computational resources.
Rhino supports point clouds. Points require positional information and optionally they can store normals, colors and arbitrary scalar values.
""" Point Cloud Construction
"""
cloud = PointCloud( )
for index in range( 1000 ):
point = Point3d(
random.uniform( -1, 1 ),
random.uniform( -1, 1 ),
random.uniform( -1, 1 ) )
normal = Vector3d(
random.uniform( -1, 1 ),
random.uniform( -1, 1 ),
random.uniform( -1, 1 ) )
color = Color.FromArgb(
int( random.uniform( 0, 255 ) ),
int( random.uniform( 0, 255 ) ),
int( random.uniform( 0, 255 ) ) )
value = random.uniform( -1, 1 )
if( int( RhinoApp.Version[0] ) >= 8 )
cloud.Add( point, normal, color, value )
else:
cloud.Add( point, normal, color )
Note that Grasshopper does not render point clouds. A workaround is provided below but this is equivalent to baking the geometry in the document! Therefore, it is best to use a boolean input parameter pressed
and connect a push button such that the component does not bake point clouds unless the button is pressed.
""" Baking Point Clouds
"""
from Rhino import RhinoDoc
if( pressed ):
RhinoDoc.ActiveDoc.Objects.AddPointCloud( cloud )