# Intersection position of 2 spheres

## Recommended Posts

I'm trying to find the position where 2 spheres intersect eachother. Just a location in the middle. If they both have the same radius it's pretty straightforward, I put both centroids into a Mix VOP with bias at 0.5. But if they're NOT the same radius I just can't figure it out. I suppose I need some sort of bias towards the smaller sphere, but I don't know where to get that from. I'm sure it's possible to calculate somehow from the centroids and radii, at least I think so but I can't get it right. Dialling it in manually doesn't really work when the spheres move. Does anyone have a clue?

##### Share on other sites

I'm sure it's all wrong, but for a quickie should work

someone better at math should help

middle_point.hip

##### Share on other sites

@sasho78 Hey thanks! Yeah that's about how far I've gotten as well. See picture what I mean. For same size spheres it works perfectly, but when they're not it's a little bit off.

##### Share on other sites

Sorry if this kind of answer isn't allowed, but this link explains it fairly straight forwardly

##### Share on other sites

You can point a normal from one sphere's center to the other and multiply that by its own radius plus half the overlap of the spheres radii.

```float rad_1 = ch("../sphere1/scale");

@N = normalize(@opinput1_P - @P);
@dist = distance(@P, @opinput1_P);
@ibtw = rad_1 + ( @diff / 2 );

vector pos = @P + (@N * @ibtw );

intersect_spheres.hipnc

Edited by konstantin magnus
##### Share on other sites

Another way:

```vector sphere_x_sphere_pos(vector a, b; float rada, radb)
{
vector delta = b - a;
float dist = length(delta);
vector x_pos = a + normalize(delta) * x_dist;
return x_pos;
}```

##### Share on other sites

@vtrvtr @konstantin magnus @f1480187 This looks great! I'll look into it a bit later tonight, thanks a lot!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×