# Problem using Rotation in Show

I would like to have an animation of rotating box and displayed it with other elements (not rotated) using Show. The first step to do that is to have all the elements working properly. So I did the following:

1. Created a box:

myBox = Cuboid[{-40, 40, 0}, {40, 60, 10}];


and make a Graphics3D out of it:

Graphics3D[myBox]

2. Rotated it:

Rotate[Graphics3D[myBox], Pi/2, {0, 0}]

3. Used Show:

Show[Rotate[Graphics3D[myBox], Pi/2, {0, 0}]]


And the strange things started to happen.

I tried most of the suggestions from those threads and the only one that helped was halirutan's from the first one:

    Show[Graphics@First@Rotate[Graphics3D[myBox], Pi/2, {0, 0}]]


There was no error, but also no rotation, so the problem was still not solved.

Then I tried:

    First@Show[Graphics@Rotate[Graphics3D[myBox], Pi/2, {0, 0}]]


The image was rotated, but it wasn't Graphics, so I couldn't use Show on it.

I suppose that answer is somewhere in the threads I quoted, but either I missed it or I can't use it.

• For 3D you need a 3D vector inside Rotate, e.g., Show[Graphics3D[Rotate[myBox, Pi/2, {0, 0, 1}]]] – Karsten 7. Mar 17 '15 at 21:49
• What are you trying to achieve by applying Show? – Szabolcs Mar 17 '15 at 21:49

myBox = Cuboid[{-40, 40, 0}, {40, 60, 10}];
Show@MapAt[Rotate[#, Pi/4, {0, 0, 1}, {0, 0, 0}] &, Graphics3D[myBox], {1}] Manipulate[Table[Show[Graphics3D[{Red, Sphere[{0, 0, 0}, 30],
Green, Cylinder[{{30, 30, 30}, {40, 50, 40}}, 30]}],
MapAt[Rotate[#, k, v, {0, 0, 0}] &, Graphics3D[myBox], {1}],
Boxed -> False, PlotRange -> {{-100, 100}, {-100, 100}, {-100, 100}}],
{k, 0, 2 Pi, Pi/12}] // ListAnimate,
{{v, {1, 0, 0}}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}}] • Thank you very much, that was exactly what I needed :) – mstechly Mar 18 '15 at 20:28

My understanding of the question is that you are not interested in doing a rotation of the 3D object inside the 3D scene, but instead want to do a 2D rotation of the displayed Graphics3D, as if the latter were just another 2D Graphics element.Then you want to combine the result with additional 2D Graphics using Show.

For this task, the right tool is simply to use Inset. Here is an example:

Show[
Graphics[
Inset[
Rotate[
Graphics3D[myBox, ImageSize -> 300], Pi/4, {0, 0}] ]
],
ImageSize -> 300
] Here I used the same commands as in the question, except to change the rotation angle to something more obviously "rotated". Then I specified ImageSize options for both the Graphics3D and the final Show. This, together with the options for Inset and the choice of PlotRange in Graphics, can be used to place the rotated object arbitrarily. Here I didn't include that because there were no other objects to be displayed. But the Show framework is all you needed, and from there everything works as it always does in Show.

In principle, you can also do away with Rotate completely and use the options of Inset directly to rotate the content in 2D.

• Looks better if you add the option Boxed -> False option to Graphics3D. You know that, but I think it's worth pointing out to our readers with little Mathematica experience. – m_goldberg Mar 18 '15 at 13:34
• I probably still don't understand something. If I want to show it with second box it doesn't work: myBox2 = Cuboid[{-40, 40, 0}, {40, 60, 10}]; Show[Graphics[Inset[Rotate[Graphics3D[myBox1], Pi/4, {0, 0}]]], myBox2] – mstechly Mar 18 '15 at 20:31
• Sorry for the second comment, some PC problems. It should have been: Show[Graphics[Inset[Rotate[Graphics3D[myBox1], Pi/4, {0, 0}]]], Graphics3D[myBox2]] @m_goldberg answer helps, but I would like to know why there is an error if I use Show. – mstechly Mar 18 '15 at 20:43
• You can't combine 2D and 3D graphics within a single Show. It's either one or the other, so you have to apply the conversion to 2D to both objects. – Jens Mar 18 '15 at 21:05

myBox = Cuboid[{-40, 40, 0}, {40, 60, 10}];

Show@MapAt[Rotate[#, Pi/4, {0, 0, 1}, {0, 0, 0}] &, Graphics3D[myBox], {1}]


is a good method.

I have an another way to solve this problem.

myBox = Graphics3D[Cuboid[{-40, 40, 0}, {40, 60, 10}]];

Graphics3D[Rotate[myBox[], Pi/4, {0, 0, 1}, {0, 0, 0}]]


Compare with the above method, it is simpler and easier to understand.

• Keep in mind that myBox[] leave all options myBox could've had while MapAt preserves them – Kuba Jan 18 '18 at 12:13
• Yeah, it is mainly used for Show[ the rotation of the graphics ]. Except for rotation, if you want to do something else. It is not necessarily the best. – laizhianzhi Jan 19 '18 at 0:48