1. ## Comparing Matrices (D3D9)

hey, just a stupid question, im new to D3D, previously just ben coding 2D games using Dx7 and the GDI but i decided id make the change to 3D, im reading through a D3D book and im at the part of handling transformations and translations allowing roatation and movement of primitives using matrices. now logicaly i thought, hey if matrices hold position data then surely comparing matrices could tell me if two primitives are coliding or not, so i skimmed the book looking to see if it had any info on collision and to my annoyance not a thing on collision detection in the whole book..
can any 1 point me in the right direction?
thanx

2. Collision detection actually has nothing at all to do with matrices in regards to meshes. All you do is make bounding spheres/boxes around the meshes you want to check and use a simple geometry formula to calculate if the spheres or boxes collide. Here's a basic sphere collision detection function written in C++:

Code:
```BOOL CheckSphereCollision( float XCenter1, float YCenter1, float ZCenter1, float Radius1,
float XCenter2, float YCenter2, float ZCenter2, float Radius2 )
{
float XDifference, YDifference, ZDifference, Distance;

XDifference  =  (float)fabs(XCenter2 - XCenter1);
YDifference  =  (float)fabs(YCenter2 - YCenter1);
ZDifference  =  (float)fabs(ZCenter2 - ZCenter1);

Distance  =  (float)sqrt(XDifference*XDifference+YDifference*YDifference+ZDifference*ZDifference);