# How to rotate a picture in 3 dimensions?

I have a picture like this:

I want to use this picture rotated like this (inline with the text as well as separately):

Is there a way to achieve this?

-

Also TikZ/PGF offers some slightly cumbersome transformation possibilities avoiding the .eps path. I have used the logo.png file.

\documentclass[10pt]{article}
\usepackage{tikz}
\pgfdeclareimage[height=2cm]{thelogo}{logo}
\newcommand{\somelogomacro}{
\tikz[baseline=(current bounding box.base)]{
\pgftext[at=\pgfpointorigin,y=-0.4cm]{
\pgflowlevel{\pgftransformcm{1}{0.7}{0}{1}{\pgfpoint{0}{0}}}
\pgfuseimage{thelogo}
}
}
}
\author{Ricky Fineman}
\title{\somelogomacro \hspace{-2mm}\LARGE Physics Related Title}
\begin{document}
\maketitle
\section{Unnecessary Show off}
Some literally skewed images.
\begin{figure}[!h]%
\begin{tikzpicture}
\pgftext[at=\pgfpointorigin]{
\pgflowlevel{\pgftransformcm{1}{0.7}{0}{1}{\pgfpoint{0}{0}}}
\pgfuseimage{thelogo}
}
\pgftext[at=\pgfpoint{3cm}{0}]{
\pgflowlevel{\pgftransformcm{1}{0.3}{0}{0.6}{\pgfpoint{0}{0}}}
\pgfuseimage{thelogo}
}
\pgftext[at=\pgfpoint{7cm}{0}]{
\pgflowlevel{\pgftransformcm{-1}{0.5}{-0.1}{-0.66}{\pgfpoint{0}{0}}}
\pgfuseimage{thelogo}
}
\end{tikzpicture}
\caption{Aye Aye Caption!!}%
\label{fig:logo}%
\end{figure}
\end{document}

The transformation is actually a matrix vector product. For more details you might want to check the manual. There is actually a small bug; the transformation matrix is actually the transposed version of what is given in the manual. If you don't want to be bothered about it just play around with the example transformations above. I have put the image into a macro called \somelogomacro which can be used in title or elsewhere. But for the title some little tweaks were necessary. Notice the leak from the bounding box because of the transformation. It is possible to fix it but I can't think of a quick fix at the moment. As usual, feel free to provide a solution if you happen to know it.

EDIT I have modified the bounding box a little but did not automate which is obvious once the transformation is set i.e. declaring the amount of skewness and applying it to the bounding box shift in the \pgfpointadd.

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\pgfdeclareimage[interpolate=true,height=2cm]{thelogo}{logo}

\newcommand{\somelogomacro}{
\tikz[baseline=(current bounding box.center)]{
\pgftext[base]{\pgflowlevel{\pgftransformcm{1}{0.707}{0}{1}{\pgfpoint{0}{0}}}\pgfuseimage{thelogo}}
\pgfpathrectanglecorners{
}{
}
\pgfusepath{use as bounding box}
}
}
\author{Ricky Fineman}
\title{\somelogomacro \LARGE Physics Related Title}
\begin{document}
\maketitle
\section{Unnecessary Show off}
Some literally skewed images.
\begin{figure}[!h]%
\centering
\somelogomacro
\caption{Aye Aye Caption!!}%
\label{fig:logo}%
\end{figure}
\end{document}

-
Great!. Is there any easier method? Using tikz is my preference. –  Harish Kumar Mar 12 '12 at 3:53
@HarishKumar Well, it is TikZ. The complicated replications are just to show you the possibilities. Can you elaborate on what is missing? –  percusse Mar 12 '12 at 3:57
The bug you were talking about and also the leak. I think to solve these one has to put in lots of energy. Your method is good and should be complete for general use. –  Harish Kumar Mar 12 '12 at 4:00
Ah, nevermind the first bug, it just requires to swap the middle two numbers (the second and the third arguments) in the \pgftransformcm command. The other one is still puzzles me. I think it is safer to put them into parbox or minipage etc. environments. Let's wait a little to see what our gurus have to say about it. –  percusse Mar 12 '12 at 4:04
‘Aye Aye Caption’ made me laugh. :-) –  Harold Cavendish Mar 13 '12 at 11:08

To do this, you can use the pst-3d package. Here is an example:

\documentclass{article}
\usepackage{graphicx}

\usepackage{pstricks}
\usepackage{pst-3d}

\begin{document}

\begin{pspicture}(0,0)(3,3)

\psset{viewpoint=1 0.001 0.5}
\ThreeDput[normal= 1 3 0](0,1,1){\includegraphics[scale=0.5]{image.eps}}

\end{pspicture}

\end{document}

The result is

Just remember a few things:

1. The image should be .eps
2. The viewpoint parameters cannot be set to 0 (that is why I used a small number)

More info can be found in the pstricks manual (chapter X: Three Dimensional Graphics)

For your info, I used the convert command line utility to convert your image from the .png format to the .eps format. Other tools may be used. Inkscape is capable of converting to the .eps format.

Remark : As Percusse showed, there is a Tikz answer which can be used with pdflatex. Unfortunately for the moment it is not perfect (that may change of course). One possible way to continue using pdflatex is to convert (skew the image) using pstricks with the standalone documentclass. This will give you a pdf version of your transformed (skewed) image, which you can use in tikz and pdflatex. Of course this is not ideal, as it involves many small steps and manipulations.

-
Just information for others: Even using xelatex instead of the sequence latex-dvips-ps2pdf, the image must be in EPS format. I have just tried it. –  Weirdstress Function Mar 12 '12 at 3:05
pstricks has been already loaded by pst-3d so you need not to reload it again. Of course +1 for you! –  Weirdstress Function Mar 12 '12 at 3:06
@Frederic, Thanks for the good reply. But unfortunately, I want to stick to pdflatex and avoid usage of .eps. Is there any method? –  Harish Kumar Mar 12 '12 at 3:49
@Harish Kumar: see my (new) remark at end of answer –  Frédéric Mar 12 '12 at 4:12
@Frédéric Thank you. Though your answer is good for me, I can not marke two answers. I have upvoted your answer and my big thanks for your time. Thank you. –  Harish Kumar Mar 13 '12 at 10:40