lb_vecs = view_sphere.horizontal_radial_vectors(30 * _resolution_) elif vt_str == 'Horizontal 30-Degree Offset': patch_mesh, lb_vecs = view_sphere.horizontal_radial_patches( 30, _resolution_) patch_wghts = view_sphere.horizontal_radial_patch_weights( 30, _resolution_) elif vt_str == 'Spherical': patch_mesh, lb_vecs = view_sphere.sphere_patches(_resolution_) patch_wghts = view_sphere.sphere_patch_weights(_resolution_) else: patch_mesh, lb_vecs = view_sphere.dome_patches(_resolution_) patch_wghts = view_sphere.dome_patch_weights(_resolution_) view_vecs = [from_vector3d(pt) for pt in lb_vecs] # mesh the geometry and context shade_mesh = join_geometry_to_mesh(_geometry + context_) if _geo_block_ \ else join_geometry_to_mesh(context_) # intersect the rays with the mesh if vt_str == 'Sky View': # account for the normals of the surface normals = [from_vector3d(vec) for vec in study_mesh.face_normals] int_matrix, angles = intersect_mesh_rays(shade_mesh, points, view_vecs, normals, parallel=parallel_) else: int_matrix, angles = intersect_mesh_rays(shade_mesh, points, view_vecs, parallel=parallel_)
_height_ = _height_ if _height_ is not None else 1.8 / conversion_to_meters( ) workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count( ) # create the points representing the human geometry human_points = [] human_line = [] for pos in _position: hpts, hlin = human_height_points(pos, _height_, _pt_count_) human_points.extend(hpts) human_line.append(hlin) if _run: # mesh the context for the intersection calculation shade_mesh = join_geometry_to_mesh(_context) # generate the sun vectors for each sun-up hour of the year sp = Sunpath.from_location(_location, north_) sun_vecs = [] day_pattern = [] for hoy in range(8760): sun = sp.calculate_sun_from_hoy(hoy) day_pattern.append(sun.is_during_day) if sun.is_during_day: sun_vecs.append(from_vector3d(sun.sun_vector_reversed)) # intersect the sun vectors with the context and compute fraction exposed sun_int_matrix, angles = intersect_mesh_rays(shade_mesh, human_points, sun_vecs,
# set the default offset distance and _cpu_count _offset_dist_ = _offset_dist_ if _offset_dist_ is not None \ else 0.1 / conversion_to_meters() workers = _cpu_count_ if _cpu_count_ is not None else recommended_processor_count( ) # create the gridded mesh from the geometry study_mesh = to_joined_gridded_mesh3d(_geometry, _grid_size) points = [ from_point3d(pt.move(vec * _offset_dist_)) for pt, vec in zip(study_mesh.face_centroids, study_mesh.face_normals) ] hide_output(ghenv.Component, 1) # mesh the geometry and context shade_mesh = join_geometry_to_mesh(_geometry + context_) # deconstruct the matrix and get the sky dome vectors mtx = de_objectify_output(_sky_mtx) total_sky_rad = [ dir_rad + dif_rad for dir_rad, dif_rad in zip(mtx[1], mtx[2]) ] ground_rad = [(sum(total_sky_rad) / len(total_sky_rad)) * mtx[0][1] ] * len(total_sky_rad) all_rad = total_sky_rad + ground_rad lb_vecs = view_sphere.tregenza_dome_vectors if len(total_sky_rad) == 145 \ else view_sphere.reinhart_dome_vectors if mtx[0][0] != 0: # there is a north input for sky; rotate vectors north_angle = math.radians(mtx[0][0]) lb_vecs = tuple(vec.rotate_xy(north_angle) for vec in lb_vecs) lb_grnd_vecs = tuple(vec.reverse() for vec in lb_vecs)
over_pattern = view_sphere.overhang_pattern( direction, overhang_proj_, view_vecs) apply_mask_to_base_mask(strategy_pattern, over_pattern, orient_pattern) apply_mask_to_sky(sky_pattern, over_pattern) if left_fin_proj_ or right_fin_proj_: f_pattern = view_sphere.fin_pattern(direction, left_fin_proj_, right_fin_proj_, view_vecs) apply_mask_to_base_mask(strategy_pattern, f_pattern, orient_pattern) apply_mask_to_sky(sky_pattern, f_pattern) # account for any input context context_pattern = None if len(context_) != 0: shade_mesh = join_geometry_to_mesh(context_) # mesh the context points = [from_point3d(center_pt3d)] view_vecs = [from_vector3d(pt) for pt in view_vecs] int_matrix, angles = intersect_mesh_rays(shade_mesh, points, view_vecs) context_pattern = [val == 0 for val in int_matrix[0]] apply_mask_to_sky(sky_pattern, context_pattern) # get the weights for each patch to be used in view factor calculation weights = view_sphere.dome_radial_patch_weights(az_count, alt_count) if direction is not None: weights = [ wgt * abs(math.cos(ang)) * 2 for wgt, ang in zip(weights, dir_angles) ] # create meshes for the masks and compute any necessary view factors gray, black = Color(230, 230, 230), Color(0, 0, 0)