我正在尝试从一个简单的旋转表面制作出一幅漂亮的图片。这是我的文字:
\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}
但是当我尝试从不同的方向做同样的事情时:
\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}
一切都出错了。
我知道\tdplotdrawarc[vlak]{(0,0,\y)}{\y*3/2}{0}{360};}
它只在 xy 表面有效,但是有没有办法在其他表面使用它?
请帮助伯特
答案1
不幸的是,你忘记了\begin{document}
,\end{document}
并且的语法\tdplotdrawarc
不正确。然后很明显发生了什么:你在错误的平面上绘制了弧。要解决这个问题,只需旋转“工作”弧。
\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}
这是强制动画。
\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}