# Intersection between shapes

Back to Shape generation

The intersection ''S'' between two shapes ''A'' and ''B'' in ''RR^n'' is ''S = A nn B''.

## Practice

Pastel implements several algorithms for finding the intersection between a pair of shapes. Describing the possible intersection shape is slower than simply finding out if the shapes overlap. If this is the need, you should use the algorithms for overlap testing instead. The implemented algorithms are listed in the following table.

Shape/Shape AlignedBox Box Sphere Plane Segment Triangle Line Ray
AlignedBox nD
Box - -
Sphere - - -
Plane ? + nD +
Segment + + + - -
Triangle ? ? - ? - -1D,+2D,3D,-nD
Line nD nD nD nD - 2D, 3D, -nD -
Ray nD + nD nD - + - -

where

• '-' means the algorithm is not sensible or will not be implemented because the intersection shape can't be described.

• '?' means the algorithm could be useful but probably too rarely.

• '+' means the algorithm would be useful but has not been implemented yet.

• '1D', '2D', '3D', and 'nD' denote dimensions in which the tests operate.

Overlap testing

Shapes

## Files

intersect.h

### Intersection between a 2-flat and a plane

intersect_flat_plane.h

intersect_flat_plane.hpp

### Intersection between a line and a box

intersect_line_box.h

intersect_line_box.hpp

### Intersection between a line and a plane

intersect_line_plane.h

intersect_line_plane.hpp

### Intersection between a line and a sphere

intersect_line_sphere.h

intersect_line_sphere.hpp

### Intersection between a line and a triangle

intersect_line_triangle.h

intersect_line_triangle.hpp

### Intersection between a line and an aligned box

intersect_line_alignedbox.h

intersect_line_alignedbox.hpp

### Intersection between a line and an aligned plane

intersect_line_alignedplane.h

intersect_line_alignedplane.hpp

### Intersection between a line segment and a half-space

intersect_segment_halfspace.h

intersect_segment_halfspace.hpp

### Intersection between a plane and a sphere

intersect_plane_sphere.h

intersect_plane_sphere.hpp

### Intersection between a ray and a plane

intersect_ray_plane.h

intersect_ray_plane.hpp

### Intersection between a ray and a sphere

intersect_ray_sphere.h

intersect_ray_sphere.hpp

### Intersection between a ray and an aligned box

intersect_ray_alignedbox.h

intersect_ray_alignedbox.hpp

### Intersection between a ray and an aligned plane

intersect_ray_alignedplane.h

intersect_ray_alignedplane.hpp

### Intersection between an aligned box and a line segment

intersect_alignedbox_segment.h

intersect_alignedbox_segment.hpp

### Intersection between an aligned box and a plane

intersect_alignedbox_plane.h

intersect_alignedbox_plane.hpp

### Intersection between two aligned boxes

intersect_alignedbox_alignedbox.h

### Intersection between two triangles

intersect_triangle_triangle.h

intersect_triangle_triangle.hpp