Skybar Posted January 30, 2017 Share Posted January 30, 2017 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? Quote Link to comment Share on other sites More sharing options...
dimovfx Posted January 30, 2017 Share Posted January 30, 2017 I'm sure it's all wrong, but for a quickie should work someone better at math should help middle_point.hip Quote Link to comment Share on other sites More sharing options...
Skybar Posted January 30, 2017 Author Share Posted January 30, 2017 @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. Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted January 30, 2017 Share Posted January 30, 2017 Sorry if this kind of answer isn't allowed, but this link explains it fairly straight forwardly Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted January 31, 2017 Share Posted January 31, 2017 (edited) 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); intersect_spheres.hipnc Edited January 31, 2017 by konstantin magnus added hip file Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 31, 2017 Share Posted January 31, 2017 Another way: vector sphere_x_sphere_pos(vector a, b; float rada, radb) { vector delta = b - a; float dist = length(delta); float x_dist = (rada*rada - radb*radb + dist*dist) / (2 * dist); vector x_pos = a + normalize(delta) * x_dist; return x_pos; } Check this thread for hips. 1 Quote Link to comment Share on other sites More sharing options...
Skybar Posted January 31, 2017 Author Share Posted January 31, 2017 @vtrvtr @konstantin magnus @f1480187 This looks great! I'll look into it a bit later tonight, thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.