def collect_shading_walls(idf): '''return the Shading:Building:Detailed objects that are walls (vertical) and have 4 vertices and rectangular''' result = [] for shading in idf.idfobjects['SHADING:BUILDING:DETAILED']: if get_number_of_vertices(shading) != 4: # ignore this one continue polygon = get_polygon(shading) try: if not np.isclose(90.0, tilt(polygon)): # ignore this one too continue except: print 'bad polygon:', shading.Name, polygon continue vectors = [line[0] - line[1] for line in zip(polygon, rotate(polygon))] if not all([ np.isclose(90.0, angle2vecs(v[0], v[1])) for v in zip(vectors, rotate(vectors)) ]): # not rectangular continue # meets criteria result.append(shading) return result
def collect_walls(citysim_xml): '''return the Wall nodes objects that are walls (vertical) and have 4 vertices and rectangular''' result = [] for wall in citysim_xml.findall('/District/Building/Zone/Wall'): if get_number_of_vertices(wall) != 4: # ignore this one continue polygon = get_polygon(wall) try: if not np.isclose(90.0, tilt(polygon)): # ignore this one too continue except: print 'bad polygon:', 'Wall@id=%s' % wall.get('id'), polygon continue vectors = [line[0] - line[1] for line in zip(polygon, rotate(polygon))] if not all([np.isclose(90.0, angle2vecs(v[0], v[1])) for v in zip(vectors, rotate(vectors))]): # not rectangular continue # meets criteria result.append(wall) return result
def test_tilt(): """test the tilt of a polygon poly""" data = (([(0,0,0), (1,0,0), (1,1,0), (0,1,0)],0),# polygon, answer, ([(0,0,0), (5,0,0), (5,0,8), (0,0,8)],90), ([(0,0,0), (1,0,0), (1,1,1), (0,1,1)],45), ([(3.571913,-9.390334,1.487381), (10.905826,-6.194443,1.487381), (8.998819,-1.818255,0.0), (1.664906, -5.014146, 0.0)],90-72.693912), ) for poly,answer in data: result = surface.tilt(poly) assert almostequal(answer, result, places=3) == True
def test_tilt(): """test the tilt of a polygon poly""" data = ( ([(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0)], 0), # polygon, answer, ([(0, 0, 0), (5, 0, 0), (5, 0, 8), (0, 0, 8)], 90), ([(0, 0, 0), (1, 0, 0), (1, 1, 1), (0, 1, 1)], 45), ([(3.571913, -9.390334, 1.487381), (10.905826, -6.194443, 1.487381), (8.998819, -1.818255, 0.0), (1.664906, -5.014146, 0.0)], 90 - 72.693912), ) for poly, answer in data: result = surface.tilt(poly) assert almostequal(answer, result, places=3) == True
def tilt(ddtt): """tilt of the surface""" coords = getcoords(ddtt) return g_surface.tilt(coords)