# Replicate an image from Documentation Center (EulerMatrix)

EDIT

I try to produce an image similar to that

(see here) but this time with an ellipsoid. I hope I am not wrong but the code that creates this beautiful image is not available in Mathematica's Help Browser (I guess it was created in Mathematica).

Thanks to the replies I got in the recent similar posts, I use the following approach:

First the elliptical cross sections.

ellipse3D[centre_: {0, 0, 0}, radii_: {1, 1}, normal_: {0, 0, 1}] :=
Polygon[RotationTransform[{{0, 0, 1}, normal}, centre][
Map[Append[#, Last@centre] &][
SortBy[#, N[ArcTan @@ (# - Most@centre)] &] &[
MeshCoordinates[
(*ellipse to 3D*)

Next the non-rotated system of axis with its label.

arrowAxes[{a_, b_, c_}, arrowstyle_: {}, n1_: 1.5] := {arrowstyle,
Map[Arrow[Tube[{{0, 0, 0}, #}]] &, {a + n1, b + n1,
c + n1} IdentityMatrix[3]]}

labelAxes[{a_, b_, c_}, {o1_String: "X", o2_String: "Y",
o3_String: "Z"}, col_: Black,
n2_: 2] := {col, {Text[
Style[o1, 20, Italic], {a + n2 - 0.2, 0, -0.5}],
Text[Style[o2, 20, Italic], {0, b + n2, -0.6}],
Text[Style[o3, 20, Italic], {0, 0.6, c + n2 - 0.2}]}}

The non-rotated ellipsoid (with its cross sections).

ellipsoidXYZ[{a_, b_, c_}] := {{Specularity[White, 40], Opacity[0.3],
Ellipsoid[{0, 0, 0}, {a, b, c}]}, {{Red, Opacity[0.9],
EdgeForm[None], ellipse3D[{0, 0, 0}, {c, b}, {1, 0, 0}]}, {Blue,
Opacity[0.9], EdgeForm[None],
ellipse3D[{0, 0, 0}, {a, c}, {0, 1, 0}]}, {Orange, Opacity[0.9],
EdgeForm[None], ellipse3D[{0, 0, 0}, {a, b}, {0, 0, 1}]}}}

Altogether

visualizeEllipsoid[{a_, b_, c_}, {o1_String: "X", o2_String: "Y",
o3_String: "Z"}, arrowstyle_: {}, col_: Black, n1_: 2,
n2_: 2.5] := {labelAxes[{a, b, c}, {o1, o2, o3}, col, n2],
arrowAxes[{a, b, c}, arrowstyle, n1], ellipsoidXYZ[{a, b, c}]}

A plane in 3D.

plane = Graphics3D[{Opacity[0.2], EdgeForm[],
FaceForm[GrayLevel[0.7]],
Cuboid[{-13, -6, 0.001}, {13, 6, 0.001}]}];

The ellipsoid

gr = Graphics3D[visualizeEllipsoid[{10, 3, 2}, {}, Red, Red],
ImageSize -> 600]

Application of EulerRotationIllustration taken from here

$scene = First@gr; EulerRotationIllustration[{\[Alpha]_, \[Beta]_, \[Gamma]_}, {a_, b_, c_}] := Map[ Graphics3D[GeometricTransformation[$scene, #], PlotRange -> All,
ImageSize -> Medium,
BoxStyle -> LightGray] &, {EulerMatrix[{0, 0, 0}, {a, b, c}],
EulerMatrix[{\[Alpha], 0, 0}, {a, b, c}],
EulerMatrix[{\[Alpha], \[Beta], 0}, {a, b, c}],
EulerMatrix[{\[Alpha], \[Beta], \[Gamma]}, {a, b, c}]}]

rotEuler = EulerRotationIllustration[{Pi/3, Pi/2, Pi/3}, {3, 1, 3}];

I am close...but not so close:-!)

The questions now:

1) How I can insert these curve arrows representing the angle of rotation?

2) How to modify the function EulerRotationIllustration (or use someting other) in order to depict the axis system that accompanies each rotation;

3) Is it possible to put different labels for each of these system (e.g. XYZ->x'y'z'->x''y''z''->xyz)?

Thank you very much.

• Have you seen this? Commented Nov 23, 2015 at 16:50
• @J.M.: Not yet:-)! Commented Nov 23, 2015 at 18:33
• I found this question (and the references therein) very useful. Commented Nov 24, 2015 at 9:18

Ok, here we are:-)! Not perfect; but still it's better than nothing. I use the code from the demonstration of Euler Angles (whenever I use it I make a reference).

For anyone interested in, I have splitted the solution in order to be more accessible. I realize also that it is very difficult (at least to me) to reach the initial desired generality.

(*axes and labels*)
arrowAxes[{axesLength1_, axesLength2_, axesLength3_},
Map[Arrow[Tube[{{0, 0, 0}, #}, 0.04]] &, {axesLength1 + 0.5,
axesLength2 + 0.6, axesLength3 + 0.7} IdentityMatrix[3]]}
labelAxes[{axesLength1_, axesLength2_, axesLength3_}, {o1_String: "x",
o2_String: "y", o3_String: "z"},
col_: Black] := {col, {Text[
Style[o1, 20, Italic], {axesLength1 + 0.5, 0, -0.4}],
Text[Style[o2, 20, Italic], {0, axesLength2 + 1, -0.4}],
Text[Style[o3, 20, Italic], {0.1, 0.5, axesLength3 + 0.6}]}}

(*the global and local coodinate systems*)

axes1 = Graphics3D[{arrowAxes[{11, 10, 9}],
labelAxes[{11, 10, 9}, {}]}, ImageSize -> Large];
axes2 = Graphics3D[
GeometricTransformation[{arrowAxes[{11, 10, 11}, Red],
labelAxes[{11, 10.5, 11}, {"\[Xi]", "\[Eta]", "\[Zeta]"}, Red]},
EulerMatrix[{Pi/3, 0, 0}, {3, 1, 3}]], ImageSize -> Large];
axes3 = Graphics3D[
GeometricTransformation[{arrowAxes[{13.5, 10, 11}, Blue],
labelAxes[{14.4, 10, 12}, {"\[Xi]'", "\[Eta]'", "\[Zeta]'"},
Blue]}, EulerMatrix[{Pi/3, Pi/3, 0}, {3, 1, 3}]],
ImageSize -> Large];
axes4 = Graphics3D[
GeometricTransformation[{arrowAxes[{13, 11, 14}, Green],
labelAxes[{13.5, 11, 16}, {"\[Xi]'", "\[Eta]'", "\[Zeta]'"},
Green]}, EulerMatrix[{Pi/3, Pi/3, Pi/3}, {3, 1, 3}]],
ImageSize -> Large];
axesAll = Show[{axes1, axes2, axes3, axes4}]

(*arcs for rotation angles*)
(*code adopted from the demostration; slightly modified to fit my needs*)
phi = Pi/3; theta = Pi/3; psi = Pi/3;
xi = RotationMatrix[phi, {0, 0, 1}].{1, 0, 0};
eta = RotationMatrix[phi, {0, 0, 1}].{0, 1, 0};
zeta = RotationMatrix[phi, {0, 0, 1}].{0, 0, 1};
xiprime = RotationMatrix[theta, xi].xi;
etaprime = RotationMatrix[theta, xi].eta;
zetaprime = RotationMatrix[theta, xi].zeta;
etheta = RotationMatrix[theta/2, xi].zeta;
epsi = RotationMatrix[psi/2, zetaprime].xiprime;
phiarc = Table[
11 RotationMatrix[tx, {0, 0, 1}].{1, 0, 0}, {tx, 0,
Max[Pi/3, 0.01], 0.05}];
thetaarc =
Table[10 RotationMatrix[tx, xi].zeta, {tx, 0, Max[Pi/3, 0.01],
0.05}]; psiarc =
Table[9 RotationMatrix[tx, zetaprime].xiprime, {tx, 0,
Max[Pi/3, 0.01], 0.05}];

angles = Graphics3D[{Text[
Style["\[Phi]", FontSize -> 30, Red], {12 Cos[phi/2],
12 Sin[phi/2], 0}],
Text[Style["\[Theta]", FontSize -> 30, Blue], 11 etheta],
Text[Style["\[Psi]", FontSize -> 30, Green], 10 epsi]}];

Arrow[Tube[phiarc, 0.03]]}],
Arrow[Tube[thetaarc, 0.03]]}],

Show[{axesAll, arcs, angles}]

(*ellipse to 3D; see reply to post 99958*)
ellipse3D[centre_: {0, 0, 0}, radii_: {1, 1}, normal_: {0, 0, 1}] :=
Polygon[RotationTransform[{{0, 0, 1}, normal}, centre][
Map[Append[#, Last@centre] &][
SortBy[#, N[ArcTan @@ (# - Most@centre)] &] &[
MeshCoordinates[

(*non rotated elipsoid*)
ellipsoidXYZ[{a_, b_, c_}, opac1_: 0.6,
opac2_: 0.9] := {{Specularity[White, 40], Opacity[opac1],
Ellipsoid[{0, 0, 0}, {a, b, c}]}, {{Red, Opacity[opac2],
EdgeForm[None], ellipse3D[{0, 0, 0}, {c, b}, {1, 0, 0}]}, {Blue,
Opacity[opac2], EdgeForm[None],
ellipse3D[{0, 0, 0}, {a, c}, {0, 1, 0}]}, {Orange, Opacity[opac2],
EdgeForm[None], ellipse3D[{0, 0, 0}, {a, b}, {0, 0, 1}]}}}

(*xy-plane*)
plane = Graphics3D[{Opacity[0.1], EdgeForm[],
FaceForm[GrayLevel[0.7]],
Cuboid[{-10 - 3, -6, 0.001}, {10 + 3, 6, 0.001}]}];

g1 = Show[{Graphics3D[ellipsoidXYZ[{9, 3, 2}]], axes1, plane},
ImageSize -> Large];

g2 = Show[{Graphics3D[
GeometricTransformation[ellipsoidXYZ[{9, 3, 2}, 0.3],
EulerMatrix[{Pi/3, 0, 0}, {3, 1, 3}]]],
Graphics3D[angles[[1, 1]]], arcs[[1]], axes2, axes1, plane},
ImageSize -> Large]

g3 = Show[{Graphics3D[
GeometricTransformation[ellipsoidXYZ[{9, 3, 2}, 0.3, 0.6],
EulerMatrix[{Pi/3, Pi/3, 0}, {3, 1, 3}]]],
Graphics3D[angles[[1, 1]]], Graphics3D[angles[[1, 2]]], arcs[[1]],
arcs[[2]], axes2, axes3, axes1, plane}, ImageSize -> Large]

g4 = Show[{Graphics3D[
GeometricTransformation[ellipsoidXYZ[{9, 3, 2}, 0.3, 0.6],
EulerMatrix[{Pi/3, Pi/3, Pi/3}, {3, 1, 3}]]],
Graphics3D[angles[[1, 1]]], Graphics3D[angles[[1, 2]]],
Graphics3D[angles[[1, 3]]], arcs[[1]], arcs[[2]], arcs[[3]], axes2,
axes3, axes1, axes4, plane}, ImageSize -> Large]