#### Archived

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.

## Recommended Posts

how do you test for a collision between an aabb and a vector? Klaus

##### Share on other sites
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 on other sites
I mean a vector with an infinite ray like definision.

[edited by - neonoblivion on July 24, 2002 5:20:27 PM]

##### 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]

thx

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
15

• 14
• 9
• 9
• 9
• 10
• ### Forum Statistics

• Total Topics
632912
• Total Posts
3009199
• ### Who's Online (See full list)

There are no registered users currently online

×