Esempio n. 1
0
def test_plane_init():
    """Test the initalization of Plane objects and basic properties."""
    pt = Point3D(2, 0, 2)
    vec = Vector3D(0, 2, 0)
    plane = Plane(vec, pt)
    str(plane)  # test the string representation

    assert plane.o == Point3D(2, 0, 2)
    assert plane.n == Vector3D(0, 1, 0)
    assert plane.x == Vector3D(1, 0, 0)
    assert plane.y == Vector3D(0, 0, -1)
    assert plane.k == 0

    plane_dup = plane.duplicate()
    assert plane_dup.o == Point3D(2, 0, 2)
    assert plane_dup.n == Vector3D(0, 1, 0)
    assert plane_dup.x == Vector3D(1, 0, 0)
    assert plane_dup.y == Vector3D(0, 0, -1)
    assert plane_dup.k == 0

    plane_flip = plane.flip()
    assert plane_flip.o == Point3D(2, 0, 2)
    assert plane_flip.n == Vector3D(0, -1, 0)
    assert plane_flip.x == Vector3D(-1, 0, 0)
    assert plane_flip.y == Vector3D(0, 0, -1)
    assert plane_flip.k == 0
def test_plane_init():
    """Test the initialization of Plane objects and basic properties."""
    pt = Point3D(2, 0, 2)
    vec = Vector3D(0, 2, 0)
    plane = Plane(vec, pt)
    str(plane)  # test the string representation
    hash(plane)

    assert plane.o == Point3D(2, 0, 2)
    assert plane.n == Vector3D(0, 1, 0)
    assert plane.x == Vector3D(1, 0, 0)
    assert plane.y == Vector3D(0, 0, -1)
    assert plane.k == 0
    assert round(plane.altitude, 3) == 0
    assert round(plane.azimuth, 3) == 0

    plane_dup = plane.duplicate()
    assert plane_dup.o == Point3D(2, 0, 2)
    assert plane_dup.n == Vector3D(0, 1, 0)
    assert plane_dup.x == Vector3D(1, 0, 0)
    assert plane_dup.y == Vector3D(0, 0, -1)
    assert plane_dup.k == 0
    assert round(plane.altitude, 3) == 0
    assert round(plane.azimuth, 3) == 0

    plane_flip = plane.flip()
    assert plane_flip.o == Point3D(2, 0, 2)
    assert plane_flip.n == Vector3D(0, -1, 0)
    assert plane_flip.x == Vector3D(1, 0, 0)
    assert plane_flip.y == Vector3D(0, 0, 1)
    assert plane_flip.k == 0
    assert round(plane_flip.altitude, 3) == 0
    assert round(plane_flip.azimuth, 3) == round(math.pi, 3)
def test_equality():
    """Test the equality of Plane objects."""
    pt = Point3D(2, 0, 2)
    vec = Vector3D(0, 2, 0)
    plane = Plane(vec, pt)
    plane_dup = plane.duplicate()
    plane_alt = Plane(vec, Point3D(2, 0.1, 2))

    assert plane is plane
    assert plane is not plane_dup
    assert plane == plane_dup
    assert hash(plane) == hash(plane_dup)
    assert plane != plane_alt
    assert hash(plane) != hash(plane_alt)