# Bounding Box

## Recommended Posts

GavRobbs    100
I need some help with this whole ray box intersection thing. It says a box can be considered to be a set of 3 orthogonal planes. How do I generate these planes if I have the boxes minimum and maximum points?

##### Share on other sites
oliii    2196
realatively straight forward.

box [min, max]

plane minX : normal = Vector(-1, 0, 0), d = -min.x
plane maxX : normal = Vector( 1, 0, 0), d = max.x
plane minY : normal = Vector( 0,-1, 0), d = -min.y
plane maxY : normal = Vector( 0, 1, 0), d = max.y
plane minZ : normal = Vector( 0, 0,-1), d = -min.z
plane maxZ : normal = Vector( 0, 0, 1), d = max.z

intersection :

t_intersect = (d - rayStart.dotProduct(normal)) / (rayDir.dotProduct(normal));

=>

t_minx = (min.x - rayStart.x) / (rayDir.x);
t_maxx = (max.x - rayStart.x) / (rayDir.x);
t_miny = (min.y - rayStart.y) / (rayDir.y);
t_maxy = (max.y - rayStart.y) / (rayDir.y);
t_minz = (min.z - rayStart.z) / (rayDir.z);
t_maxz = (max.z - rayStart.z) / (rayDir.z);

##### Share on other sites
GavRobbs    100
Hey thanks man!!! I feel like a moron now! lol

oliii    2196
No problemo :)