def smooth_normals(positions, normals):
    lookup = defaultdict(list)
    for position, normal in zip(positions, normals):
        lookup[position].append(normal)
    result = []
    for position in positions:
        tx = ty = tz = 0
        for x, y, z in lookup[position]:
            tx += x
            ty += y
            tz += z
        d = (tx * tx + ty * ty + tz * tz) ** 0.5
        result.append((tx / d, ty / d, tz / d))
    return result
Assigns an averaged normal to each position based on all of the normals
dataset/ETHPy150Open fogleman/pg/pg/util.py/smooth_normals