Jump to content
• Advertisement

#### Archived

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

# Hey... would this work?

This topic is 5955 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

Hey, I''ve been looking for a way to do fast tests for collision between a ray and an AABB (Axis Aligned Bounding Box), and I think I''ve found something. First you find the center of the bounding cube. Then, you test to see if the x component of the vector is other than zero. If it is, you divide the difference between the x component of the origin of the ray, and the center of the AABB, by the x component of the vector. Else, just skip the x component entirely and move on to the Y, performing the same operations. Then, take the product of the box center y and the origin y, multiply it by the above mentioned quotient do the same for z. So you should have by this point(pun not intended, hehe,) (box center x - ray origin x, (box y - ray origin y)*(box center x - ray origin x)/vector x), (box z - ray origin z)*(box center x - ray origin x)/vector x)) you then (making sure, in this case, that the y component of the vector is not equal to zero,) get, ((box x - ray origin x)*(box center y - ray origin y)/vector y), box y - ray origin y, (box z - ray origin z)*(box center y - ray origin y)/vector y)) and (still not forgetting, just as with the y and x components, that the z component of the vector cannot equal zero or this segment should be skipped.) ((box x - ray origin x)*(box center z - ray origin z)/vector z), (box y - ray origin y*(box center z - ray origin z)/vector z), box z - ray origin z) if any of these points are in the box in question, then you have collision. Does this make sense? I''ve tried it on paper but not in my engine yet. Hope to hear many constructive comments Klaus

#### Share this post

##### Share on other sites
Advertisement
no replies, hmmm... Is this in the right forum?

#### Share this post

##### Share on other sites
i dont know this stuff at all, but i say give it a try and find out, thats how i do these things

#### Share this post

##### Share on other sites
What do you mean by "bounding cube?" And you mention "the x component of the vector" a lot, I assume you''re referring to the x component of the centre of the bounding cube but it''s unclear.

If it works, use it.

#### Share this post

##### Share on other sites
By a "bounding cube" I mean the same thing as an AABB, and no, I mean the x component of the only mentioned vector. And anyway, I am pretty sure it work, I was just looking for comments and possibly a better (read faster) way to do it.
Klaus

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 13
• 9
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633331
• Total Posts
3011390
• ### Who's Online (See full list)

There are no registered users currently online

×

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