# 2D collision detection

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

## Recommended Posts

I have a problem. I know how to make a simple 2D collision detection function using bounding boxes, but that only works when the bounding box is perfectly "straight", like the image here: ||||||||| ||||||||| ||||||||| ||||||||| Now that I am making a 3D FPS, I need to find a way to test for collision between a point and a bounding box that is at an angle, Like the image here. ..//////// .//////// //////// Does anyone know of a way to check for these kinds of collision [Edited by - Sir Sapo on December 31, 2004 7:01:06 PM]

##### Share on other sites
Have one large bounding box and sub boxes that are smaller.
Then, if their is a collsion with the big box check the smaller more accurate boxes for a collision. You can make them as small as you need. The large box is to save time and CPU. There is no point checking each small box when there might not even be a thing around it.

##### Share on other sites
What you want is an OBB (oriented bounding box). Google or search the archives here for 'obb' and you will find a wealth of information.

An OBB is similar to an AABB (axis-aligned bounding box) in that it has a center and three half-extents (its 'radii' in the x, y and z directions). However, an OBB also has a set of three orthonormal axes that represent its orientation in 3D space.

Do you know how to use a 4x4 (or 4x3) transformation matrix to transform a point from one space to another? An OBB's center and axes form such a matrix, and you can use this to transform a point in world space into 'OBB space'. Once you've done that, finding out whether the point intersects the OBB is a simple matter of checking its x, y and z components against the OBB extents.

There are also good algorithms for intersecting OBBs with other OBBs, spheres, lines, etc. Google and you'll find them!

Good luck.

P.S. At least I *think* you want an OBB, but maybe I'm misinterpreting your question (and your ASCII diagram, which by necessity is a parallelogram rather than an OBB). So if I'm off-base, never mind.

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633410
• Total Posts
3011727
• ### Who's Online (See full list)

There are no registered users currently online

×