Archived

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

Hey... would this work?

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


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


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


Link to post
Share on other sites