Reputation: 385
Is there a way to find out the distance of intersection between 2 spheres ? I understand when two spheres intersect the circle of intersection is formed . But what i'm trying to figure ouut is by how much i will need to push circle 1 outside so that they dont intersect and are at a point where they are just touching each other . The only data i have are the centres of the spheres and their respective radii.
Thanks
Upvotes: 0
Views: 2029
Reputation: 20131
Define two spheres with centres at position vectors a and b (i.e. a = axi + ayj + azk).
Define a vector c from centre of sphere A to centre of sphere B:
c = b - a
Its length is |c| = |b - a|
= sqrt( [bx - ax]2 + [by - ay]2 + [bz - az]2 )
As Mahesh stated, the distance between the two spheres is:
|d| = |c| - rA - rB
So the vector d from the furthest point of sphere A to the furthest point of B will be either pointing along c (when the spheres are not yet intersecting) or in the opposite direction (when the sphere are intersecting).
To move one sphere so they don't intersect, you need to move it by d. Since this is along c, we can just multiply c by a factor to get the components of d:
f = ( |d| / |c| )
d = f * c
For example, in the x direction:
dx = f * cx
So I would say try this:
You can test whether the spheres intersect by testing the sign on f: if it is negative then the spheres intersect. You can then either move A or B by d, or both by some portion of d so that they no longer intersect.
Upvotes: 2
Reputation: 34625
( radius1 + radius2 ) - ( Current distance between the two centers )
is the amount of distance to be moved by either of a sphere to exactly touch each other. ( Assuming spheres are currently intersecting )
Upvotes: 1
Reputation: 372724
If you know that the two spheres overlap, then you could compute the distance between their centers. You could then add together the two spheres' radii to get the minimum distances that the spheres must be from one another such that they touch only at a point. The difference between the two (sum of the radii minus the distance between the centers) should be the amount the spheres need to move apart from one another so that they touch only at a point.
Upvotes: 0