ladybug_rhino.intersect module

Functions to handle intersection of Rhino geometries.

These represent geometry computation methods that are either not supported by ladybug_geometry or there are much more efficient versions of them in Rhino.

ladybug_rhino.intersect.bounding_box(geometry, high_accuracy=False)[source]

Get a Rhino bounding box around an input Rhino Mesh or Brep.

This is a typical pre-step before using intersection functions.

Parameters
  • geometry – A Rhino Brep or Mesh.

  • high_accuracy – If True, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. For some geometry types, there is no difference between the estimate and the accurate bounding box. Estimated bounding boxes can be computed much (much) faster than accurate (or “tight”) bounding boxes. Estimated bounding boxes are always similar to or larger than accurate bounding boxes.

ladybug_rhino.intersect.bounding_box_extents(geometry, high_accuracy=False)[source]

Get min and max points around an input Rhino Mesh or Brep

Parameters
  • geometry – A Rhino Brep or Mesh.

  • high_accuracy – If True, a physically accurate bounding box will be computed. If not, a bounding box estimate will be computed. For some geometry types, there is no difference between the estimate and the accurate bounding box. Estimated bounding boxes can be computed much (much) faster than accurate (or “tight”) bounding boxes. Estimated bounding boxes are always similar to or larger than accurate bounding boxes.

ladybug_rhino.intersect.generate_intersection_rays(points, vectors)[source]

Generate a series of rays to be used for intersection calculations.

All combinations of rays between the input points and vectors will be generated.

Parameters
  • points – A list of Rhino point objects for the starting point of each ray.

  • vectors – A list of Rhino vector objects for the direction of each ray, which will be projected from each point.

ladybug_rhino.intersect.geo_min_max_height(geometry)[source]

Get the min and max Z values of any input object.

This is useful as a pre-step before the split_solid_to_floors method.

ladybug_rhino.intersect.intersect_mesh_lines(mesh, start_points, end_points, max_dist=None, cpu_count=None, parallel=True)[source]

Intersect a group of lines (represented by start + end points) with a mesh.

All combinations of lines that are possible between the input start_points and end_points will be intersected. This method exists since most CAD plugins have much more efficient mesh/line intersection functions than ladybug_geometry. However, the ladybug_geometry Face3D.intersect_line_ray() method provides a workable (albeit very inefficient) alternative to this if it is needed.

Parameters
  • mesh – A Rhino mesh that can block the lines.

  • start_points – An array of Rhino points that will be used to generate lines.

  • end_points – An array of Rhino points that will be used to generate lines.

  • max_dist – An optional number to set the maximum distance beyond which the end_points are no longer considered visible by the start_points. If None, points with an unobstructed view to one another will be considered visible no matter how far they are from one another.

  • cpu_count – An integer for the number of CPUs to be used in the intersection calculation. The ladybug_rhino.grasshopper.recommended_processor_count function can be used to get a recommendation. If set to None, all available processors will be used. (Default: None).

  • parallel – Optional boolean to override the cpu_count and use a single CPU instead of multiple processors.

Returns

A 2D matrix of 0’s and 1’s indicating the results of the intersection. Each sub-list of the matrix represents one of the points and has a length equal to the end_points. 0 indicates a blocked ray and 1 indicates a ray that was not blocked.

ladybug_rhino.intersect.intersect_mesh_rays(mesh, points, vectors, normals=None, cpu_count=None, parallel=True)[source]

Intersect a group of rays (represented by points and vectors) with a mesh.

All combinations of rays that are possible between the input points and vectors will be intersected. This method exists since most CAD plugins have much more efficient mesh/ray intersection functions than ladybug_geometry. However, the ladybug_geometry Face3D.intersect_line_ray() method provides a workable (albeit very inefficient) alternative to this if it is needed.

Parameters
  • mesh – A Rhino mesh that can block the rays.

  • points – An array of Rhino points that will be used to generate rays.

  • vectors – An array of Rhino vectors that will be used to generate rays.

  • normals – An optional array of Rhino vectors that align with the input points and denote the direction each point is facing. These will be used to eliminate any cases where the vector and the normal differ by more than 90 degrees. If None, points are assumed to have no direction.

  • cpu_count – An integer for the number of CPUs to be used in the intersection calculation. The ladybug_rhino.grasshopper.recommended_processor_count function can be used to get a recommendation. If set to None, all available processors will be used. (Default: None).

  • parallel – Optional boolean to override the cpu_count and use a single CPU instead of multiple processors.

