#### Archived

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

# BBox rotation

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

## Recommended Posts

For my collision detection I worked out four vertices around my car using the D3DXComputeBoundingBox() function form the D3DX library. Now I want to rotate and translate the vertices so they are always the tightest fit around the car. Basically its a OBB. Any ideas on how to do this. I could cos/sin or use some matrix stuff but I need more info.

##### Share on other sites
One more question.

How would I work out if a bounding box hit a triangle plane or triangle and also work out the intersection point.

Ok no more questions.

##### Share on other sites
if you really want to rotate rectangle (change coordinates of points):
for rotate you must define center for your rectangle in point 0,0. for example your rectangle:

--------x 10,10
| |
| 0,0 |
| |
x--------
-10,-10

and rotation:

...
float fWorkAngleCos, fWorkAngleSin, fWorkAngleMinusSin, nx, nz, negVecRx;

negVecRx=-vecR.x;
fWorkAngleCos=cos(negVecRx);
fWorkAngleSin=sin(negVecRx);
fWorkAngleMinusSin=-sin(negVecRx);

//-- for first point ---
nx=ObjectRectangle[i*4].x;
nz=ObjectRectangle[i*4].z;
ObjectRectangle[i*4].x=nx*fWorkAngleCos+nz*fWorkAngleSin;
ObjectRectangle[i*4].z=nx*fWorkAngleMinusSin+nz*fWorkAngleCos;

//-- for second ---
...
and so on for last three points.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 46
• ### Forum Statistics

• Total Topics
632635
• Total Posts
3007569
• ### Who's Online (See full list)

There are no registered users currently online

×