예제 #1
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Room2D."""
    tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6,
                                                   Plane(o=Point3D(5, -10, 6)))
    tree_canopy_geo2 = Face3D.from_regular_polygon(
        6, 2, Plane(o=Point3D(-5, -10, 3)))
    shade_original = ContextShade('TreeCanopy',
                                  [tree_canopy_geo1, tree_canopy_geo2])
    shade_dup_1 = shade_original.duplicate()

    bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True)
    tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5,
                                                     schedule_types.fractional)

    assert shade_original.properties.energy.host is shade_original
    assert shade_dup_1.properties.energy.host is shade_dup_1
    assert shade_original.properties.energy.host is not \
        shade_dup_1.properties.energy.host

    assert shade_original.properties.energy.construction == \
        shade_dup_1.properties.energy.construction
    shade_dup_1.properties.energy.construction = bright_leaves
    assert shade_original.properties.energy.construction != \
        shade_dup_1.properties.energy.construction

    shade_dup_2 = shade_dup_1.duplicate()

    assert shade_dup_1.properties.energy.construction == \
        shade_dup_2.properties.energy.construction
    shade_dup_2.properties.energy.construction = None
    assert shade_dup_1.properties.energy.construction != \
        shade_dup_2.properties.energy.construction
예제 #2
0
def test_scale():
    """Test the ContextShade scale method."""
    pts = (Point3D(1, 1, 2), Point3D(2, 1, 2), Point3D(2, 2, 2), Point3D(1, 2, 2))
    plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0))
    awning_canopy = ContextShade('Awning_Canopy', [Face3D(pts, plane_1)])

    new_a = awning_canopy.duplicate()
    new_a.scale(2)
    assert new_a[0][0] == Point3D(2, 2, 4)
    assert new_a[0][1] == Point3D(4, 2, 4)
    assert new_a[0][2] == Point3D(4, 4, 4)
    assert new_a[0][3] == Point3D(2, 4, 4)
    assert new_a.area == awning_canopy.area * 2 ** 2
예제 #3
0
def test_move():
    """Test the ContextShade move method."""
    pts_1 = (Point3D(0, 2, 3), Point3D(2, 2, 3), Point3D(2, 0, 3), Point3D(0, 0, 3))
    plane_1 = Plane(Vector3D(0, 0, 1), Point3D(0, 0, 0))
    awning_canopy = ContextShade('Awning_Canopy', [Face3D(pts_1, plane_1)])

    vec_1 = Vector3D(2, 2, 2)
    new_a = awning_canopy.duplicate()
    new_a.move(vec_1)
    assert new_a[0][0] == Point3D(2, 2, 5)
    assert new_a[0][1] == Point3D(4, 2, 5)
    assert new_a[0][2] == Point3D(4, 4, 5)
    assert new_a[0][3] == Point3D(2, 4, 5)
    assert awning_canopy.area == new_a.area
예제 #4
0
def test_rotate_xy():
    """Test the ContextShade 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))
    awning_canopy = ContextShade('Awning_Canopy', [Face3D(pts, plane)])
    origin_1 = Point3D(1, 1, 0)

    test_1 = awning_canopy.duplicate()
    test_1.rotate_xy(180, origin_1)
    assert test_1[0][0].x == pytest.approx(1, rel=1e-3)
    assert test_1[0][0].y == pytest.approx(1, rel=1e-3)
    assert test_1[0][0].z == pytest.approx(2, rel=1e-3)
    assert test_1[0][2].x == pytest.approx(0, rel=1e-3)
    assert test_1[0][2].y == pytest.approx(0, rel=1e-3)
    assert test_1[0][2].z == pytest.approx(2, rel=1e-3)
예제 #5
0
def test_reflect():
    """Test the ContextShade 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))
    awning_canopy = ContextShade('Awning_Canopy', [Face3D(pts, plane)])

    origin_1 = Point3D(1, 0, 2)
    normal_1 = Vector3D(1, 0, 0)
    plane_1 = Plane(normal_1, origin_1)

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