0
\$\begingroup\$

Is there a way to get the normal and depth of two spheres that have collided.

I know that it is something to do with the center and radius of two spheres but I am not sure what

\$\endgroup\$
  • \$\begingroup\$ Downvoter, can you please explain why you downvoted. Feedback will be appreciated so I can modify the post. \$\endgroup\$ – user116458 Jun 6 '18 at 11:39
5
\$\begingroup\$

This is probably the simplest 3D collision check.

Distance between sphere centers is length(c1.center - c2.center)

Depth is distance - radius1 - radius2 = length(c1.center - c2.center) - c1.radius - c2.radius

Normal is normalized(c1.center - c2.center) for c2 and the inverse of that for c1.

\$\endgroup\$
  • \$\begingroup\$ It may be worth mentioning that the point of contact on the surface of the sphere is c1.center - normal * c1.radius / c2.center + normal * c2.radius). If the spheres just touch without penetrating, then these two surface contact points will be the same. \$\endgroup\$ – DMGregory Aug 9 '18 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy