Exemplo n.º 1
0
def test_rotate_xy():
    """Test the Door rotate_xy method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2,
                                                       2), Point3D(1, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    door = Door('Rectangle Door', Face3D(pts, plane))
    origin_1 = Point3D(1, 1, 0)

    test_1 = door.duplicate()
    test_1.rotate_xy(180, origin_1)
    assert test_1.geometry[0].x == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].y == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].x == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[2].y == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)

    test_2 = door.duplicate()
    test_2.rotate_xy(90, origin_1)
    assert test_2.geometry[0].x == pytest.approx(1, rel=1e-3)
    assert test_2.geometry[0].y == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(2, rel=1e-3)
    assert test_2.geometry[2].x == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[2].y == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(2, rel=1e-3)
Exemplo n.º 2
0
def test_rotate():
    """Test the Door rotate method."""
    pts = (Point3D(0, 0, 2), Point3D(2, 0, 2), Point3D(2, 2,
                                                       2), Point3D(0, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    door = Door('Rectangle Door', Face3D(pts, plane))
    origin = Point3D(0, 0, 0)
    axis = Vector3D(1, 0, 0)

    test_1 = door.duplicate()
    test_1.rotate(axis, 180, origin)
    assert test_1.geometry[0].x == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[0].y == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[0].z == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[2].x == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[2].y == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[2].z == pytest.approx(-2, rel=1e-3)
    assert door.area == test_1.area
    assert len(door.vertices) == len(test_1.vertices)

    test_2 = door.duplicate()
    test_2.rotate(axis, 90, origin)
    assert test_2.geometry[0].x == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[0].y == pytest.approx(-2, rel=1e-3)
    assert test_2.geometry[0].z == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[2].x == pytest.approx(2, rel=1e-3)
    assert test_2.geometry[2].y == pytest.approx(-2, rel=1e-3)
    assert test_2.geometry[2].z == pytest.approx(2, rel=1e-3)
    assert door.area == test_2.area
    assert len(door.vertices) == len(test_2.vertices)
Exemplo n.º 3
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Door."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    concrete5 = EnergyMaterial('5cm Concrete', 0.05, 2.31, 2322, 832,
                               'MediumRough', 0.95, 0.75, 0.8)
    mass_constr = OpaqueConstruction('Concrete Door', [concrete5])

    door_original = Door('wall door', Face3D(verts))
    door_dup_1 = door_original.duplicate()

    assert door_original.properties.energy.host is door_original
    assert door_dup_1.properties.energy.host is door_dup_1
    assert door_original.properties.energy.host is not \
        door_dup_1.properties.energy.host

    assert door_original.properties.energy.construction == \
        door_dup_1.properties.energy.construction
    door_dup_1.properties.energy.construction = mass_constr
    assert door_original.properties.energy.construction != \
        door_dup_1.properties.energy.construction

    door_dup_2 = door_dup_1.duplicate()

    assert door_dup_1.properties.energy.construction == \
        door_dup_2.properties.energy.construction
    door_dup_2.properties.energy.construction = None
    assert door_dup_1.properties.energy.construction != \
        door_dup_2.properties.energy.construction
Exemplo n.º 4
0
def test_reflect():
    """Test the Door reflect method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2,
                                                       2), Point3D(1, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    door = Door('Rectangle Door', Face3D(pts, plane))

    origin_1 = Point3D(1, 0, 2)
    origin_2 = Point3D(0, 0, 2)
    normal_1 = Vector3D(1, 0, 0)
    normal_2 = Vector3D(-1, -1, 0).normalize()
    plane_1 = Plane(normal_1, origin_1)
    plane_2 = Plane(normal_2, origin_2)
    plane_3 = Plane(normal_2, origin_1)

    test_1 = door.duplicate()
    test_1.reflect(plane_1)
    assert test_1.geometry[-1].x == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[-1].y == pytest.approx(1, rel=1e-3)
    assert test_1.geometry[-1].z == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[1].x == pytest.approx(0, rel=1e-3)
    assert test_1.geometry[1].y == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[1].z == pytest.approx(2, rel=1e-3)

    test_1 = door.duplicate()
    test_1.reflect(plane_2)
    assert test_1.geometry[-1].x == pytest.approx(-1, rel=1e-3)
    assert test_1.geometry[-1].y == pytest.approx(-1, rel=1e-3)
    assert test_1.geometry[-1].z == pytest.approx(2, rel=1e-3)
    assert test_1.geometry[1].x == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[1].y == pytest.approx(-2, rel=1e-3)
    assert test_1.geometry[1].z == pytest.approx(2, rel=1e-3)

    test_2 = door.duplicate()
    test_2.reflect(plane_3)
    assert test_2.geometry[-1].x == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[-1].y == pytest.approx(0, rel=1e-3)
    assert test_2.geometry[-1].z == pytest.approx(2, rel=1e-3)
    assert test_2.geometry[1].x == pytest.approx(-1, rel=1e-3)
    assert test_2.geometry[1].y == pytest.approx(-1, rel=1e-3)
    assert test_2.geometry[1].z == pytest.approx(2, rel=1e-3)
Exemplo n.º 5
0
def test_door_duplicate():
    """Test the duplication of door objects."""
    pts = (Point3D(0, 0, 0), Point3D(0, 0, 3), Point3D(1, 0, 3), Point3D(1, 0, 0))
    dr_1 = Door('TestDoor', Face3D(pts))
    dr_2 = dr_1.duplicate()

    assert dr_1 is not dr_2
    for i, pt in enumerate(dr_1.vertices):
        assert pt == dr_2.vertices[i]
    assert dr_1.identifier == dr_2.identifier

    dr_2.move(Vector3D(0, 1, 0))
    for i, pt in enumerate(dr_1.vertices):
        assert pt != dr_2.vertices[i]
Exemplo n.º 6
0
def test_scale():
    """Test the Door scale method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2))
    plane = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 2))
    door = Door('RectangleDoor', Face3D(pts, plane))

    new_dr = door.duplicate()
    new_dr.scale(2)
    assert new_dr.geometry[0] == Point3D(2, 2, 4)
    assert new_dr.geometry[1] == Point3D(4, 2, 4)
    assert new_dr.geometry[2] == Point3D(4, 4, 4)
    assert new_dr.geometry[3] == Point3D(2, 4, 4)
    assert new_dr.area == door.area * 2 ** 2
    assert new_dr.perimeter == door.perimeter * 2
    assert new_dr.normal == door.normal
Exemplo n.º 7
0
def test_move():
    """Test the Door move method."""
    pts_1 = (Point3D(0, 0, 0), Point3D(2, 0, 0), Point3D(2, 2, 0), Point3D(0, 2, 0))
    plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0))
    door = Door('RectangleDoor', Face3D(pts_1, plane_1))

    vec_1 = Vector3D(2, 2, 2)
    new_dr = door.duplicate()
    new_dr.move(vec_1)
    assert new_dr.geometry[0] == Point3D(2, 2, 2)
    assert new_dr.geometry[1] == Point3D(4, 2, 2)
    assert new_dr.geometry[2] == Point3D(4, 4, 2)
    assert new_dr.geometry[3] == Point3D(2, 4, 2)
    assert new_dr.normal == door.normal
    assert door.area == new_dr.area
    assert door.perimeter == new_dr.perimeter