2

What follows was tested with tikz-3dplot, but it could also regard the 2D TikZ as well.

This code:

\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}

\draw[->] (-3,0,0) -- (3,0,0) node[below right] {$x$};
\draw[->] (0,-3,0) -- (0,3,0) node[above right] {$y$};
\draw[->] (0,0,-3) -- (0,0,3) node[below right] {$z$};

\coordinate (o) at (0,0,0);
\coordinate (a) at (3.6,0,4.5);

\draw[dashed] (a) -- (o);

\path (a) -- coordinate[pos=0.32] (b) (o);
\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$) node[black,above left] (c) {c};
\draw [thick,-{Straight Barb},gray] (a) -- node[pos=0.7, below=0.35em] {b} (b);
\draw [thick,-{Straight Barb},red] (a) -- ([shift={(0,1.5,0)}]a) node[black,below right] (d) {d};

\draw ([shift={(0,0,-2.1)}]a) -- ([shift={(0,0,2.1)}]a);

\end{tikzpicture}

\end{document}

produces this output:

enter image description here

The black simple line

\draw ([shift={(0,0,-2.1)}]a) -- ([shift={(0,0,2.1)}]a);

should overlap the arrowed orange segment

\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$) node[black,above left] (c) {c};

Why it doesn't? Maybe I misunderstood the ($(a)!1.2cm!90:(o)$) expression?

BowPark
  • 1,213
  • 1
    Your point (a) is not orthogonal to the z-axis. Check your drawing by replacing its definition by \coordinate (a) at ([rotate=90]0,0,4.5);. – Kpym Apr 20 '18 at 18:10
  • Just for curiosity: you load tikz-3dplot but I can't see where you use it. If I am not mistaken, you'd need something like \tdplotsetmaincoords{70}{70} \begin{tikzpicture}[tdplot_main_coords] for that. So I'd like to suggest that you really cook this down to a 2D example (if possible) and verify that removing tikz-3dplot doesn't change the story. –  Apr 20 '18 at 18:10
  • @Kpym @marmot You are both right. Point a wasn't meant to be in the negative 45-degrees line, but thank you for your observations, which have been useful. Another issue is about this plot, but I'll write it on a separate question, in order to avoid confusion. – BowPark Apr 23 '18 at 15:26

1 Answers1

2

As mentioned in my comment, you are not using the tikz-3dplot library at all. Then if you say 90 degrees, you'd have to append the information in which plane. TikZ by default takes this to be the x-y plane. And, by default, the z-direction is along the negative 45-degree line. If you wish to change that, you'd really need to load tikz-3dplot (or the 3d library). The position of a was accidentally close to another 45 degree line, that's the reason why it accidentally almost worked. If you put a on that 45 degree line, it really works, but just because you happen to adjust things.

enter image description here

\documentclass[border=2mm,tikz]{standalone}
%\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,calc}

\begin{document}

\begin{tikzpicture}

\draw[->] (-3,0,0) -- (3,0,0) node[below right] {$x$};
\draw[->] (0,-3,0) -- (0,3,0) node[above right] {$y$};
\draw[->] (0,0,-3) -- (0,0,3) node[below right] {$z$};

\coordinate (o) at (0,0,0);
\coordinate (a) at (2.4,-2.4,0);

\draw[dashed] (a) -- (o);

\path (a) -- coordinate[pos=0.32] (b) (o);
\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$) node[black,above left] (c) {c};
\draw [thick,-{Straight Barb},gray] (a) -- node[pos=0.7, below=0.35em] {b} (b);
\draw [thick,-{Straight Barb},red] (a) -- ([shift={(0,1.5,0)}]a) node[black,below right] (d) {d};

\draw[blue] ([shift={(0,0,-2.1)}]a) -- ([shift={(0,0,2.1)}]a);

\end{tikzpicture}

\end{document}

I guess that what Kpym meant by the statement that a is not orthogonal to the z-axis is that it did not happen to lie on that 45 degree line.

  • I erroneously thought that the simple use of 3 coordinates instead of 2 was already triggering tikz-3dplot, which instead is about rotations of the system of coordinates and other more advanced flavours. – BowPark Apr 23 '18 at 15:24