[Tex/LaTex] 3d arrows in tikz, or arrows that fit perspective

3darrowstikz-pgf

I'm trying to draw a 3d arrow in a 3d box (well lots of them actually). I've got the 3d box sorted, but the arrow doesn't look quite right. I've set up my axes/projection with:

\usepackage{tikz-3dplot}
\tdplotsetmaincoords{90}{90}
\tdplotsetrotatedcoords{0}{20}{70}

But the arrows don't obey the projection, they're 2d but don't look flat on the xy plane of the box, they're still flat with respect to the page. Does anyone know how to fix this?

Also, ideally I'm looking for a big 3d block arrows but I can't find any examples of this, any ideas?

Cheers.

Edit: As requested, here's a MWE:

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{>=latex}

\usepackage{tikz-3dplot}
\tdplotsetmaincoords{90}{90}
\tdplotsetrotatedcoords{0}{20}{70}

\begin{document}
\begin{tikzpicture}
\begin{scope}[fill={rgb:red,1;green,2;blue,10},fill opacity=0.4]
\draw [fill] (0,0,0)--(4,0,0)--(4,4,0)--(0,4,0)--cycle;
\draw [fill] (0,0,0)--(4,0,0)--(4,0,1)--(0,0,1)--cycle;
\draw [fill] (0,0,0)--(0,4,0)--(0,4,1)--(0,0,1)--cycle;
\draw [fill] (4,0,0)--(4,4,0)--(4,4,1)--(4,0,1)--cycle;
\draw [fill] (4,4,0)--(0,4,0)--(0,4,1)--(4,4,1)--cycle;
\draw [fill] (0,0,1)--(4,0,1)--(4,4,1)--(0,4,1)--cycle;
\end{scope}

\begin{scope}[->, ultra thick]
\draw[->] (2,2,1/2)--++(180:1.5)--++(0:3);
\end{scope}
\end{tikzpicture}
\end{document}

The result:

Hopefully you can see the problem, it doesn't look like the arrow is in the box, it's just been laid over the top.

Best Answer

You did not use the main coordinate that you've set up. To use it add [tdplot_main_coords] after \begin{tikzpicture}:

\begin{tikzpicture}[tdplot_main_coords]

If you do this, you will get blue rectangle with upward arrow from the center because the first parameter of \tdplotsetmaincoords is the angle (in degrees) through which the coordinate frame is rotated about x axis and the second parameter is rotated about z axis. Read tikz-3dplot documentation for more detailed explanation: http://mirrors.ctan.org/graphics/pgf/contrib/tikz-3dplot/tikz-3dplot_documentation.pdf

90-90 view

If you change \tdplotsetmaincoords{90}{90} to \tdplotsetmaincoords{100}{20} you will have this:

100-20 view