Returns

A tuple with two elements

  • intersection_matrix – A 2D matrix of 0’s and 1’s indicating the results of the intersection. Each sub-list of the matrix represents one of the points and has a length equal to the vectors. 0 indicates a blocked ray and 1 indicates a ray that was not blocked.

  • angle_matrix – A 2D matrix of angles in radians. Each sub-list of the matrix represents one of the normals and has a length equal to the supplied vectors. Will be None if no normals are provided.

ladybug_rhino.intersect.intersect_mesh_rays_distance(mesh, point, vectors, max_dist=None)[source]

Intersect a group of rays with a mesh to get the distance until intersection.

Parameters
  • mesh – A Rhino mesh that can block the rays.

  • points – A Rhino point that will be used to generate rays.

  • vectors – An array of Rhino vectors that will be used to generate rays.

  • max_dist – An optional number to set the maximum distance beyond which context blocking the view is no longer considered relevant. If None, geometries at all distances will be evaluated for whether they block the view and the results may contain negative numbers indicating that the view from that ray is never blocked

Returns

A list of values for the distance at which intersection occurs.

ladybug_rhino.intersect.intersect_rays_with_mesh_faces(mesh, rays, context=None, normals=None, cpu_count=None)[source]

Intersect a matrix of rays with a mesh to get the intersected mesh faces.

This method is useful when trying to color each face of the mesh with values that can be linked to each one of the rays. For example, this method is used in all shade benefit calculations.

Parameters
  • mesh – A Rhino mesh that will be intersected with the rays.

  • rays – A matrix (list of lists) where each sublist contains Rhino Rays to be intersected with the mesh.

  • context – An optional Rhino mesh that will be used to evaluate if the rays are blocked before performing the calculation with the input mesh. Rays that intersect this context will be discounted from the calculation.

  • normals – An optional array of Rhino vectors that align with the input rays and denote the direction each ray group is facing. These will be used to eliminate any cases where the vector and the normal differ by more than 90 degrees. If None, points are assumed to have no direction.

  • cpu_count – An integer for the number of CPUs to be used in the intersection calculation. The ladybug_rhino.grasshopper.recommended_processor_count function can be used to get a recommendation. If set to None, all available processors will be used. (Default: None).

Returns

A 2D matrix of integers indicating the results of the intersection. Each sub-list of the matrix represents one of the mesh faces and the integers within it refer to the indices of the rays in the rays list that intersected that face.

ladybug_rhino.intersect.intersect_solid(solid, other_solid)[source]

Intersect the co-planar faces of one solid Brep using another.

Parameters
  • solid – The solid Brep which will be split with intersections.

  • other_solid – The other Brep, which will be used to split.

Returns

A tuple with two elements

  • solid – The input solid, which has been split.

  • intersection_exists – Boolean to note whether an intersection was found between the solid and the other_solid. If False, there’s no need to split the other_solid with the input solid.

ladybug_rhino.intersect.intersect_solids(solids, bound_boxes)[source]

Intersect the co-planar faces of an array of solids.

Parameters
  • original_solids – An array of closed Rhino breps (polysurfaces) that do not have perfectly matching surfaces between adjacent Faces.

  • bound_boxes – An array of Rhino bounding boxes that parallels the input solids and will be used to check whether two Breps have any potential for intersection before the actual intersection is performed.

Returns

int_solids – The input array of solids, which have all been intersected with one another.

ladybug_rhino.intersect.intersect_solids_parallel(solids, bound_boxes, cpu_count=None)[source]

Intersect the co-planar faces of an array of solids using parallel processing.

Parameters
  • original_solids – An array of closed Rhino breps (polysurfaces) that do not have perfectly matching surfaces between adjacent Faces.

  • bound_boxes – An array of Rhino bounding boxes that parallels the input solids and will be used to check whether two Breps have any potential for intersection before the actual intersection is performed.

  • cpu_count – An integer for the number of CPUs to be used in the intersection calculation. The ladybug_rhino.grasshopper.recommended_processor_count function can be used to get a recommendation. If None, all available processors will be used. (Default: None).

  • parallel – Optional boolean to override the cpu_count and use a single CPU instead of multiple processors.

Returns

int_solids – The input array of solids, which have all been intersected with one another.

ladybug_rhino.intersect.intersect_view_factor(meshes, points, vectors, vector_weights, context=None, normals=None, cpu_count=None)[source]

Intersect a list of points with meshes to determine the view factor to each mesh.

