Jump to content

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?

Link to comment
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");
float rad_2 = ch("../sphere2/scale");

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

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


Edited by konstantin magnus
added hip file
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

  • Create New...