The TikZ library calc
can handle angle values:
\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc,intersections}
\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.1,0,1.2);
\draw[dashed] (a) -- (o);
\path (a) -- coordinate[pos=0.32] (b) (o);
\draw [thick,-{Straight Barb},orange] (a) -- ($(a)!1.2cm!90:(o)$) coordinate[label={[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) coordinate[label={[black]above right:d}] (d);
\draw (d) -- ($(c)!1.4cm!90:(a)$) coordinate (h);
\end{tikzpicture}
\end{document}
The output is:
Giving the angle in ($(c)!1.4cm!90:(a)$)
any positive or negative value, h
will always be in the (x,z) plane. In this case, the segment c
--h
should instead be vertical (parallel to y
) with respect to the (x,z) plane. So, how can the expression ($(c)!1.4cm!90:(a)$)
be modified in order to accomplish this?
As noticed in the comments, the above code does not use tikz-3dplot
. If, however, this package can provide a solution besides the traditional TikZ-only approach, it is ok and it can be used here.
The requested elucidation
This question is part of a series (1st question, 2nd question, 3rd question, 4th question, 5th question).
It is asked to depict a triad of mutually orthogonal vectors. One of them (b
, in the image above) is in the (x,z) plane in a general position and points to the origin; the plane generated by the vectors c
and d
should be highlighted. This triad should be depicted in a 3D space, and I should be able to arbitrarily rotate the space orientation. The end configuration of the axes should be the one shown in this answer, with the z
axis pointing right.
The tool through which this can be obtained is not important: it can be TikZ, as well as tikz-3dplot
, as well as a combination of them. Whether tikz-3dplot
must be used or not is part of the question: it can sometimes be the only tool, it can sometimes be just an alternative. So far, I don't know tikz-3dplot
enough.
All this summary wasn't written at the beginning because it was difficult, if not impossible, for me to work and make all the attempts on this picture directly. I was not able to provide any example or failed attempts regarding the general picture. The question would have certainly disapproved and criticized (as it was the 1st question).
The 2nd question was actually ambiguous, because I didn't notice the 45° line. Given that, I always tried to provide quick and precise questions, after making some attempts.
Thanks to all those who try to work on these images. I hope that this meets as much as possible the clarification that has been asked in the comments.
(c)
and(a)
were points in a 3d space there would not be such point as($(c)!1.4cm!90:(a)$)
because in 3d there is no sens to say "rotate around (c) at 90° in the positive direction". If you want a point to be1.4cm
above(c)
you can use([yshift=1.4cm]c)
. A point with "coordinate"(x,y,z)
is a 2d point that is a (non orthogonal) projection of this 3d point. – Kpym Apr 24 '18 at 12:33tikz-3dplot
, but not using it. With this package, you can work in any plane, and then statement "rotate around (c) by 90° in the positive direction" does make sense. (Note that I never used this calc syntax in tikz-3dplot my self, so I am not 100% sure that this is a good advice. The command\draw (a) rectangle (b);
does not yield a rotated rectangle.) – user121799 Apr 24 '18 at 13:40(c)
as vector/axis or point. In the latter case, you are right, but not on the former. – user121799 Apr 24 '18 at 14:37(a)
in two macros\x
and\z
then the coordinates of(c)
would be (a multiple of)(-\z‚0‚\x)
. – Kpym Apr 26 '18 at 10:57