Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


axis aligned bounding box's

This topic is 5927 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A vector has no concept of origin, so you can''t really check to see if it''s in the same place as anything. It isn''t really in a place.

If you want to check for a point, simply make sure its coordinates are each between the minimum and maximum coordinates for the bounding box. I assume you''re thinking of something more complex, tho.

Don''t listen to me. I''ve had too much coffee.

Share this post

Link to post
Share on other sites
A vector is not a ray, it's just a direction. You need a point and a vector to specify a ray.

If I remember my geometry correctly, what you want to do is check if the ray crosses any of the 6 planes that make up the aabb. If the ray does cross any of these planes, find the point where it crosses and see if that point is actually in the aabb.

The point (px,py,pz) is the beginning of the ray, and the vector (vx,vy,vz) is the direction of the ray. So the equation for the ray is (x,y,z) = (px,py,pz) + t*(vx,vy,vz) where t is an arbitrary constant.

For each plane that makes up the aabb:
- Check if the ray is perpendicular to the plane's normal (in other words the dot product is equal to 0 - note that if you're using floating point numbers you're unlikely to get an answer of exactly zero so just check if the value is very small). If it is then the ray doesn't intersect this plane so you can ignore it.
- Plug the ray's (x,y,z) values into the plane's Ax+By+Cz+D=0 equation. This gives you A(px+t*vx)+B(py+t*vy)+C(pz+t*vz)+D=0. Solve this equation for t, then plug that t back into the ray equation to get the point where the ray intersects the plane. Check if this point is within the bounds of the aabb. If it is then you have an intersection, otherwise move onto the next side of the aabb.

Edit: followup

The method I gave you will tell you if a line intersects with a bounding box. If you want just a ray (ie a line extending only in one directoin) check if the value of t you find is positive.

[edited by - Dobbs on July 24, 2002 6:15:41 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!