如何通过指定坐标绘制椭圆线?

如何通过指定坐标绘制椭圆线?

如何通过指定坐标绘制椭圆线?我\draw [red, dashed, line width=1px] (A) to[out=180, in=180] (C);手动为每个连接使用了简单的方法。连接的线虚线没有正确连接(因为椭圆由 A 点和 B 点的不同部分组成)。也许还有其他更有效的方法?

\documentclass[preview,border=12pt,12pt, varwidth=\maxdimen]{standalone}
\usepackage[americaninductors, europeanresistor]{circuitikz}
\usepackage{siunitx}
\usepackage{nccmath}
\begin{document}
    \sisetup{output-decimal-marker = {,}}
    
    \begin{circuitikz}
        
        \draw (0,0) coordinate(point0) to[R, l_=$\underline{Z}_1$, *-]  (0,4) coordinate(point1);
        
        \draw (0,4) to[L=$\underline{Z}_2$, label distance=2px, *-*] (4,4) coordinate(point2);
        
        \draw (4,4) to[L=$\underline{Z}_3$] (4,0);
        
        \draw (0,0) to[short, -*] (4,0);
        
        \draw (4,4) to[C=$\underline{Z}_5$, label distance=2px, -*] (8,4) coordinate(point3);
        
        \draw (8,4) to[R=$\underline{Z}_{67}$] (8,0);
        
        \draw (4,0) to[short] (8,0);
        
        
        \draw (0,4) -- (0,6) to[C=$\underline{Z}_4$, label distance=2px] (8,6) -- (8,4);
        
        
        \draw (point1) -- ++ (-2,0);
        \draw (point0) -- ++ (-2,0);
        
        
        \node[draw,rectangle,text centered,font=\bfseries] at ([xshift=-0.5cm,yshift=0.5cm] point1){1};
        \node[draw,rectangle,text centered,font=\bfseries] at ([yshift=0.5cm] point2){2};
        \node[draw,rectangle,text centered,font=\bfseries] at ([xshift=0.5cm,yshift=0.5cm] point3){3};
        \node[draw,rectangle,text centered,font=\bfseries] at (0,-0.5){4};


        \coordinate (A) at (1.5,5.2);
        \coordinate (B) at (6.5,5.2);
        \coordinate (C) at (4,0.8);

        \draw [red, dashed, line width=1px] (A) -- (B);
        \draw [red, dashed, line width=1px] (A) to[out=180, in=180] (C);
        \draw [red, dashed, line width=1px] (B) to[out=0, in=0] (C);


        
    \end{circuitikz}
\end{document}

在此处输入图片描述

答案1

如果您只是担心混乱的连接,那么诀窍就是将形状绘制为单一路径,这样虚线的图案就不会停止和重新开始,而是始终持续下去。

更整洁的连接

你不能完全地避免不一致,而无需确保虚线图案的长度均匀地分为路径的长度,但即使如此,单个路径也会大大改善结果。

\documentclass[preview,border=12pt,12pt, varwidth=\maxdimen]{standalone}
\usepackage[americaninductors, europeanresistor]{circuitikz}
\usepackage{siunitx}
\usepackage{nccmath}
\begin{document}
\sisetup{output-decimal-marker = {,}}
\begin{circuitikz}
  \draw (0,0) coordinate(point0) to[R, l_=$\underline{Z}_1$, *-]  (0,4) coordinate(point1);
  
  \draw (0,4) to[L=$\underline{Z}_2$, label distance=2px, *-*] (4,4) coordinate(point2);
  
  \draw (4,4) to[L=$\underline{Z}_3$] (4,0);
  
  \draw (0,0) to[short, -*] (4,0);
  
  \draw (4,4) to[C=$\underline{Z}_5$, label distance=2px, -*] (8,4) coordinate(point3);
  
  \draw (8,4) to[R=$\underline{Z}_{67}$] (8,0);
  
  \draw (4,0) to[short] (8,0);
  
  \draw (0,4) -- (0,6) to[C=$\underline{Z}_4$, label distance=2px] (8,6) -- (8,4);
  
  \draw (point1) -- ++ (-2,0);
  \draw (point0) -- ++ (-2,0);
  
  \node[draw,rectangle,text centered,font=\bfseries] at ([xshift=-0.5cm,yshift=0.5cm] point1){1};
  \node[draw,rectangle,text centered,font=\bfseries] at ([yshift=0.5cm] point2){2};
  \node[draw,rectangle,text centered,font=\bfseries] at ([xshift=0.5cm,yshift=0.5cm] point3){3};
  \node[draw,rectangle,text centered,font=\bfseries] at (0,-0.5){4};
  
  \coordinate (A) at (1.5,5.2);
  \coordinate (B) at (6.5,5.2);
  \coordinate (C) at (4,0.8);
  
  \draw [red, dashed, line width=1px] (A) -- (B) to[out=0, in=0] (C) to[out=180,in=180] cycle;
\end{circuitikz}
\end{document}

答案2

根据我对您的回答上一个问题并使用该fit库:

\documentclass[12pt,, margin=12pt]{standalone}
\usepackage[americaninductors, europeanresistor]{circuitikz}
    \usetikzlibrary{fit,
                    shapes.geometric}
\usepackage{siunitx}
\usepackage{nccmath}


\begin{document}
    \begin{circuitikz}[every label/.style = {label distance=2mm,
                                             draw, minimum size=1em, inner sep=1pt,
                                             font=\bfseries}
                        ]
    \ctikzset{capacitors/width=0.1, capacitors/height=0.5,
              label distance=3pt}
% 1. loop
\draw   (0,0)   coordinate[label=below:4]   (p0)
                to[R=$\underline{Z}_1$, *-] ++ (0, 4) coordinate[label=above left:1]  (p1)  
                to[L=$\underline{Z}_2$,*-*,
                   name=A]                  ++ (3, 0) coordinate[label=above:2] (p2)
                to[L=$\underline{Z}_3$, -*, 
                   name=B]                  ++ (0,-4)
% 2. loop
        (p2)    to[C=$\underline{Z}_5$, -*,
                   name=C]                  ++ (3, 0) coordinate[label=above right:3] (p3)
                to[R=$\underline{Z}_{67}$]  ++ (0,-4) 
                -- (p0)
% 3. loop
        (p1)    -- ++ (0,2) 
                to[C=$\underline{Z}_4$]     ++ (6, 0)
                to[short,-*]                ++ (0,-2)
% input connectors
        (p1)    to[short,*-o]   ++ (-2,0)
        (p0)    to[short,*-o]   ++ (-2,0);
% group of elements forming T circuit
\node [trapezium, minimum height=40mm, trapezium stretches, yscale=-1,
       draw=red, thick, densely dashed, rounded corners=5mm,
       inner xsep=-2ex, yshift=-2ex, 
       fit=(A.center) (B) (C.center)] {};
    \end{circuitikz}
\end{document}

在此处输入图片描述

相关内容