def test_express_point_in_frame(example_frames): fa, fb, fc = example_frames p0 = (5, 3, 20) p1 = (7.07107, 1.41421, -24.00000) res0 = Point(p0).express_in_frame(fa) assert res0 == Point(p0).express_in_frame(fa, original_frame=UnitFrame) assert isinstance(res0._a, np.ndarray) res1 = Point(p0).express_in_frame(fa, original_frame=fb) assert res1.as_array() == pytest.approx(p1, abs=1e-4) assert isinstance(res1._a, np.ndarray) assert express_point_in_frame( p0, fa, original_frame=fb).as_array() == pytest.approx(p1, abs=1e-4) assert Point(p0).express_in_frame( fa, original_frame=fb) == Point(p0).express_in_frame( fa.express_in_frame(fb))
def test_point_express_in_frame(example_frames): fa, fb, fc = example_frames p = Point([1, 1, 3]) pt = p.express_in_frame(fc) assert pt == Point([0, 0, 1])
def test_point_transform(example_frames): fa, fb, fc = example_frames p = Point([1, 1, 3]) pt = p.transform(fc) assert pt == Point([1 + math.sqrt(2), 1, 1])
def test_point_from_array(): p = Point([1, 2, 3]) assert p[2] == 3
def test_point_from_np(): p = Point(np.array([1, 2, 3])) assert p[2] == 3
def test_point_from_np_bare_copy(): a = np.array([1, 2, 3]) p = Point.from_array(a, copy=True) a[2] = 7 assert p[2] == 3
def test_point_from_vector(): p = Point(Vector([1, 2, 3])) assert p[2] == 3
def test_point_from_tuple(): p = Point((1, 2, 3)) assert p[2] == 3
def test_vector_from_point(): p = Vector(Point([1, 2, 3])) assert p[2] == 3
def test_point_from_point(): p = Point(Point([1, 2, 3])) assert p[2] == 3
def test_distances_plane_to_points(): plane = Plane(normal=Vector([0, 0, -1]), point=Point([1, 2, 0])) points = [[1, 2, 3], [1, 2, 6]] d = distances_plane_to_points(plane, points) assert d == pytest.approx([-3, -6])
def test_distance_between_points(): pointA = Point([1, 2, 3]) pointB = Point([1, 2, 6]) assert distance_between_points(pointA, pointB) == 3
def test_plane_from_normal_point(): normal = Vector([0, 0, -1]) point = Point([1, 2, 0]) plane = Plane(normal=normal, point=point) assert plane.normal == normal assert plane.point == point
def test_plane_as_abcd(): normal = Vector([0, 0, -1]) point = Point([1, 2, 0]) plane = Plane(normal=normal, point=point) assert plane.as_abcd() == pytest.approx((0, 0, -1, 0))
def test_fit_plane(): points = [[1, 0, 0], [0, 1, 0], [-1, 0, 0]] plane = fit_plane(points) assert plane == Plane(normal=Vector([0, 0, 1]), point=Point([0, 1 / 3, 0]))