# How to 3D rotate figures in display

I have a bunch of 2D figures which I like to use latex to display them in a row (side by side). Since the number of the figures is a lot I cannot show them all horizontally. For this I would like to have the option to rotate each slightly so that I can show all of them in the limited space. (like the option we have in Microsoft words)

-
What do you think about using the option width=xxcm for the command \includegraphics so that you can put some commands together. You can also use subfloat. – Sigur Sep 21 '12 at 23:21
Could you post a link to an example ppicture (someone with more reputation can that include this in your question.) – Tom Bombadil Sep 21 '12 at 23:47
I may be interpreting it incorrectly but what you are looking for in similar to this image, right? – mythealias Sep 22 '12 at 0:34
Switching to landscape is not an opportunity? – Speravir Sep 22 '12 at 0:50
what is the name of the feature in MS Word that you are referring to? (I am curious). – alfC Dec 11 '12 at 3:17

works only with latex->dvips->ps2pdf

\documentclass{article}
\usepackage{pst-3d,graphicx,multido}
\pagestyle{empty}
\begin{document}

\pspicture(12,5)
\multirput[lb](0.25,0)(2.5,0){5}{%
\psAffinTransform{0.7 0.3 0 1 0 0}{\includegraphics[scale=0.5]{xyz}}}
\endpspicture

\end{document}


0.7 0.3 0 1 0 0 are the six values for the transformation matrix. See http://en.wikipedia.org/wiki/Transformation_matrix

-
Awesome! thanks – kevin Sep 25 '12 at 17:51

In principle, the images are in 2D, thus rotation could be done only in 2D (x-y axis). But you obtain the effect of a Z rotation with the width and height options of \includegraphics. Therefore you can combine with these options:

Rotating with enviroments:

In the preamble \usepackage{rotating} allow three environments:

1. \begin{sideways} ... \end{sideways} rotate 90 degrees counterclockwise.
2. \begin{turn}{30} ... \end{turn} turn 30 degrees. Any positive or negative angle is allowed.
3. \begin{rotate}{30} ... \end{rotate} is like turn, but the former add some space to avoid overlapping with text.

Rotating without environments:

In the preamble \usepackage{graphicx} allow insert images, but also rotation, an you can, por example:

\includegraphics[width=2cm,height=3cm,angle=90]{image}

That is not the same that;

\includegraphics[angle=90,width=2cm,height=3cm]{image}

And also it you can consider the origin of the rotation:

\includegraphics[angle=30,origin=rt,width=2cm,height=3cm]{image}

There also more complicated solutions with packages tikz and pst-3d (in this case for .eps images only) that are described in How to rotate a picture in 3 dimensions?

-
maybe if there were a generalization of the rotate/turn package, maybe a 3D rotation (perspective) can be mocked up. – alfC Sep 22 '12 at 1:20

Do you mean something like this? The z-axis is slanted 10°, you can compute bigger values if you like.

## Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{3d}

\begin{document}

\begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,1cm)},z={(0.985cm,0.174cm)}]
\foreach \x in {1,...,5}
\node[canvas is zy plane at x=3*\x,draw,fill=white] at (0,0) {\includegraphics{book}};
\end{tikzpicture}

\end{document}


## Output

Edit 1: Now with different pictures of different sizes which are automatically spaced correctly, and easily changable orientation and length of the z-axis:

## Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{3d}

\begin{document}

\newcommand{\zangle}{20}
\newcommand{\zlength}{0.707}

\pgfmathsetmacro{\zx}{\zlength*cos(\zangle)}
\pgfmathsetmacro{\zy}{\zlength*sin(\zangle)}

\xdef\nextx{0}

\begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,1cm)},z={(\zx cm,\zy cm)}]
\foreach \f [count=\x] in {book,book2,book03,bookfour,book5}
{   \pgfmathsetmacro{\scalef}{1-\x/10}
\node[canvas is zy plane at x=\nextx,draw,fill=white,above right] (temp) at (0,0) {\includegraphics[scale=\scalef]{\f}};
\path (temp.east);
\pgfgetlastxy{\tempx}{\tempy}
\pgfmathsetmacro{\newx}{(\tempx+3)/28.453}
\xdef\nextx{\newx}
}
\end{tikzpicture}

\end{document}


## Output

-
+1 nice use of 3d library. – Harish Kumar Sep 23 '12 at 0:55
Is it possible to make lines convergent to simulate perspective? – alfC Sep 23 '12 at 1:12
@alfC: With TikZ I don't think so. – Tom Bombadil Sep 23 '12 at 1:14
this is great, thanks – kevin Sep 25 '12 at 17:52

Introducing \multirput instead of \multido that has been used in Herbert's answer.

\documentclass[pstricks,border=0pt]{standalone}
\usepackage{pst-3d,graphicx,multido}

\begin{document}

\multido{\n=1+1}{5}
{
\begin{pspicture}(4,3)
\multirput[bl](0,0)(0.62,0){\n}{\psAffinTransform{0.7 0.3 0 1 0 0}{\includegraphics[scale=0.246]{parishilton}}}
\end{pspicture}
}

\end{document}

-
Colector Nice, but most printed documents, and indeed most other documents, don't need animated effects. – Marc van Dongen Sep 23 '12 at 20:01
@MarcvanDongen: This is just an answer for pleasure. :-) – kiss my armpit Sep 24 '12 at 3:57