4

I want to draw a spiral to denote the orientation of a tetrahedron (either left or right handed). I played around with using a helix, but I'm not very happy with the look. Here is my attempt.

\documentclass{article}
\usepackage{pgfplots,tikz}

\begin{document}
\begin{tikzpicture}[scale=.75]
\coordinate (a) at (4,2.5);
\coordinate (b) at (3,.8);
\coordinate (c) at (4.5,0);
\coordinate (d) at (5.3,1.2);
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above]{$v_3$} node[at end, below]{$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left]{$v_0$} node[at end, right]{$v_2$};
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\begin{axis} [
view={5}{50},
axis lines=none,
ymin=-2,
ymax=5,
xmin=-2,
xmax=2]
\addplot3 [very thick, ->, domain=.75*pi:4.25*pi, samples = 100, samples y=0] ({sin(deg(-x))}, {cos(deg(-x))}, {x});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

What I would prefer is a less uniform spiral that sticks up at the end, to really give the reader the idea that we are orienting the vertices of this tetrahedron with the ordering $(v_0,v_1,v_2,v_3)$. Here is my attempt to draw what I want using paint.

enter image description here

The idea is to give the helix/spiral variable curvature and torsion. I still want the smooth lines seen in the first picture.

Ideally, I would like some simple tikz code that uses arcs or bends rather than pgfplots. I would also like to be able to reverse the spiral and make it left-handed so that I can give an example of the same tetrahedron but with opposite orientation.

Alternatively, if someone can put the helix in the same tikzpicture as the tetrahedron and bring it a little closer to the right side of the tetrahedron I would be fine with that. I tried moving the helix around on my own and I couldn't figure out how to position it where I want it. The code for the helix was found at How to draw vertical spiral using TiKZ?.

My Solution Here is the plot I finally decided on in case anyone wants to use it.

\documentclass{article}
\usepackage{pgfplots,tikz}

\begin{document}
\begin{tikzpicture}[scale=.75]
\coordinate (a) at (4,2.5);
\coordinate (b) at (3,.8);
\coordinate (c) at (4.5,0);
\coordinate (d) at (5.3,1.2);
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above]{$v_3$} node[at end, below]{$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left]{$v_0$} node[at end, right]{$v_2$};
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\begin{axis} [
view={0}{75},
axis lines=none,
ymin=-2,
ymax=5,
xmin=-2,
xmax=2]
\addplot3 [very thick, ->, domain=2.9*pi:6*pi, samples = 100, samples y=0]
          ({.5*sin(deg(-x))}, {.5*cos(deg(-x))+1}, {2*x*x*x});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2 Answers 2

7

Here is how I would do it.

\documentclass{article}
\usepackage{pgfplots,tikz}

\begin{document}

\begin{tikzpicture}[scale=.75]
\coordinate (a) at (4,2.5);
\coordinate (b) at (3,.8);
\coordinate (c) at (4.5,0);
\coordinate (d) at (5.3,1.2);
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above](v3){$v_3$} node[at end, below](v1){$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left](v0){$v_0$} node[at end, right](v2){$v_2$};
\draw[gray,opacity=0.5,-latex] (v0.south) to[out=-75,in=180] (v1.west);
\draw[gray,opacity=0.5,-latex] (v1.east) to[out=0,in=-90] (v2.south);
\draw[gray,opacity=0.5,-latex] (v2.north) to[out=90,in=0] (v3.east);
\end{tikzpicture}

\end{document}

enter image description here

Now for your question in the comment: You set view={5}{50} which defines the viewing angles as explained in the pgfplots manual. Changing it will also lead to a different picture. And all I did was to change the curve by replacing the constant velocity in z-direction to something in which this velocity has some hills.

