Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understood what you are trying to do, this will create a matrix which will rotate around an arbitrary axis, in your case the axis is the cross product between the direction and up vector, which is the axis pointing to your right (or left, depends on the coordinate system and product order). Cross product always return a vector perpendicular to the other two.</p> <pre><code>//Cross product D3DXVECTOR3 axis; D3DXVec3Cross(&amp;axis, &amp;direction, &amp;up); //Rotation matrix D3DXMATRIX matrix; D3DXMatrixRotationAxis(&amp;matrix, &amp;axis, rotationAmount); </code></pre> <p>The resulting matrix should be your rotation matrix.</p> <p>Have a look at <a href="http://en.wikipedia.org/wiki/Euler_angles" rel="nofollow">http://en.wikipedia.org/wiki/Euler_angles</a> in the section "rotation matrix XYZ" if you want to get the rotation angles back, but I suggest you to use built-in matrix and vector operation given by directx to store your position and rotation.</p> <p>It will allow you to easily rotate, translate and scale positions and directions using matrices withouth taking care of maths under every operation, and withouth causing gimabl lock (<a href="http://en.wikipedia.org/wiki/Gimbal_lock" rel="nofollow">http://en.wikipedia.org/wiki/Gimbal_lock</a>). Have a look at <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb205164(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/bb205164(v=vs.85).aspx</a> for directx maths operations or search for other tutorials, it is really easy to learn how to handle them.</p> <p>If you want some infos on specific math or other game-related topics I suggest you to read "game engine architecture" by Jason Gregory</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload