I'm writing simple 3d application, with directX. Im a newbie, but i think i understand how D3DX Rotation works. when creating a colision detection functionality i notice that ball bounce in wrong direction. the code should change the direction of axis given in "direction" vector. Instead it change the 2 others:
speed = D3DXVECTOR3(1.0f, 2.0f, 3.0f);
direction = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
D3DXMATRIX temp;
D3DXMatrixRotationAxis(&temp, &direction, 3.14f);
D3DXVec3TransformCoord(&speed, &speed, &temp);
from breakpoint i know that speed changed from 1 , 2 , 3 to:
- _D3DVECTOR {x=0.999999762 y=-2.00477481 z=-2.99681091 } _D3DVECTOR
What am i doing wrong here? The idea is to invert the axis specified in direction vector.
You have created a rotation transformation of 180 around the X axis. Operating that on (1,2,3) resulted with (1,-2,-3) which is what you specified.
"Bouncing" your "speed" S vector with a plane that has Normal N: