I have 3D graphics with an ellipsoid and three arrows which represent its axes. However, not all arrows are inside the ellipsoid; two are outside. How can I rotate the ellipsoid with the use of built-in functions to have the arrows inside the ellipsoid? I have tried three different solutions; however, none give the result I want to get. What did I do wrong?
Here is an example:
Module[{rotZ, a1, a2, a3, b1, b2, b3, l1, l2, l3},
{a1, a2, a3} = {{1.5, 0., 0.}, {0., 1, 0.}, {0., 0., 2}};
rotZ[θ_] := {{Cos[θ], Sin[θ], 0}, {-Sin[θ], Cos[θ], 0}, {0, 0, 1}};
{b1, b2, b3} = {rotZ[30. Degree].a1, rotZ[30. Degree].a2, a3};
{l1, l2, l3} = Map[Sqrt[#[[1]]^2 + #[[2]]^2 + #[[3]]^2] &, {a1, a2, a3}];
Graphics3D[{
(*coodrinate system*)
{Arrowheads[Small], Arrow[{{0., 0., 0.}, {1., 0., 0.}}]},
Text[Style["X", 12, Black], {1., 0., 0.} 1.1],
{Arrowheads[Small], Arrow[{{0., 0., 0.}, {0., 1., 0.}}]},
Text[Style["Y", 12, Black], {0., 1., 0.} 1.1],
{Arrowheads[Small], Arrow[{{0., 0., 0.}, {0., 0., 1.}}]},
Text[Style["Z", 12, Black], {0., 0., 1.} 1.1],
{Dotted, Line[{{0., 0., 0.}, {-1., 0., 0.}}]}, {Dotted,
Line[{{0., 0., 0.}, {0., -1., 0.}}]}, {Dotted,
Line[{{0., 0., 0.}, {0., 0., -1}}]},
(*ellipsoid*)
(*1*)
{Opacity[0.3], Gray, Ellipsoid[{0., 0., 0.}, {l1, l2, l3}]},
(*2*)
(*{Opacity[0.3],Gray,Ellipsoid[{0.,0.,0.},{b1,b2,b3}]},*)
(*3*)
(*{Opacity[0.3],Gray,Rotate[Ellipsoid[{0.,0.,0.},{l1,l2,l3}],
30. Degree,{0.,0.,0.}]},*)
(*ellipsoid axes*)
{Arrowheads[Small], Arrow[{{0., 0., 0.}, b1}]},
Text[Style["a1", 12, Black], b1 1.1],
{Arrowheads[Small], Arrow[{{0., 0., 0.}, b2}]},
Text[Style["a2", 12, Black], b2 1.1], {Arrowheads[Small],
Arrow[{{0., 0., 0.}, b3}]}, Text[Style["a3", 12, Black], b3 1.1]
}, ViewPoint -> Top
]]