D3DXRotationMatrixY[θ_] := {{Cos[θ], 
            0, -Sin[θ]}, {0, 1, 0}, {Sin[θ], 0, 
            Cos[θ]}};
D3DXRotationMatrixX[θ_] := {{1, 0, 0}, {0, Cos[θ], 
            Sin[θ]}, {0, -Sin[θ], 
            Cos[θ]}};
D3DXRotationMatrixZ[θ_] := {{Cos[θ], Sin[θ], 
            0}, {-Sin[θ], Cos[θ], 0}, {0, 0, 
            1}};
D3DXRotationMatrixYawPitchRoll[yaw_,  pitch_,  roll_] := 
        RotationMatrixZ[roll] . RotationMatrixX[pitch] . 
          RotationMatrixY[yaw];
D3DXRotationMatrixAxis[x_, y_, z_, θ_] := 
      Module[{axis}, 
axis = {x, y, z}/
            Sqrt[{x, y, z} . {x, y, z}]; 
Outer[ Times,  
              axis,  axis ] (1 - 
                Cos[θ])
 + {{0, 
                axis[[3]], -axis[[2]]}, 
{-axis[[3]], 0, 
                axis[[1]]}, 
{axis[[2]], -axis[[1]], 0}} Sin[θ]
 + {{1, 0, 
                0}, 
{0, 1, 0}, 
{0, 0, 
                1}} Cos[θ]]
<< Algebra`Quaternions`
D3DXQuaternionRotationAxis[x_, y_, z_, θ_] := 
      Module[{axis}, 
axis = 
          Sin[θ/2] {x, y, z}/
              Sqrt[{x, y, z} . {x, y, z}]; 
Quaternion[ 
          axis[[1]], axis[[2]], axis[[3]],  
          Cos[θ/2]]]
D3DXQuaternionRotationYawPitchRoll[yaw_,  pitch_,  roll_]  := 
        D3DXQuaternionRotationAxis[0, 0, 1, roll]  **  
          D3DXQuaternionRotationAxis[1, 0, 0, pitch]  **  
          D3DXQuaternionRotationAxis[0, 1, 0, yaw];