Intersection

Intersections between lines and polyhedra.

pypoman.intersection.intersect_line_cylinder(line: Tuple[ndarray, ndarray], vertices: List[ndarray]) List[ndarray]

Intersect the line segment [p1, p2] with a vertical cylinder.

The vertical cylinder has a polygonal cross-section. If the intersection has two points, this function returns the one closest to p1.

Parameters:
  • line – End points of the 3D line segment.

  • vertices – Vertices of the polygon.

Returns:

List of intersection points between the line segment and the cylinder.

Return type:

inter_points

pypoman.intersection.intersect_line_polygon(line: Tuple[ndarray, ndarray], vertices: List[ndarray], apply_hull: bool) List[ndarray]

Intersect a line segment with a polygon.

Parameters:
  • line – End points of the line segment (2D or 3D).

  • vertices – Vertices of the polygon.

  • apply_hull – Set to True to apply a convex hull algorithm to vertices. Otherwise, the function assumes that vertices are already sorted in clockwise or counterclockwise order.

Returns:

List of intersection points between the line segment and the polygon.

Notes

This code is adapted from <https://stackoverflow.com/questions/20677795/how-do-i-compute-the-intersection-point-of-two-lines-in-python/20679579#20679579>. On the same setting with apply_hull=False, it %timeits to 6 us.

pypoman.intersection.intersect_polygons(polygon1: List[ndarray], polygon2: List[ndarray]) List[ndarray]

Intersect two polygons.

Parameters:
  • polygon1 – Vertices of the first polygon in counterclockwise order.

  • polygon1 – Vertices of the second polygon in counterclockwise order.

Returns:

Vertices of the intersection in counterclockwise order.