Beispiel #1
0
def test_init_form_vector():
    p = Plane.from_vector((5, 0, 0))
    assert p.normal == (1, 0, 0)
    assert p.distance_from_origin == 5

    with pytest.raises(ZeroDivisionError):
        Plane.from_vector((0, 0, 0))
Beispiel #2
0
def test_equal():
    p1 = Plane.from_vector((5, 0, 0))
    p2 = Plane.from_vector((5, 0, 0))
    assert p1 is not p2
    assert p1 == p1
    with pytest.raises(TypeError):
        p1 == Vector(5, 0, 0)
    with pytest.raises(TypeError):
        p1 != Vector(5, 0, 0)
    with pytest.raises(TypeError):
        p1 == 5
    with pytest.raises(TypeError):
        p1 != 5
Beispiel #3
0
def test_is_coplanar_plane():
    p1 = Plane.from_vector((5, 0, 0))
    p2 = Plane.from_vector((-1, 0, 0))
    assert p1.is_coplanar_plane(p2) is True
Beispiel #4
0
def test_is_coplanar():
    p = Plane.from_vector((5, 0, 0))
    assert p.is_coplanar_vertex(Vector(5, 5, 0)) is True
    assert p.is_coplanar_vertex(Vector(5, 0, 5)) is True
Beispiel #5
0
def test_distance_to():
    p = Plane.from_vector((5, 0, 0))
    assert p.distance_to(Vector(10, 0, 0)) == 5
    assert p.distance_to(Vector(0, 0, 0)) == 5
Beispiel #6
0
def test_signed_distance_to():
    p = Plane.from_vector((5, 0, 0))
    assert p.signed_distance_to(Vec3(10, 0, 0)) == 5
    assert p.signed_distance_to(Vec3(0, 0, 0)) == -5
Beispiel #7
0
def test_equal():
    p1 = Plane.from_vector((5, 0, 0))
    p2 = Plane.from_vector((5, 0, 0))
    assert p1 is not p2
    assert p1 == p1