def reduce_poly(points, tolerance=0.5):
    
    assert len(points) > 0, "reduce_poly can not simplify an empty points list"
    
    curr_p = points[0]
    reduced_ps = [points[0]]
    
    for p in points[1:]:
        distance = (curr_p[X] - p[X])**2 + (curr_p[Y] - p[Y])**2
        if distance > tolerance:
            curr_p = p
            reduced_ps.append(p)
            
    return reduced_ps
Remove close points to simplify a polyline
dataset/ETHPy150Open estevaofon/angry-birds-python/pymunk-4.0.0/pymunk/util.py/reduce_poly