绞线缠绕圆柱体

绞线缠绕圆柱体

我想在 TikZ 上绘制下图。但我不知道如何绘制缠绕线。我已经有圆柱体的代码,如下所示:

\documentclass[a4paper,12pt,reqno,english]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{graphicx}
\begin{document}

\begin{tikzpicture}
%cylinder
\draw [thick](-1.5,-2) -- (-1.5,2);
\draw [thick](+1.5,-2) -- (+1.5,2);
\draw [thick](-1.5,-2) arc (180:360:1.5 and 0.5);         
\draw[thick,dashed] (1.5,-2) arc (-2:180:1.5 and 0.5);  
\draw [thick](-1.5,+2) arc (180:360:1.5 and 0.5);         
\draw [thick](+1.5,+2) arc (-1.5:180:1.5 and 0.5);         
%hollow
\draw [thick](-1,-2) -- (-1,2);
\draw [thick](+1,-2) -- (+1,2);
\draw [thick](-1,-2) arc (180:360:1 and 0.25);
\draw[thick,dashed] (1,-2) arc (-1.65:180:1 and 0.25);
\draw [thick](-1,2) arc (180:360:1 and 0.25);
\draw [thick](+1,2) arc (-1:180:1 and 0.25);
\node[left,scale=0.7] at (-1,2) {$T_0$};
\node[right,scale=0.7] at (1.5,2) {$T_1$};
\fill[fill=blue] (1.5,2) circle (1.5pt);
\fill[fill=red] (-1,2) circle (1.5pt);

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

你可以用几个\foreach循环和 Ti 的帮助来实现这一点perspective等距(或其他)视图的Z库。

你还需要记住“图层”的顺序。首先绘制背景,然后绘制前景。

例如:

\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{perspective}

\begin{document}
\begin{tikzpicture}[isometric view]
% background
\foreach[count=\ii]\i in {blue,red} \foreach[count=\jj]\j in {dashed,solid}
{
   % radius
   \pgfmathsetmacro\r{3-\ii}
   % cylinder surface
   \fill[left color=white,right color=\i,fill opacity=0.1] (135:\r) arc (135:-45:\r) --++ (0,0,6) arc (-45:135:\r) -- cycle; 
   % ellipses
   \draw[\i,\j] (135:\r) + (0,0,6*\jj-6) arc (135:-45:\r); 
   % helices
   \foreach\z in {0,3}
     \draw[dashed,\i] plot[domain=180:360,samples=145] ({\r*cos(\x+45)},{-\r*sin(\x+45)},\z+\x/120);
}
% foreground
\foreach[count=\ii]\i in {red,blue}
{
   % cylinder surface
   \draw[\i,left color=\i,fill opacity=0.4] (135:\ii) arc (135:315:\ii) --++ (0,0,6) arc (315:135:\ii) -- cycle;
   % helices
   \foreach\z in {0,3}
     \draw[\i] plot[domain=0:180,samples=145] ({\ii*cos(\x+45)},{-\ii*sin(\x+45)},\z+\x/120);
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容