Original Post
I am trying to find the intersection (x, y, z) of two spheres and a plane to use for a collision detection routine in my game. Help would be appreciated. Here are the specifics: One of the spheres is x2 + y2 + z2 = 1 The second sphere is (x - xt)2 + (y - yt)2 + (z - zt)2 = r2 The plane is ax + by + cz = 0 Additional constraints that do not directly affect (x, y, z) but place limits on the constants used to calculate it: (xt, yt, zt) lies on the sphere defined in the first equation. (a, b, c) lies on the sphere defined in the first equation. NOTE: (a, b, c) is calculated as an initial point satisfying the first equation crossed with the velocity vector, which is perpendicular to the first vector. See the note at the end of this post. r > 0, r <= 2 I have tried using various methods, including parameterization with vectors in terms of cosine and sine, but have not been able to get a working solution. If it helps, I have found the plane on which the intersection of the two spheres lies to be defined by the equation xtx + yty + ztz = 1 - (r2) / 2 An analytic solution is the only way that this will work. There should be 0, 1, or 2 solutions for any values satisfying the conditions. NOTE: I have tried parameterizing the vector of the point of intersection x as Icos(theta) + vsin(theta) / |v|, where I is the initial point and v is the initial velocity. In the end, what I need to know is the angle measure from the initial point to the point(s) of intersection, in the direction of v. This, however, gave me a quadratic-ish equation (I could use the quadratic formula to solve for cos2(theta), but it didn't work in-game, probably because it was a huge thing to work out and to copy into code and I could have made errors doing either.