def test_3_points_dist_1_not_closed(self): points = [(0, 0), (0, 2), (2, 0)] inter = interpolate_points_by_max_distance(points, 1.0, closed=False) assert np.allclose( inter, np.float32([[0, 0], [0, 1.0], [0, 2], [1.0, 1.0], [2, 0]]))
def test_2_points_dist_1(self): points = [(0, 0), (0, 2)] inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose(inter, np.float32([[0, 0], [0, 1.0], [0, 2], [0, 1.0]]))
def test_interpolate_points_by_max_distance(self): # 2 points points = [(0, 0), (0, 2)] inter = interpolate_points_by_max_distance(points, 10000) assert np.allclose(inter, points) inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose(inter, np.float32([[0, 0], [0, 1.0], [0, 2], [0, 1.0]])) inter = interpolate_points_by_max_distance(points, 1.0, closed=False) assert np.allclose(inter, np.float32([[0, 0], [0, 1.0], [0, 2]])) # 3 points points = [(0, 0), (0, 2), (2, 0)] inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose( inter, np.float32([[0, 0], [0, 1.0], [0, 2], [1.0, 1.0], [2, 0], [1.0, 0]])) inter = interpolate_points_by_max_distance(points, 1.0, closed=False) assert np.allclose( inter, np.float32([[0, 0], [0, 1.0], [0, 2], [1.0, 1.0], [2, 0]])) # 0 points points = [] inter = interpolate_points_by_max_distance(points, 1.0) assert len(inter) == 0 # 1 points points = [(0, 0)] inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose(inter, np.float32([[0, 0]]))
def test_0_points_dist_1(self): points = [] inter = interpolate_points_by_max_distance(points, 1.0) assert len(inter) == 0
def test_2_points_dist_10000(self): points = [(0, 0), (0, 2)] inter = interpolate_points_by_max_distance(points, 10000) assert np.allclose(inter, points)
def test_interpolate_points_by_max_distance(self): # 2 points points = [ (0, 0), (0, 2) ] inter = interpolate_points_by_max_distance(points, 10000) assert np.allclose( inter, points ) inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose( inter, np.float32([ [0, 0], [0, 1.0], [0, 2], [0, 1.0] ]) ) inter = interpolate_points_by_max_distance(points, 1.0, closed=False) assert np.allclose( inter, np.float32([ [0, 0], [0, 1.0], [0, 2] ]) ) # 3 points points = [ (0, 0), (0, 2), (2, 0) ] inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose( inter, np.float32([ [0, 0], [0, 1.0], [0, 2], [1.0, 1.0], [2, 0], [1.0, 0] ]) ) inter = interpolate_points_by_max_distance(points, 1.0, closed=False) assert np.allclose( inter, np.float32([ [0, 0], [0, 1.0], [0, 2], [1.0, 1.0], [2, 0] ]) ) # 0 points points = [] inter = interpolate_points_by_max_distance(points, 1.0) assert len(inter) == 0 # 1 points points = [(0, 0)] inter = interpolate_points_by_max_distance(points, 1.0) assert np.allclose( inter, np.float32([ [0, 0] ]) )