Sign in to follow this  
GavRobbs

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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this