3

I'm trying to make a nice picture from a simple surface of revolution. Here my text:

\documentclass[a4paper,11pt]{article}
\usepackage{ifthen}
\usepackage{tikz, tkz-euclide}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,intersections,through,backgrounds,through, shapes, decorations}
\usepackage{calc}
\usepackage{pgffor}

\tdplotsetmaincoords{60}{30}
\begin{tikzpicture}
        [tdplot_main_coords,
        cube/.style={gray},
        basis/.style={->,blue,very thick},
        grid/.style={very thin,gray},
        axis/.style={->,red,thick},
        vlak/.style= {black, very thin},
        arce/.style= {very thin,black},
        scale=3]

\draw[cube, very thick, blue] (-1,0,{-2/3}) -- (1,0,{2/3}) node[anchor=west]{$l$} ;
\draw[axis] (-1.5,0,0) -- (1.5,0,0) node[anchor=west]{$x$};
\draw[axis] (0,-1.5,0) -- (0,1.5,0) node[anchor=west]{$y$};
\draw[axis] (0,0,-1.5) -- (0,0,1.5) node[anchor=east]{$z$};
\foreach \y in {-0.7,-0.68,...,0.7}{
\tdplotdrawarc[vlak]{(0,0,\y)}{\y*3/2}{0}{360};}
\end{tikzpicture}

Works perfect, no problem: enter image description here

But when I try to do the same in a different direction:

\tdplotsetmaincoords{60}{30}
\begin{tikzpicture}
        [tdplot_main_coords,
        cube/.style={gray},
        basis/.style={->,blue,very thick},
        grid/.style={very thin,gray},
        axis/.style={->,red,thick},
        vlak/.style= {black, very thin},
        arce/.style= {very thin,black},
        scale=3]

\draw[cube, very thick, blue] (-1,0,{-2/3}) -- (1,0,{2/3}) node[anchor=west]{$l$} ;
\draw[axis] (-1.5,0,0) -- (1.5,0,0) node[anchor=west]{$x$};
\draw[axis] (0,-1.5,0) -- (0,1.5,0) node[anchor=west]{$y$};
\draw[axis] (0,0,-1.5) -- (0,0,1.5) node[anchor=east]{$z$};
\foreach \y in {-1,-0.95,...,1}{
\tdplotdrawarc[vlak,tdplot_rotated_coords]{(\y,0,0)}{\y*2/3}{0}{360};
\end{tikzpicture}   

It went wrong.

enter image description here

I know \tdplotdrawarc[vlak]{(0,0,\y)}{\y*3/2}{0}{360};} works only in the x-y surface, but is there a way to use it in other surfaces?

Please help Bert

3

Unfortunately, you forgot \begin{document}, \end{document}and the syntax for\tdplotdrawarc` is not correct. And then it is clear what happens: you draw the arcs in the incorrect planes. To fix that, just rotate the "working" arcs.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{30}
\begin{tikzpicture}
        [tdplot_main_coords,
        cube/.style={gray},
        basis/.style={->,blue,very thick},
        grid/.style={very thin,gray},
        axis/.style={->,red,thick},
        vlak/.style= {black, very thin},
        arce/.style= {very thin,black},
        scale=3]

\draw[cube, very thick, blue] (-1,0,{-2/3}) -- (1,0,{2/3}) node[anchor=west]{$l$} ;
\draw[axis] (-1.5,0,0) -- (1.5,0,0) node[anchor=west]{$x$};
\draw[axis] (0,-1.5,0) -- (0,1.5,0) node[anchor=west]{$y$};
\draw[axis] (0,0,-1.5) -- (0,0,1.5) node[anchor=east]{$z$};
\tdplotsetrotatedcoords{0}{90}{0}
\begin{scope}[tdplot_rotated_coords]
 \foreach \y in {-0.7,-0.68,...,0.7}
 {\tdplotdrawarc[vlak]{(0,0,\y)}{\y*3/2}{0}{360}{}{}{}}
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

And here is the mandatory animation.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{60}{30}
\foreach \X in {0,5,...,175}
{\begin{tikzpicture}
        [tdplot_main_coords,
        cube/.style={gray},
        basis/.style={->,blue,very thick},
        grid/.style={very thin,gray},
        axis/.style={->,red,thick},
        vlak/.style= {black, very thin},
        arce/.style= {very thin,black},
        scale=3]

\draw[cube, very thick, blue] (-1,0,{-2/3}) -- (1,0,{2/3}) node[anchor=west]{$l$} ;
\draw[axis] (-1.5,0,0) -- (1.5,0,0) node[anchor=west]{$x$};
\draw[axis] (0,-1.5,0) -- (0,1.5,0) node[anchor=west]{$y$};
\draw[axis] (0,0,-1.5) -- (0,0,1.5) node[anchor=east]{$z$};
\tdplotsetrotatedcoords{0}{\X}{0}
\begin{scope}[tdplot_rotated_coords]
 \foreach \y in {-0.7,-0.68,...,0.7}
 {\tdplotdrawarc[vlak]{(0,0,\y)}{\y*3/2}{0}{360}{}{}{}}
\end{scope}
\end{tikzpicture}}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.