Parameters
  • meshes – A list of Rhino meshes that will be intersected to determine the view factor from each point.

  • points – An array of Rhino points that will be used to generate rays.

  • vectors – An array of Rhino vectors that will be used to generate rays.

  • vector_weights – A list of numbers with the same length as the vectors corresponding to the solid angle weight of each vector. The sum of this list should be equal to one. These are needed to ensure that the resulting view factors are accurate.

  • context – An optional Rhino mesh that will be used to evaluate if the rays are blocked before performing the calculation with the input meshes. Rays that intersect this context will be discounted from the result.

  • normals – An optional array of Rhino vectors that align with the input points and denote the direction each point is facing. These will be used to eliminate any cases where the vector and the normal differ by more than 90 degrees and will also be used to compute view factors within the plane defined by this normal vector. If None, points are assumed to have no direction and view factors will be computed spherically around the points.

  • cpu_count – An integer for the number of CPUs to be used in the intersection calculation. The ladybug_rhino.grasshopper.recommended_processor_count function can be used to get a recommendation. If set to None, all available processors will be used. (Default: None).

Returns

A tuple with two values.

  • view_factors – A 2D matrix of fractional values indicating the view factor from each point to each mesh. Each sub-list of the matrix denotes one of the input points.

  • mesh_indices – A 2D matrix of integers indicating the index of each mesh struck by each view ray. Each sub-list of the matrix represents one of the points and the value in each sub-list is the integer of the mesh that was struck by a given ray shot from the point.

ladybug_rhino.intersect.join_geometry_to_brep(geometry)[source]

Convert an array of Rhino Breps and/or Meshes into a single Rhino Brep.

This is a typical pre-step before using the ray tracing functions.

Parameters

geometry – An array of Rhino Breps or Rhino Meshes.

ladybug_rhino.intersect.join_geometry_to_gridded_mesh(geometry, grid_size, offset_distance=0)[source]

Create a single gridded Ladybug Mesh3D from an array of Rhino geometry.

Parameters
  • breps – An array of Rhino Breps and/or Rhino meshes that will be converted into a single, joined gridded Ladybug Mesh3D.

  • grid_size – A number for the grid size dimension with which to make the mesh.

  • offset_distance – A number for the distance at which to offset the points from the underlying geometry. The default is 0.

Returns

A tuple with three elements

  • joined_mesh – A Rhino Mesh from the input geometry.

  • points – A list of Rhino Point3ds for the mesh face centers.

  • normals – A list of Rhino Point3ds for the mesh face normals.

ladybug_rhino.intersect.join_geometry_to_mesh(geometry)[source]

Convert an array of Rhino Breps and/or Meshes into a single Rhino Mesh.

This is a typical pre-step before using the intersect_mesh_rays functions.

Parameters

geometry – An array of Rhino Breps or Rhino Meshes.

ladybug_rhino.intersect.normal_at_point(brep, point)[source]

Get a Rhino vector for the normal at a specific point that lies on a brep.

Parameters
  • breps – A Rhino brep on which the normal direction will be evaluated.

  • point – A Rhino point on the input brep where the normal will be evaluated.

ladybug_rhino.intersect.overlapping_bounding_boxes(bound_box1, bound_box2)[source]

Check if two Rhino bounding boxes overlap within the tolerance.

This is particularly useful as a check before performing computationally intense intersection processes between two bounding boxes. Checking the overlap of the bounding boxes is extremely quick given this method’s use of the Separating Axis Theorem. This method is built into the intersect_solids functions in order to improve its calculation time.

Parameters
  • bound_box1 – The first bound_box to check.

  • bound_box2 – The second bound_box to check.

ladybug_rhino.intersect.split_solid_to_floors(building_solid, floor_heights)[source]

Extract a series of planar floor surfaces from solid building massing.

Parameters
  • building_solid – A closed brep representing a building massing.

  • floor_heights – An array of float values for the floor heights, which will be used to generate planes that subdivide the building solid.

Returns

floor_breps – A list of planar, horizontal breps representing the floors of the building.

ladybug_rhino.intersect.trace_ray(ray, breps, bounce_count=1)[source]

Get a list of Rhino points for the path a ray takes bouncing through breps.

Parameters
  • ray – A Rhino Ray whose path will be traced through the geometry.

  • breps – An array of Rhino breps through with the ray will be traced.

  • bounce_count – An positive integer for the number of ray bounces to trace the sun rays forward. (Default: 1).