예제 #1
0
def test_axis_transformation():
    assert Ox_axis.translated_x(10) == Ox_axis
    assert Ox_axis.translated_y(10) == Axis(vector=(1, 0, 0), point=(0, 10, 0))

    assert Ox_axis.rotated(Ox_axis, angle=np.pi / 2) == Ox_axis
    assert Ox_axis.rotated(Oy_axis, angle=-np.pi / 2) == Oz_axis

    assert Ox_axis.mirrored(plane=yOz_Plane) == Ox_axis
    assert Ox_axis.mirrored(plane=xOz_Plane.translated_y(2)) == Axis(
        vector=(1, 0, 0), point=(0, 4, 0))

    axis1 = Axis(vector=(1, 1, 1), point=(0, 0, 0))
    axis2 = Axis(vector=(1, 2, 3), point=(0, 0, 0))
    assert axis1.rotated_around_center_to_align_vectors(
        axis1.point, axis1.vector, axis2.vector) == axis2
    axis1.rotate(axis2, np.pi)
    assert axis1.rotated_around_center_to_align_vectors(
        axis1.point, axis1.vector, axis2.vector) == axis2
    axis1.vector *= -1
    assert axis1.rotated_around_center_to_align_vectors(
        axis1.point, axis1.vector, axis2.vector) == axis2

    axis1 = Axis(vector=(1, 1, 1), point=(1, 2, 0))
    axis2 = Axis(vector=(2, 2, 2), point=(0, 0, 0))
    assert axis1.translated_point_to_point(axis1.point, axis2.point) == axis2
def test_mesh_splitting():
    mesh = Sphere().mesh.merged()

    splitted_mesh = mesh.sliced_by_plane(xOz_Plane.translated_y(0.5))
    assert isinstance(splitted_mesh, CollectionOfMeshes)
    assert splitted_mesh.merged() == mesh

    twice_splitted_mesh = splitted_mesh.sliced_by_plane(yOz_Plane)
    assert isinstance(twice_splitted_mesh[0], CollectionOfMeshes)
    assert isinstance(twice_splitted_mesh[1], CollectionOfMeshes)
    assert twice_splitted_mesh.merged() == mesh