Пример #1
0
def area(poly):
    """Calculation of zone area"""
    poly_xy = []
    num = len(poly)
    for i in range(num):
        poly[i] = poly[i][0:2] + (0,)
        poly_xy.append(poly[i])
    return surface.area(poly)
def merge_windows(wa, wb):
    '''
    update the attributes for the glazing / windows e.g.:
        GlazingRatio="0.43"
        GlazingGValue="0.7"
        GlazingUValue="1.1"
        ShortWaveReflectance="0.2"
        Uvalue="0.5331238918939453"
    using a weighted average for each value.
    FIXME: is this physically correct?!
    '''
    aa = area(get_polygon(wa))
    ab = area(get_polygon(wb))
    attributes = ['GlazingRatio',
                  'GlazingGValue',
                  'GlazingUValue',
                  'ShortWaveReflectance',
                  'Uvalue']
    for attrib in attributes:
        wa.set(attrib, str(weighted_average(
            get_float(wa, attrib),
            get_float(wb, attrib),
            aa, ab)))
Пример #3
0
def test_area():
    """test the area of a polygon poly"""

    data = (
        ([(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0)], 1),  # polygon, answer,
        ([(0, 0, 0), (1, 0, 0), (1, 0, 1), (0, 0, 1)], 1),
        ([(0, 0, 0), (0, 1, 0), (0, 1, 1), (0, 0, 1)], 1),
        ([(0, 0, 0), (0, 1, 0), (0, 2, 0), (0, 3, 0)], 0),
        ([(-4.611479, 6.729214, -0.332978), (-0.694944, 4.990984, 2.243709),
          (-2.147088, 0.302854, 1.288344),
          (-6.063622, 2.041084, -1.288344)], 25),
    )
    for poly, answer in data:
        result = surface.area(poly)
        assert almostequal(answer, result, places=4) == True
Пример #4
0
def test_area():
    """test the area of a polygon poly"""
    
    data = (([(0,0,0), (1,0,0), (1,1,0), (0,1,0)],1),# polygon, answer,
             ([(0,0,0), (1,0,0), (1,0,1), (0,0,1)],1),
             ([(0,0,0), (0,1,0), (0,1,1), (0,0,1)],1),
             ([(0,0,0), (0,1,0), (0,2,0), (0,3,0)],0),
             ([(-4.611479, 6.729214, -0.332978),
             (-0.694944, 4.990984, 2.243709),
             (-2.147088,0.302854,1.288344),
             (-6.063622,2.041084,-1.288344)],25),
            )
    for poly,answer in data:
        result = surface.area(poly)
        assert almostequal(answer, result, places=4) == True
def simplify_one_level(walls):
    '''
    run one pass of simplifications - this needs to be repeated until
    no more simplifications are found
    to_delete is a set of names of shading surfaces that were simplified.
    '''
    to_delete = set()
    print 'simplify_one_level', len(walls)
    for wa, wb in itertools.combinations(walls, 2):
        if not same_zone(wa, wb):
            continue
        if not same_construction(wa, wb):
            continue
        if wa in to_delete or wb in to_delete:
            # one of these has already been merged!
            continue
        pa = get_polygon(wa)
        pb = get_polygon(wb)
        if len(points_in_common(pa, pb)) != 2:
            # ignore these as they can't possibly share an edge
            continue
        pa = canonical_rotation(pa)
        pb = canonical_rotation(pb)
        if np.isclose(pa[0][2], pb[0][2]):
            # not above each other...
            continue
        # swap the two polygons so that pa is the upper and pb the lower
        # polygon - that way we can always index them the same:
        # a1 ----- a2
        # |        |
        # |        |
        # a0 ----- a3 (a0 == b1, a3 == b2)
        # |        |
        # |        |
        # b0 ----- b3
        if pa[0][2] < pb[0][2]:
            wa, wb = wb, wa
            pa, pb = pb, pa
        pnew = [pb[0], pa[1], pa[2], pb[3]]
        set_polygon(wa, pnew)
        wa.set('Area', str(area(pnew)))
        merge_windows(wa, wb)
        to_delete.add(wb)
        print '-', wa.get('id'), wb.get('id')
    return to_delete
Пример #6
0
 def area(self):
     # type: () -> np.float64
     return area(self)
Пример #7
0
def area(ddtt):
    """area of the surface"""
    coords = getcoords(ddtt)
    return g_surface.area(coords)
Пример #8
0
def area(ddtt):
    """area of the surface"""
    coords = getcoords(ddtt)
    return g_surface.area(coords)
Пример #9
0
 def area(self):
     return area(self)