# Circle-Sphere 3D Intersection Points

1. Jul 25, 2012

### wb24

I would like to find a way to get the intersection points of a circle and a sphere in 3d. The center of each and their radii are known. This needs to be a general solution so that I can move the center of the sphere in steps and find the intersection at each step.
I am curious if this can be done by treating the circle as the intersection of a plane and sphere, finding the intersection of the 2 spheres (which will give a circle), then finding where that circle intersects the plane.
I need some help in working all of this out.

Heres is a link to someone else trying this, but I do not understand the solution...
Can anyone decode this for me? haha

2. Jul 25, 2012

### chiro

Hey wb24 and welcome to the forums.

For this you will get either 0, 1, 2, or infinitely many solutions (if the circle lies on the sphere).

First try and equate the equation of the sphere with the circle: for the sphere and circle respectively we have (x-a)^2 + (y-b)^2 + (z-c)^2 = r^2 and (x-d)^2 + (y-e)^2 = q^2.

The only complication though is that the circle can be rotated to not simply lie in the x-y axis which means you will have to rotate the circle around an axis to get it in the form. This is what the author was getting at in the majority of his post.

So to rotate the circle you need to adjust the equation so that the plane that the circle lies in is known. This means that given the normal of the plane, the tangent of the circle is always perpendicular to the normal.

What you need to do is find the equation of the rotated plane and then substitute in the new co-ordinates that correspond to the u and v axis of the plane.

So as an example for a normal circle we have (x-a)^2 + (y-b)^2 = r^2 if a circle is in the x-y plane. What you will have to do is change this to (u-a)^2 + (v-b)^2 = r^2 where the circle has a centre (a,b) but lies in the (u,v) plane instead of the (x,y) plane.

This requires you to get a plane and parameterize it in terms of (u,v) co-ordinates which can be done by writing the plane in terms of plane = some_point + u*a + v*b where u and b are orthogonal (should be orthonormal) where <u,b> = 0.

Then what you do from this point in-wards is you take your circle in u,v co-ordinates, convert the sphere into u,v co-ordinates and then solve for u,v.

To convert the sphere to u,v co-ordinates simply find the centre of the sphere that lies on the u,v plane and replace the x,y,z with the new co-ordinates where the z co-ordinate will be the cross product of the normalized u and v vectors. Once you do all this everything will be in terms of u and v and you can find the solutions.

So this is probably a lot to take in so I will ask if you are familiar with finding the plane equation in terms of two independent vectors and how much knowledge of geometry have particular for dot and cross products?

3. Jul 26, 2012

### wb24

chiro,
Thanks for the quick response.
One important detail I forgot was that a vector perpendicular to the plane containing the circle is also known (a vector along the axis that the circle is rotated around).

I am very familiar with dot and cross products.

Does rotating in these (u,v) axes account for the circle to be rotated in any of the 3 directions? (not just around the z axis?)

So your saying find the intersection points in u,v coordinates, then transform back to x,y coordinates? Can you give a little more detail/example of how this is done? Do you use vectors from the x,y origin to the u,v origin?

4. Jul 26, 2012

### chiro

Yes the (u,v) will hold in any direction and not just the z-axis: remember that your new 'z' axis will be the cross product of u and v and we assume u is orthogonal (better to be orthonormal though) to v.

In terms of going from (u,v) to (x,y,z), the plane equation should be able to go from point + u*a + v+b to ax + by + cz + d = 0 (different a's and b's for each formulation). It's a matter of going between the two representations.

So if we have say u = (1/SQRT(2),0,1/SQRT(2)) and v = (0,1,0) our plane has a normal of u x v. Now u is in terms of (x,y,z) in the form of [1/SQRT(2)]x + 0y + [1/SQRT(2)]z and v = 0x + 1y + 0z. You can then equate the components in each representation of the plane equation to get the x,y, and z values.

5. Jul 26, 2012

### HallsofIvy

Staff Emeritus
I would recommend that first you find the equation of the plane the circle lies in and then find the intersection of that plane with the sphere.

6. Jul 26, 2012

### haruspex

Normalise vectors s.t. the sphere radius R is centred at the origin.
Let c be the vector to centre of circle (radius C) and p the vector defining the plane containing it (i.e. to the point of the plane nearest the origin).
Let x be on the intersection of sphere and circle.
x.p = p.p = p.c [1]
x.x = R2 [2]
(x-c).(x-c) = C2 [3]
If p and c collinear, either the circle lies on the sphere or does not intersect it all, so assume pxc0. x can be expressed as λp + μc + ηpxc. Substituting in [1], [2] and [3] shows λ+μ = 1, λ = (R2-C2)/(p.c - c.c), and R2 = λ2p.p + 2λμp.c + μ2c.c2(pxc).(pxc)
solve for λ, μ, η.

7. Jul 27, 2012

### wb24

Okay, so I've finally got it.
I attached a spreadsheet for anyone interested
For my application, I was moving the center point of the sphere along an arc, and outputing its intersection with a circle that has a fixed center. I was only interested in 1 of the 2 intersection points.
If you are just looking to find a single intersection point of a fixed sphere and circle, you could still use this and just simply it down a lot.
Thanks for all the help!

(I had to convert it to xls instead of xlsx to upload it here, so if it isnt working correct, sorry)

File size:
68.5 KB
Views:
309