TikZ 煎饼线圈围绕圆角矩形

TikZ 煎饼线圈围绕圆角矩形

如何在圆角矩形周围绘制薄饼线圈?目的如下:

hand drawn draft

我不知道...

编辑:

对不起!

我认为以 3d 形式绘制更好。

我是 Tikz 的新手......我解决问题的第一步是:

\documentclass[varwidth,border=7mm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\begin{scope}[
    yshift=-130,every node/.append style={
    yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
                            ]

    \draw[black,very thick,fill=gray!30] (0,0) rectangle (4,4);


    \end{scope}


    \begin{scope}[
     yshift=-100,every node/.append style={
     yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
             ]

                \draw[gray!80,very thick,fill=gray!30] (0,0) rectangle (4,4);

                                \draw[black,thick] (1.5,1) rectangle (3,1.2);
                                \draw[black,thick] (1.5,2) rectangle (3,2.2);
                                \draw[black,thick] (1.5,3) rectangle (3,3.2);
                                \draw[black,thick] (1.5,4) rectangle (3,4.2);


        \end{scope}


 \begin{scope}
                    [ yshift=-220]

            %\draw[black,very thick] (0,0) rectangle (2,2);

\end{scope}

  \end{tikzpicture}
\end{document}

你现在能帮助我吗?

数据

hand drawn 3D draft

决赛

是否可以使用图中的线圈,以便连接器位于中间?我认为这看起来更好,然后线圈 2、4、6... 就是线圈 1、3、5... 但旋转到 180 度。

例如:线圈 1 的端口 2 将连接到线圈 2 的端口 2,然后线圈 2 的端口 1 将连接到线圈 3 的端口 1 ...

我怎样才能减少线路距离?

enter image description here

答案1

几乎(?)最终(?)版本

\documentclass[varwidth,border=7mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfkeys{/tikz/.cd,
    pancake distance/.store in=\PancakeDistance,
    pancake distance=2pt,
    pancake final node/.store in=\PancakeLastNode,
    pancake final node=finalPC,
    pancake initial pos/.store in=\PancakeIniPos,
    pancake initial pos=0.5,
    pancake final pos/.store in=\PancakeFinPos,
    pancake final pos=0.5,
    pancake/.style={rounded corners}
}
\newcommand{\DrawPancake}[4][]{
 \xdef\Pancake{($(#2)!\PancakeIniPos!(#2-|#3)$) 
  to[bend right,rounded corners=0] ($([xshift=2*\PancakeDistance,yshift=-2*\PancakeDistance]#2)!\PancakeIniPos!(#2-|#3)$)}
 \foreach \Z [evaluate={\nextZ=int(\Z+1)}] in {1,...,#4}
  {\pgfmathtruncatemacro{\prevZ}{int(\Z-1)}
  \coordinate (#2-\Z) at ([xshift=-\prevZ*\PancakeDistance,yshift=-\Z*\PancakeDistance]#2);
  \coordinate (#2-\nextZ) at ([xshift=-\Z*\PancakeDistance,yshift=-\nextZ*\PancakeDistance]#2);
  \coordinate (#3-\Z) at ([xshift=\Z*\PancakeDistance,yshift=\Z*\PancakeDistance]#3);
  \xdef\Pancake{\Pancake -- (#2-\Z -| #3-\Z) -- (#3-\Z) -- (#3-\Z -| #2-\nextZ) --
  (#2-\nextZ)}
  }
  \pgfmathtruncatemacro{\nextZ}{int(#4+1)}
  \xdef\Pancake{\Pancake -- ($(#2-\nextZ)!\PancakeFinPos!(#2-\nextZ -|#3)$) }
 \draw[pancake,#1] \Pancake coordinate (\PancakeLastNode);
}
\begin{document}

\begin{tikzpicture}

\begin{scope}[
    yshift=-130,every node/.append style={
    yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
                            ]

    \draw[black,very thick,fill=gray!30] (0,0) rectangle (4,4);


    \end{scope}


    \begin{scope}[
     yshift=-100,every node/.append style={
     yslant=0.5,xslant=-1.3},yslant=0.5,xslant=-1.3
             ]

     \draw[gray!80,very thick,fill=gray!30] (0,0) rectangle (4,4);

     \begin{scope}[yscale=-1,xscale=-1]
     \draw[black,thick] (-3,-1.2) coordinate(X) rectangle (-1.5,-1) coordinate(Y);
     \tikzset{pancake final node=myPC1}
     \DrawPancake{X}{Y}{4}
     \end{scope}
     \draw[black,thick] (1.5,2) coordinate(X) rectangle (3,2.2) coordinate(Y);
     \tikzset{pancake final node=myPC2}
     \DrawPancake{X}{Y}{4}
     \draw (myPC1)--(myPC2);
     \draw[black,thick] (1.5,3) coordinate (X) rectangle (3,3.2) coordinate (Y);
     \DrawPancake[dashed,blue]{X}{Y}{5}
     \draw[black,thick] (1.5,4) coordinate (X) rectangle (3,4.2) coordinate (Y);
     \tikzset{pancake distance=1.5pt}
     \DrawPancake[red]{X}{Y}{6}

        \end{scope}


 \begin{scope}
                    [ yshift=-220]

            %\draw[black,very thick] (0,0) rectangle (2,2);

\end{scope}

  \end{tikzpicture}
\end{document}

enter image description here

在更新中,我解决了几个额外的要求,也使代码更加 Ti唷。

相关内容