I have the开发者_运维问答 center (xyz - in 3 dimensional space) and the radius of two spheres A and B.
Now I have to figure out a point or more than 1 point where these spheres meet. It is fairly easy to figure out if the two spheres collide or not, but how do I find out the points of intersection of 2 spheres?
Any help would be greatly appreciated.
The curve where they intersect is a circle. The equation for the radius of the circle is a bit complicated, but is shown here, in eqn. 8, and this distance of the circle from the center of one of the spheres is shown in eqn. 5.
If the radius of the smaller sphere is A, and the bigger is B, and their centers are D units apart, then the points of intersection are on a circle of radius r centered on a point directly between the centers of the two spheres, which is y units from the center of the bigger sphere, and x units from the center of the other, where
y = 1/2 (D + (B^2 - A^2)/D)
and
x = 1/2 (D - (B^2 - A^2)/D)
with radius
r = B^2 - x^2 = A^2 - y^2
If you need the equation for this circle the best way is to represent it as a set of three parameterized equations, where the x, y, and z coordinates are each expressed a a function of some t, which represents the radius vector trraveling around the circle once, from zero to 2PI...
To construct these equations, think about expressing the point which is the radius r from the center, on the 2D plane which is normal to the line between the two spheres.
Check out this link for some iedas on how to do this..
Derivation is as follows: draw a line between the centers of the two spheres. Label it as D
Designate a point on this line as the center of the final solution circle label it as point O
Label the smaller portion of D as x, and the large portion as y
draw a line from O perpindicular to D, for some distance r to represent the radius of the solution circle
Label the end of this radius as Q
Now draw B between the center of the larger sphere to Q and A from the center of smaller sphere and Q
From Pythagoras:
B^2 = y^2 + r^2 and A^2 = x^2 + r^2
so, after eliminating r and a bit of algebra,
y-x = (B^2 - A*2) / (x+y)
But x+y = D so,
y-x = (B^2 - A*2) / D
Adding the equation x+y=D to the above eliminates the x, giving
2y = D + (B^2 - A*2) / D
or,
y = 1/2 ( D + (B^2 - A*2) / D )
精彩评论