As I mentioned, you might benefit from drawing all things in one picture with tikz-3dplot. This makes things more intuitive because you then know at least what the directions mean. In order to see them more clearly, I drew the axes but commented them out, all you need to do is to uncomment them. And you could play with the angles in \tdplotsetmaincoords{60}{110} in order to see what the view does. Try e.g. \tdplotsetmaincoords{60}{70}. Notice, however, that you cannot overdo it since these are no real 3D pictures. That is, if you rotate too much, you'll discover that some faces have not been drawn

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz}   
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\coordinate (a) at (0, 0, {sqrt(3/2)/2});
\coordinate (b) at ({-1/(2*sqrt(3))}, -1/2,  {-1/(2*sqrt(6))});
\coordinate (c) at ({1/sqrt(3)}, 0, {-1/(2*sqrt(6))});
\coordinate (d) at ({-1/(2*sqrt(3))},   1/2, {-1/(2*sqrt(6))}); 
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above]{$v_3$} node[at end, below]{$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left]{$v_0$} node[at end, right]{$v_2$};
\draw plot[variable=\x,samples=100,domain=.75*pi:4.25*pi]
({0.5*sin(deg(-\x))}, {0.5*cos(deg(-\x))+1.5}, 
{(\x/(4.25*pi))^2});
% % Uncomment these lines if you want to know where x', y' and z' point to
% \draw[-latex,blue] (-1.5,0,0) -- (1.5,0,0)  node[above right]  {$x'$};
% \draw[-latex,blue] (0,-1.5,0) -- (0,1.5,0)  node[below] {$y'$};
% \draw[-latex,blue] (0,0,-1.5) -- (0,0,1.5)  node[above left]  {$z'$};
\end{tikzpicture}
\end{document}

enter image description here

ORIGINAL ANSWER: Apart from the possibility to change the viewing angle, you could play with the parametrization:

\documentclass{article}
\usepackage{pgfplots,tikz}

\begin{document}

\begin{tikzpicture}[scale=.75]
\coordinate (a) at (4,2.5);
\coordinate (b) at (3,.8);
\coordinate (c) at (4.5,0);
\coordinate (d) at (5.3,1.2);
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above]{$v_3$} node[at end, below]{$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left]{$v_0$} node[at end, right]{$v_2$};
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\begin{axis} [
view={5}{50},
axis lines=none,
ymin=-2,
ymax=5,
xmin=-2,
xmax=2]
\addplot3 [very thick, ->, domain=.75*pi:4.25*pi, samples = 100, samples y=0] ({sin(deg(-x))}, {cos(deg(-x))}, 
{x+4*sin(deg(x+1.5))+1*x*x*x*x});
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

3
  • Would you be able to point me to some helpful documentation that explains the different pieces of the axis environment? For example, I don't know what view means, or what samples are, or what your edit of {x+4*sin(deg(x+1.5))+1*xxx*x} means. Without knowing what I'm doing it's hard to play around and produce what I want, mostly I end up making changes that I don't want and not understanding why I didn't produce what I wanted. May 8, 2018 at 19:31
  • @rosterherik I try to explain it in the revised answer. I was just guessing a function {x+4*sin(deg(x+1.5))+1*x*x*x*x} that resembles a bit your figure. (Why x*x*x*x? Simply because x^2 and x^3 didn't look so good and in TikZ sometimes x^2 gave a weird result.) You do not need pgfplots for this. The things could all be done very nicely with tikz-3dplot. But anyway I added a proposal which may make the spiral unnecessary, what do you think?
    – user121799
    May 8, 2018 at 19:40
  • I'm sticking with the spiral because it's consistent with my sources, but your answer was very helpful in showing me how to play around with the plots and giving me ideas. So thank you! I'll edit my question to show the plot I decided on. May 9, 2018 at 0:59
3

add some random value

\documentclass{article}
\usepackage{pgfplots,tikz}

\begin{document}
\begin{tikzpicture}[scale=.75]
\coordinate (a) at (4,2.5);
\coordinate (b) at (3,.8);
\coordinate (c) at (4.5,0);
\coordinate (d) at (5.3,1.2);
\draw[thick, fill=black!20] (a) -- (b) -- (c) -- (d) -- cycle;
\draw[very thick] (a) -- (c) node[at start, above]{$v_3$} node[at end, below]{$v_1$};
\draw[thick, dashed] (b) -- (d) node[at start, left]{$v_0$} node[at end, right]{$v_2$};
\end{tikzpicture}
\begin{tikzpicture}[scale=.5]
\begin{axis} [
view={5}{50},
axis lines=none,
ymin=-2,
ymax=5,
xmin=-2,
xmax=2]
\addplot3 [very thick, ->, domain=.75*pi:4.25*pi, samples = 100, samples y=0] ({sin(deg(-x))+0.1*rnd}, {cos(deg(-x))+0.1*rnd}, {x});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • I think you have misinterpreted my question, so I will edit to clarify. I want smooth curves, but I don't want the curvature and torsion of the helix to be constant. May 8, 2018 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .