def test_distance_away2(): # Towards a smarter Curve::distance_away(), which understands # piecewise linear geometry island = np.array([[200, 200], [600, 200], [200, 600]]) curve = front.Curve(island) anchor_f = 919.3 signed_distance = 50.0 res = curve.distance_away(anchor_f, signed_distance) assert res[0] > anchor_f anchor_pnt = curve(anchor_f) rel_err = np.abs(utils.dist(anchor_pnt - res[1]) - abs(signed_distance)) / abs(signed_distance) assert np.abs(rel_err) <= 0.05 anchor_f = 440 signed_distance = -50.0 res = curve.distance_away(anchor_f, signed_distance) anchor_pnt = curve(anchor_f) rel_err = np.abs(utils.dist(anchor_pnt - res[1]) - abs(signed_distance)) / abs(signed_distance) assert res[0] < anchor_f assert np.abs(rel_err) <= 0.05
def hex_curve(): hexagon = np.array( [[0,11], [10,0], [30,0], [40,9], [30,20], [10,20]] ) return front.Curve(hexagon)
def test_distance3(): # Case where the return point is on the same segment as it starts curve = front.Curve(np.array([[0, 0], [1000, 0], [1000, 1000], [0, 1000]]), closed=True) res = curve.distance_away(3308.90, 50.0) res = curve.distance_away(3308.90, -50.0)