ladybug_geometry.intersection2d module¶
Utility functions for computing intersections between geometry in 2D space.
Taken mostly from the euclid package available at https://pypi.org/project/euclid/
- ladybug_geometry.intersection2d.closest_end_point2d_between_line2d(line_a, line_b)[source]¶
Get the two closest end Point2Ds between two LineSegment2D objects.
The result will always be composed of endpoints of the segments and will not account for cases where the closest point lies in the middle of a segment. For cases where such middle points are important, the closest_point2d_between_line2d method should be used.
- Parameters:
line_a – A LineSegment2D object.
line_b – Another LineSegment2D to which closest points will be determined.
- Returns:
A tuple with two elements
dist: The distance between the two endpoints objects.
pts: A tuple of two Point2D objects representing:
The end point on line_a that is closest to line_b
The end point on line_b that is closest to line_a
- ladybug_geometry.intersection2d.closest_point2d_between_line2d(line_ray_a, line_ray_b)[source]¶
Get the two closest Point2D between two LineSegment2D objects.
When the closest point on one of the segments lies in the middle of the segment, this will be accounted for. Also note that the line segments should not intersect for the result to be valid.
- Parameters:
line_ray_a – A LineSegment2D object.
line_ray_b – Another LineSegment2D to which closest points will be determined.
- Returns:
A tuple with two elements
dists[0]: The distance between the two LineSegment2D objects.
pts[0]: A tuple of two Point2D objects representing:
The point on line_ray_a that is closest to line_ray_b
The point on line_ray_b that is closest to line_ray_a
- ladybug_geometry.intersection2d.closest_point2d_on_arc2d(point, arc)[source]¶
Get the closest Point2D on a Arc2D to the input point.
- Parameters:
point – A Point2D object.
arc – An Arc2D object along which the closest point will be determined.
- Returns:
Point2D for the closest point on arc to point.
- ladybug_geometry.intersection2d.closest_point2d_on_line2d(point, line_ray)[source]¶
Get the closest Point2D on a LineSegment2D or Ray2D to the input point.
- Parameters:
point – A Point2D object.
line_ray – A LineSegment2D or Ray2D object along which the closest point will be determined.
- Returns:
Point2D for the closest point on the line_ray to point.
- ladybug_geometry.intersection2d.closest_point2d_on_line2d_infinite(point, line_ray)[source]¶
Get the closest Point2D on a Ray2D/LineSegment2D extended infinitely.
- Parameters:
point – A Point2D object.
line_ray – A LineSegment2D or Ray2D object that will be extended infinitely to determine where the closest point lies.
- Returns:
Point2D for the closest point on the line_ray to point.
- ladybug_geometry.intersection2d.does_intersection_exist_line2d(line_ray_a, line_ray_b)[source]¶
Boolean denoting whether an intersection exists between Ray2D or LineSegment2D.
This is slightly faster than actually computing the intersection but should only be used in cases where the actual point of intersection is not needed.
- Parameters:
line_ray_a – A LineSegment2D or Ray2D object.
line_ray_b – Another LineSegment2D or Ray2D to intersect.
- Returns:
True if an intersection exists. False if no intersection exists.
- ladybug_geometry.intersection2d.intersect_line2d(line_ray_a, line_ray_b)[source]¶
Get the intersection between any Ray2D or LineSegment2D objects as a Point2D.
- This function calculates scaling parameters for ua and ub where:
A.p + ua * A.v = B.p + ub * B.v
Which represents the intersection point between line A and line B.
The derivation of ua is achieved by crossing both sides of the above equation with the direction vector of B, and rearranging the formula:
A.p + ua * A.v = B.p + ub * B.v (A.p + ua * A.v) x B.v = (B.p + ub * B.v) x B.v # Cross both sides with B.v (A.p x B.v) + (ua * A.v x B.v) = (B.p x B.v) + (ub * B.v x B.v) # B.v x B.v = 0 ua = (B.p - A.p) x B.v / (A.v x B.v)
- Parameters:
line_ray_a – A LineSegment2D or Ray2D object.
line_ray_b – Another LineSegment2D or Ray2D to intersect.
- Returns:
Point2D of intersection if it exists. None if no intersection exists.
- ladybug_geometry.intersection2d.intersect_line2d_arc2d(line_ray, arc)[source]¶
Get the intersection between any Ray2D/LineSegment2D and an Arc2D.
- Parameters:
line_ray – A LineSegment2D or Ray2D object.
arc – An Arc2D object along which the closest point will be determined.
- Returns:
A list of 2 Point2D objects if a full intersection exists. A list with a single Point2D object if the line is tangent or intersects only once. None if no intersection exists.
- ladybug_geometry.intersection2d.intersect_line2d_infinite(line_ray_a, line_ray_b)[source]¶
Get intersection between a Ray2D/LineSegment2D and another extended infinitely.
- Parameters:
line_ray_a – A LineSegment2D or Ray2D object.
line_ray_b – A LineSegment2D or Ray2D that will be extended infinitely for intersection.
- Returns:
Point2D of intersection if it exists. None if no intersection exists.
- ladybug_geometry.intersection2d.intersect_line2d_infinite_arc2d(line_ray, arc)[source]¶
Get intersection between an Arc2D and a Ray2D/LineSegment2D extended infinitely.
- Parameters:
line_ray – A LineSegment2D or Ray2D that will be extended infinitely for intersection.
arc – An Arc2D object along which the closest point will be determined.
- Returns:
A list of 2 Point2D objects if a full intersection exists. A list with a single Point2D object if the line is tangent or intersects only once. None if no intersection exists.
- ladybug_geometry.intersection2d.intersect_line_segment2d(line_a, line_b)[source]¶
Get the intersection between two LineSegment2D objects as a Point2D.
This function is identical to intersect_line2d but has some extra checks to avoid certain cases of floating point tolerance issues. It is only intended to work with LineSegment2D and not Ray2D.
- Parameters:
line_a – A LineSegment2D object.
line_b – Another LineSegment2D intersect.
- Returns:
Point2D of intersection if it exists. None if no intersection exists.