# Collidiers intersection

Is there a way to get point where colliders intersect. For example it would be two points for two circle colliders. To write it better, points where lines of colliders boundary intersect.
I need that for my project and can’t find a way to do this

I am assuming you have two 3D mesh colliders (or just meshes) colliding.

I doubt you will find an efficient solution to this. Even approximating it might be hard. I’ll suggest two simple methods:

Method 1: (exact, inefficient, simple)

Loop through pairs of triangles. One triangle on one mesh, the other triangle on the other. (You could improve this by finding bounding boxes of each triangle and only going further when they overlap. This will improve performance)

Using the normals to the triangles and the coordinates of one vertex on each, you can treat them as a planes. Then you need to find the intersection of the two planes. (This is simple mathematically with 3 cases:

1. The planes lie exactly on each other - Then every point on the two planes are points of intersection. But you only want the points of intersection which lie in both triangles. In this case you can reduce it to finding points of intersection of two triangles in 2D.

2. The planes are parrallel - No points of intersection if we are not in case 1 - You can easily check this case by checking if the normals are the same (or only differ by sign) and the reference point on one plane does not lie on the other.

3. The planes have a line of intersection - Its easy to find the line of intersection (do a google search). You’ll want to parameterise the line of intersection and then find in which intervals the parametrisation is on each triangle (if at all). If these intervals overlap that is where you’ll find your points of intersection.

It looks like there is a lot to implement here but if you know your maths its really not that hard. Bear in mind this method will be very inefficient for large meshes.

Method 2: (approximation, probably faster, might not always work)

Firstly you need some kind of initial guess for a point of intersection. Maybe halfway between the centers of the two meshes.

Use something like Collider.ClosestPoint or Physics.ClosestPoint to find the closest point to your initial guess on mesh 1. From this point find the nearest point on mesh 2. From this point find the nearest point on mesh 1 … Keep repeating and pray your points converge to a point of intersection.

You’ll need to do this multiple times with different initial guesses if you want to find more than one point of intersection.

Neither of these Methods are particularily good. If you find a better solution it would be great if you could share it!