View Full Version : Point/Box in sphere-check?
02-13-2003, 11:26 AM
I want to check wether a box is intersecting a sphere with at least one corner.
I know this is not OGL related but if you have some code please post it. I just can't get it right, I' tired and stuff. Thanks for the help...
02-13-2003, 11:41 AM
Not sure if this is what you are looking for, but if you know the center point of the sphere and the radius of the sphere, find the line between center of sphere and corner of box. Find the length of line. If line length is less than radius then box corner point is within sphere.
02-14-2003, 08:26 AM
if ((box_corner - circle_center) < circle_radius)
else if ((box_corner - circle_center) > circle_radius)
// not intersecting
// touching each other
[This message has been edited by jebus (edited 02-14-2003).]
02-15-2003, 03:10 AM
OK, thanks I got something working now.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.