Coordinate system transformation problem (about Euler angle)

EulerMatrix is available in MMA 10. To obtain the matrix for the transformation shown in your sketch, apply

EulerMatrix[{α,β,γ},{3,1,3}]

This transformation is known as the x-convention, because the second rotation is about x'-axis. The Wikipedia designates this by ZXZ.

Those who do not have MMA 10 can obtain the same x-convention transformation using RotationMatrix applied 3 times. The code is

Transpose@
  Dot[
    RotationMatrix[γ, {0, 0, -1}], 
    RotationMatrix[β, {-1, 0, 0}], 
    RotationMatrix[α, {0, 0, -1}]]

As you know from the Wikipedia, there is more than one set of Euler angles. The y-convention is more common in quantum mechanics, so let me give that transformation here as well. In MMA 10, the y-convention transformation is

 EulerMatrix[{α,β,γ},{3,2,3}]

or

 EulerMatrix[{α,β,γ}]

since the y-convention is the default when the axes are not specified. The Wikipedia designates this by ZYZ. In terms of the RotationMatrix function, the y-convention transformation is

Transpose@
  Dot[
   RotationMatrix[γ, {0, 0, -1}],
   RotationMatrix[β, {0, -1, 0}], 
   RotationMatrix[α, {0, 0, -1}]]

A reference for these transformations is Classical Mechanics by Herbert Goldstein, 2nd Edition, Section 4-4 and Appendix B.


To address your actual problem:

If you're just looking to re-orient your B-spline cylinder, there's no need to go through the Euler angles. Here's one way.

Consider the following cylinder:

myCyl = BSplineSurface[{{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}},
                        {{0, 0, 1}, {0, 1, 1}, {1, 1, 1}, {1, 0, 1}}}, 
                       SplineClosed -> {False, True}, SplineDegree -> {1, 3}, 
                       SplineWeights -> {{1, 3, 3, 1}, {1, 3, 3, 1}}];

Graphics3D[myCyl, Axes -> True]

just a cylinder

Note that this unit-height cylinder is pointing towards the positive $z$-axis. To re-orient this cylinder to point in a different direction, you can use RotationTransform[]. Here's how to re-orient it to point at the direction of $(3,1,2)$:

Graphics3D[{MapAt[Map[RotationTransform[{{0, 0, 1}, {3, 1, 2}}], #] &, myCyl, 1],
            {Black, Arrow[Tube[{{0, 0, 0}, {3, 1, 2} // Normalize}]]}},
           Axes -> True]

yes, it goes that way

You can of course add a translation:

Graphics3D[{MapAt[Map[Composition[TranslationTransform[{-1, -1, 1}], 
                                  RotationTransform[{{0, 0, 1}, {3, 1, 2}}]], #] &,
                  myCyl, 1],
            {Black, Arrow[Tube[{{0, 0, 0}, {3, 1, 2} // Normalize}]]}},
           Axes -> True]

also goes that way