#### Archived

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

# Collision detection

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

## Recommended Posts

I use bounding sphere algorithm for collision detection in my engine. I created an algoritm for calculate sphere''s center and radius. It is calculate correctly radius and center of my object. My question is When my object is moving, how can I move the Center of my object, excatly? (I know the radius should not be changed, because sphere is simetrical.) D3DXVECTOR CenterPlane; //Center of Plane object. D3DXMATRIX mat_PlaneMatrix; // Moving matrix of my plane. Show me the way. Thanks.

##### Share on other sites
PLEASE learn to RESPECT the forums! You have posted this same question TEN times.

¬_¬

##### Share on other sites
Hi click,

I use a hierarchical bounding sphere system for object culling. Transforming the center of the sphere is simple, because it is like transforming any other point in space:

D3DXMATRIX mtrxTransform; // transformation matrix of the object
D3DXVECTOR3 vct3Center; // sphere center in object space
D3DXVECTOR3 vct3AbsoluteCenter; // sphere center in world space

D3DXVec3TransformCoord( &vct3AbsoluteCenter, &vct3Center, &mtrxTransform );

Because a matrix can change the size of an object by scaling, you should also transform the radius. But it is not so easy when you want to get the correct value in a fast way. You have to transform some good points from the surface of the sphere. From the resulting points you should use the maximum to get the transform radius value.
If you only use scaling with equal values in all three dimensions, then you are able to use the following formula:
fAbsoluteRadius = D3DXVec3Length( D3DXVec3TransformNormal( &vct3Radius, &D3DXVECTOR3( D3DXVECTOR3( 0.57735f, 0.57735f, 0.57735f ) * fRadius ), &mtrxTransform ) );

##### Share on other sites
It''s not that hard.

You move your object X units.

newCenter = oldCenter + X;

I really hope I''m misunderstanding your question. If I''m not, then maybe you need more math before attempting graphics programming.

##### Share on other sites
If moving means the translation of the object then lucid999 is correct, but when the motion by transformation is meant then you have to transform the center, too.

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

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

• Total Topics
632634
• Total Posts
3007546
• ### Who's Online (See full list)

There are no registered users currently online

×