When two spheres intersect they should share one or two points. I want to know how to compute those points?

I was thinking of something like this:

  • -check if the spheres intersect
  • -calculate radius_1 distance from center_1 in the direction of center_2
  • -calculate radius_2 distance from center_2 in the direction of center_1
  • -substract the smaller to the larger and have that one as "collision" point

This sounds to me a little too tricky, I wanted to know if there is a simplier way to achieve this?

  • 2
    \$\begingroup\$ Is this 2D or 3D? In 3D, the intersection of two spheres is a circle. \$\endgroup\$ Jan 14, 2014 at 10:07
  • \$\begingroup\$ right! it is in 3d. np, the intersection circle could be approximated to its center \$\endgroup\$
    – Leggy7
    Jan 14, 2014 at 10:11
  • \$\begingroup\$ Here is a similar question with answer: stackoverflow.com/questions/5048701/… \$\endgroup\$
    – Andreas
    Jan 14, 2014 at 10:23

2 Answers 2


Let C₁ and C₂ be the sphere centres, and R₁ and R₂ their radiuses. We pick a point A on the intersection circle and we want to find B, the centre of the intersection circle:


Pythagoras gives us the following two equalities:

AB² = AC₁² - BC₁²
AB² = AC₂² - BC₂²

Combining the two and replacing AC₁ with R₁ and AC₂ with R₂:

BC₁² - BC₂² = R₁² - R₂²

We know that C₁B + BC₂ = C₁C₂:

                BC₁² - (C₁C₂ - BC₁)² = R₁² - R₂²
BC₁² - C₁C₂² - BC₁² + 2 * C₁C₂ * BC₁ = R₁² - R₂²
                      2 * C₁C₂ * BC₁ = R₁² - R₂² + C₁C₂²
                                 BC₁ = (R₁² - R₂² + C₁C₂²) / (2 * C₁C₂)

Giving us the final formula for the C₁B vector:

C₁B = (R₁² - R₂² + C₁C₂²) / (2 * C₁C₂²) * C₁C₂

Using pseudocode:

float P = dot(center_2 - center_1, center_2 - center_1);
float Q = (radius_1 * radius_1 - radius_2 * radius_2 + P) / (2.0f * P);
Point B = center_1 + Q * (center_2 - center_1);
  • \$\begingroup\$ @Hocevar maybe I am a bit slow but I don't think that we know BC2.. just because we don't exactly know even where is B. Am I wrong? \$\endgroup\$
    – Leggy7
    Jan 14, 2014 at 10:48
  • \$\begingroup\$ @Leggy7 You can just calculate it. Since you know R1 and R2 you can calculate how far both circles overlap (second code snippet). B will always be in the middle of the overlapping area. \$\endgroup\$
    – Mario
    Jan 14, 2014 at 11:49
  • \$\begingroup\$ @Leggy7 the last line tells you where is B because it tells you what vector C1B is. If only we could use LaTeX formatting on this site, it would look a lot better. \$\endgroup\$ Jan 14, 2014 at 11:58
  • \$\begingroup\$ @Leggy7 I added pseudocode using your variable names, hoping it's clearer now. \$\endgroup\$ Jan 14, 2014 at 12:47
  • \$\begingroup\$ Excuseme sir, this is my first approach to this topic, so I'll need some explaination. what does the dot product of a vector with itself represent? geometrically, I mean \$\endgroup\$
    – Leggy7
    Jan 14, 2014 at 16:58

Here a simple method to compute the center of the intersection circle between two (hyper)spheres that works for every dimension (but 0D) using some vector notation.

Let C1 and C2 be the center of your (hyper)spheres, r1 and r2 the radii.

D := C2 - C1 is the vector that moves C1 to C2; the leght of D (|D|) is the distance between centers.

Now d := |D| -(r1+r2) is the distance between the (hyper)spheres: positive menans no intersection, 0 menans point intersection, negative means intersection.

In the latter case, -d is an usefull measure of how much the spheres compenetrate.

Now the distance between C1 and the center(C) we are looking for, is r1 - (-d)/2; being -d/2 the half distance and being substracted from r1 because r1 is "responsible" for "half compenetration".

Then C = D /|D| * (r1+d/2)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .