开发者

How do I determine the collision normal in an axis aligned bounding box collision?

开发者 https://www.devze.com 2023-03-08 22:04 出处:网络
I have a 3d moving box an开发者_JS百科d a stationary box. I can detect collisions ok but now I would like to slide the moving box against the stationary box as a collision response. For this I need th

I have a 3d moving box an开发者_JS百科d a stationary box. I can detect collisions ok but now I would like to slide the moving box against the stationary box as a collision response. For this I need the normal of the face that collides with the moving box. Does anyone know how I figure this out? It doesn't seem like the collision test gives me this information. Any help is appreciated.


The normal of the face is equal to the cross product between the vectors of two of the connecting edges of all the edges which are adjacent to the face.

Let a,b and c be position vectors of 3 of the 4 points around the face:

//edge a<->b
Vector3f ab = b-a;

//edge b<->c
Vector3f bc = c-b;

//normal of the face
Vector3f normal = Vector3.cross_product(ab,bc);

If you don't know what the cross product between two three-dimensional vectors is, you can look here: http://en.wikipedia.org/wiki/Cross_product

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号