Back to Parent

### Python Code For Recording Deformations in the Point Cloud ###


import rhinoscriptsyntax as rs
import scriptcontext as sc

def accumulate_displacement( accum, punch ):
    """Given two lists of Point3D objects, return a list with the minimal Y displacement."""
    return [ a if a.Y < p.Y else p for a,p in zip(accum, punch) ]
    
if clear or sc.sticky.get('pointShift') is None:
    accum = pointCloud
else:
    accum = sc.sticky['pointShift']
    

def compare_pts(p1,p2):
    """Sort function for x,z points.  Returns -1, 0, or 1."""
    if p1.X < p2.X:
        return -1
    elif p1.X > p2.X:
        return 1
    elif p1.Z < p2.Z:
        return -1
    elif p1.Z > p2.Z:
        return 1
    else:
        return 0
        
pointCloud.sort(compare_pts)
deformed = accumulate_displacement( accum, pointCloud )
sc.sticky['pointShift'] = deformed
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0