# Tikz 3d trimetric view coordinate calculation bug

I'm trying to draw a line in the x-y-plane and circles in the y-z-plane at constant x position.

Problem is, that the circle is far out of position (x-coordinate of center point of the circle is exactly the x-coordinate of the end of the line drawn from origin, but the circle is drawn elsewhere).

MWE:

\documentclass{standalone}
\usepackage{tikz}
%\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,3d}

% see http://tex.stackexchange.com/a/48776/70600
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother

% Drawing Views
\tikzstyle{trimetric}=[x={(0.926cm,-0.207cm)},y={(0cm,0.837cm)},z={(-0.378cm,-0.507cm)}]

\begin{document}
\begin{tikzpicture}[trimetric, scale=0.1]

\draw[dashed] (-1, 0,  0) -- (1, 0,  0);
\draw[dashed] (0, -1,  0) -- (0, 1,  0);
\draw[dashed] (0, 0,  -1) -- (0, 0,  1);

\coordinate (O) at (0, 0, 0);
\draw[-latex] (O) -- +(10, 0,  0) node [right] {$x$};
\draw[-latex] (O) -- +(0,  10, 0) node [left] {$y$};
\draw[-latex] (O) -- +(0,  0, 10 ) node [above] {$z$};

\begin{scope}[canvas is yz plane at x=120.0pt]
\filldraw circle (.01); % center point
\end{scope}

\begin{scope}[canvas is xy plane at z=0]
\draw[] (0.0pt, 0.0pt) -- (120.0pt, 120.0pt);
\end{scope}

\end{tikzpicture}

\end{document}


Result:

• Welcome to TeX.SX! The picture seems to fit with your description. What do you want to be different? – Andrew Swann Feb 25 '15 at 10:34
• x-position of circle canvas is yz plane at x=120.0pt doesn't fit the x-position of the end of the line drawn from origin \draw[] (0.0pt, 0.0pt) -- (120.0pt, 120.0pt) – user3116388 Feb 25 '15 at 11:30
• Watch out cm and pt conversion. 1cm=28.4pt. – ferahfeza Feb 25 '15 at 11:53
• @ferahfeza circle position canvas is yz plane at x=120.0pt is in pt and line coordinates \draw[] (0.0pt, 0.0pt) -- (120.0pt, 120.0pt) are in pt too. If I write it like this canvas is yz plane at x=120.0pt/28.4 then the circle is drawn correct. But why doesn't Tikz recognize the pt scaling? – user3116388 Feb 25 '15 at 12:04
• @user3116388, I don't know. TiKz experts can answer. – ferahfeza Feb 25 '15 at 13:45

The canvas ... at uses the internal \pgfpointxyz.

The latter function just takes numbers not dimensions; \pgfpointxyz{a}{b}{c} gives a times the x-vector plus b times the y-vector plus c times the z-vector.

In particular the units are ignored (rather than throwing an error).
If you write canvas is yz plane at x=120.0 you get the same result.

You need to specify x in your xyz system instead. As your x-vector has length .949cm you should write

x = 120.0*.949/28.4


to get the position corresponding to 120pt since 1cm=28.4pt.

\documentclass{standalone}
\usepackage{tikz}
%\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,3d}

% see http://tex.stackexchange.com/a/48776/70600
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother

% Drawing Views
\tikzstyle{trimetric}=[x={(0.926cm,-0.207cm)},y={(0cm,0.837cm)},z={(-0.378cm,-0.507cm)}]

\begin{document}
\begin{tikzpicture}[trimetric, scale=0.1]

\draw[dashed] (-1, 0,  0) -- (1, 0,  0);
\draw[dashed] (0, -1,  0) -- (0, 1,  0);
\draw[dashed] (0, 0,  -1) -- (0, 0,  1);

\coordinate (O) at (0, 0, 0);
\draw[-latex] (O) -- +(10, 0,  0) node [right] {$x$};
\draw[-latex] (O) -- +(0,  10, 0) node [left] {$y$};
\draw[-latex] (O) -- +(0,  0, 10 ) node [above] {$z$};

\begin{scope}[canvas is yz plane at x=120.0*.949/28.4]
\filldraw circle (.01); % center point