What\'s the easiest way of doing this? I fail at math, and i found pretty complicate formulaes over the internet... im hoping if theres some simpler one?
I just need
Jim Arvo has an algorithm for this in Graphics Gems 2 which works in N-Dimensions. I believe you want "case 3" at the bottom of this page: http://www.ics.uci.edu/~arvo/code/BoxSphereIntersect.c which cleaned up for your case is:
bool BoxIntersectsSphere(Vec3 Bmin, Vec3 Bmax, Vec3 C, float r) {
float r2 = r * r;
dmin = 0;
for( i = 0; i < 3; i++ ) {
if( C[i] < Bmin[i] ) dmin += SQR( C[i] - Bmin[i] );
else if( C[i] > Bmax[i] ) dmin += SQR( C[i] - Bmax[i] );
}
return dmin <= r2;
}