3차원 고리 그리기

3차원 고리 그리기

이 그림을 그리는 데 도움을 주실 수 있나요?

\documentclass[10pt]{standalone}

\usepackage{tikz}

\usepackage{circuitikz}

\begin{document}
    
    \begin{circuitikz}
        %upper ring
        \draw[fill=yellow](0,0) ellipse(2 cm and .7 cm);
        \draw[fill=white](0,0) ellipse(1.67 cm and .5 cm);
        
        \def\d{1.5}
        \draw(2,0)--++(0,-\d) coordinate(X1);
        \draw(-2,0)--++(0,-\d) coordinate(X2);
        
        \draw (X1) arc(0:-180:2cm and .6cm);
        
        
        
        %lower ring
        
            \draw[fill=yellow](0,-4) ellipse(2 cm and .7 cm);
        \draw[fill=white](0,-4) ellipse(1.67 cm and .5 cm);
        
        \def\d{1.95}
        \draw(2,-4)--++(0,-\d) coordinate(X1a);
        \draw(-2,-4)--++(0,-\d) coordinate(X2a);
        
        \draw (X1a) arc(0:-180:2cm and .6cm);
        
        \foreach\y in{-4.1,-4.15, ..., -5.9} \draw(2,\y) arc(0:-180: 2cm and .6cm);
        
        
        %the cylinder 
        \draw[fill=yellow](0,3) ellipse(1.3 cm and .5 cm);
        \def\d{11}
        \draw(1.3,3)--++(0,-\d) coordinate(X1);
        \draw(-1.3,3)--++(0,-\d) coordinate(X2);
        
        \draw (X1) arc(0:-180:1.3cm and .5cm);
        
     
     %circuit
     
     \draw(2,-4.5)--(2.7,-4.5)--++(0,1.5)--++(.5,0)--++(.8,.3);
     
\draw(2,-5.5)--(2.7,-5.5)--++(0,-1.5)--++(1,0);
        
        
        \coordinate(K1)at(5,-3);
        \coordinate(K0)at(5,-5);
        \coordinate(K2)at(5,-7);
        
        \draw(K1)to[battery] (K0);
        \draw(K0)to[battery] (K2);
        \draw(K1)--++(-.9,0);
        \draw(K2)--++(-1.3,0);
        
        %labels
\scriptsize     
    \draw(-2.3,2)node[left] {ferrous core}--++(1,-.2);
    \draw(-2.6,0)node[left] {aluminium ring}--++(.7,-.2);
    \draw(-2.6,-5)node[left] {coil of insulated wire}--++(.7,-.2);

    \end{circuitikz}

\end{document}

여기에 이미지 설명을 입력하세요

답변1

업데이트 2:

단색 버전도 있지만 강제 금속 색조를 유지합니다.

U2 결과:

여기에 이미지 설명을 입력하세요

U2 MWE:

\documentclass[border=3.14pt,tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\begin{document}
    \begin{tikzpicture}
        \def\alt{0.55}
        \def\Ring#1#2#3#4#5[#6]{%\Ring{position}{Radious}{widht}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#6--east) at (0:#2);
                \coordinate (#6--west) at (180:#2);
                \begin{pgfonlayer}{background layer}
                    \fill[fill=#5,even odd rule]
                        (0:#2)
                            arc (0:180:#2 and #2*\alt) 
                            -- (180:#2-#3) 
                            arc (180:0:#2-#3 and #2*\alt-#3*\alt);
                    \fill[draw,fill=#5]
                        (0:#2-#3)
                            arc (0:180:#2-#3 and #2*\alt-#3*\alt)
                            --++(0,-#4)
                            arc (180:0:#2-#3 and #2*\alt-#3*\alt)
                            -- cycle;
                    \draw[black](0:#2) arc (0:180:#2 and #2*\alt);
                    \draw[black](0:#2-#3) arc (0:180:#2-#3 and #2*\alt-#3*\alt);
                    \foreach \r in {45,135}{%forced radial shade
                        \foreach \i [evaluate={\s=20}] in {0,2,...,20}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)  -- (\r-\s+\i:#2-#3 and #2*\alt-#3*\alt)
                            arc (\r-\s+\i:\r+\s-\i:#2-#3 and #2*\alt-#3*\alt) -- cycle;
                        }
                    }                  
                \end{pgfonlayer}
                \begin{pgfonlayer}{foreground layer}
                    \fill[fill=#5,even odd rule]
                    (180-1:#2)
                        arc (180-1:360+1:#2 and #2*\alt)
                        -- (360+1:#2-#3)
                        arc (360+1:180-1:#2-#3 and #2*\alt-#3*\alt);
                    \fill[fill=#5]
                    (0:#2)
                        arc (360:180:#2 and #2*\alt)
                        --++(0,-#4)
                        arc (180:360:#2 and #2*\alt)
                        -- cycle;
                    \draw[black]
                        (0:#2)
                            --++(0,-#4)
                            arc (360:180:#2 and #2*\alt)
                            --++(0,#4);
                    \draw[black](180-1:#2) arc (180-1:360+1:#2 and #2*\alt);
                    \draw[black](180-1:#2-#3) arc (180-1:360+1:#2-#3 and #2*\alt-#3*\alt);
                    \foreach \r in {-45,-135}{%forced radial shade
                        \foreach \i [evaluate={\s=20}] in {0,2,...,20}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)  -- (\r-\s+\i:#2-#3 and #2*\alt-#3*\alt)
                            arc (\r-\s+\i:\r+\s-\i:#2-#3 and #2*\alt-#3*\alt) -- cycle;
                        }
                    }
                    \foreach \r in {-45,-90}{%forced radial side shade
                        \foreach \i [evaluate={\s=20}] in {0,2,...,20}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- ++(0,-#4) arc (\r-\s+\i:\r+\s-\i:#2 and #2*\alt) -- cycle;
                        }
                    }
                \end{pgfonlayer}    
            \end{scope}
            
        }
        
        \def\cilinder#1#2#3#4[#5]{%\cilinder{position}{Radious}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#5--east) at (0:#2);
                \coordinate (#5--west) at (180:#2);
                \fill[draw,fill=#4] (0:#2) arc (0:180:#2 and #2*\alt) -- ++ (0,-#3) arc (180:360:#2 and #2*\alt) -- cycle;
                \draw[black](0:#2) arc (0:360:#2 and #2*\alt);
                \foreach \r in {135,45,-45,-135}{%forced radial shade
                    \foreach \i [evaluate={\s=20}] in {0,2,...,20}{
                        \fill [black, fill opacity=1/50] 
                        (0,0) -- (\r+\s-\i:#2 and #2*\alt) 
                        arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- cycle;
                    }
                }
                \foreach \r in {-85,-135}{%forced radial side shade
                    \foreach \i [evaluate={\s=20}] in {0,2,...,20}{
                        \fill [black, fill opacity=1/50] 
                        (\r+\s-\i:#2 and #2*\alt) 
                        arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- ++(0,-#3) arc (\r-\s+\i:\r+\s-\i:#2 and #2*\alt) -- cycle;
                    }
                }
            \end{scope}
        }
        
        %The metals
        \cilinder{0,0}{1}{5}{white}[A]
        \Ring{0,-1}{1.8}{0.5}{1}{white}[B]
        \foreach \i in {1,...,18}{%Generate 18 named rings from CuRing-1 to CuRing-18
            \Ring{0,-4.5+0.06*\i}{1.1}{0.1}{0mm}{white}[C\i]
        }
        
        %The circuit
        \draw
        (C14--east)%From te coordinate east of CuRing-14
            -| ++(1,1)% Squared path first horizontal then vertical to x+1 and y+1 from previous coordinate (x,y)
            to [nos] ++(2,0)%Normal Open Switch from previous coordinate (x',y') to (x'+2,y'+0)
            to [battery] ++ (0,-1.4)
            to [battery] ++ (0,-1.4)
            -- ++ (-2,0)
            |- (C2--east);
        
        %labels
        \scriptsize
        \begin{pgfonlayer}{foreground layer}    
            \draw($(A--west)+(0.5,0)$) -- ++(-1,0.5)node[left] {ferrous core};
            \draw($(B--west)+(0.25,0)$) -- ++(-1.2,0.5)node[left] {Aluminium ring};
            \draw($(C18--west)+(0.07,0)$) -- ++(-1,0.5)node[left] {Coil of insulated wire};
        \end{pgfonlayer}     
                   
    \end{tikzpicture}   
\end{document}

업데이트:

흰색 채우기만 사용하는 옵션입니다.

U-결과:

여기에 이미지 설명을 입력하세요

U-MWE:

\documentclass[border=3.14pt,tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\begin{document}
    \begin{tikzpicture}
        \def\alt{0.55}
        \def\Ring#1#2#3#4#5[#6]{%\Ring{position}{Radious}{widht}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#6--east) at (0:#2);
                \coordinate (#6--west) at (180:#2);
                \begin{pgfonlayer}{background layer}
                    \fill[fill=#5,even odd rule]
                        (0:#2)
                            arc (0:180:#2 and #2*\alt) 
                            -- (180:#2-#3) 
                            arc (180:0:#2-#3 and #2*\alt-#3*\alt);
                    \fill[draw,fill=#5]
                        (0:#2-#3)
                            arc (0:180:#2-#3 and #2*\alt-#3*\alt)
                            --++(0,-#4)
                            arc (180:0:#2-#3 and #2*\alt-#3*\alt)
                            -- cycle;
                    \draw[black](0:#2) arc (0:180:#2 and #2*\alt);
                    \draw[black](0:#2-#3) arc (0:180:#2-#3 and #2*\alt-#3*\alt);                  
                \end{pgfonlayer}
                \begin{pgfonlayer}{foreground layer}
                    \fill[fill=#5,even odd rule]
                    (180-1:#2)
                        arc (180-1:360+1:#2 and #2*\alt)
                        -- (360+1:#2-#3)
                        arc (360+1:180-1:#2-#3 and #2*\alt-#3*\alt);
                    \fill[fill=#5]
                    (0:#2)
                        arc (360:180:#2 and #2*\alt)
                        --++(0,-#4)
                        arc (180:360:#2 and #2*\alt)
                        -- cycle;
                    \draw[black]
                        (0:#2)
                            --++(0,-#4)
                            arc (360:180:#2 and #2*\alt)
                            --++(0,#4);
                    \draw[black](180-1:#2) arc (180-1:360+1:#2 and #2*\alt);
                    \draw[black](180-1:#2-#3) arc (180-1:360+1:#2-#3 and #2*\alt-#3*\alt);
                \end{pgfonlayer}    
            \end{scope}
            
        }
        
        \def\cilinder#1#2#3#4[#5]{%\cilinder{position}{Radious}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#5--east) at (0:#2);
                \coordinate (#5--west) at (180:#2);
                \fill[draw,fill=#4] (0:#2) arc (0:180:#2 and #2*\alt) -- ++ (0,-#3) arc (180:360:#2 and #2*\alt) -- cycle;
                \draw[black](0:#2) arc (0:360:#2 and #2*\alt);
            \end{scope}
        }
        
        %The metals
        \cilinder{0,0}{1}{5}{white}[A]
        \Ring{0,-1}{1.8}{0.5}{1}{white}[B]
        \foreach \i in {1,...,18}{%Generate 18 named rings from CuRing-1 to CuRing-18
            \Ring{0,-4.5+0.06*\i}{1.1}{0.1}{0mm}{white}[C\i]
        }
        
        %The circuit
        \draw
        (C14--east)%From te coordinate east of CuRing-14
            -| ++(1,1)% Squared path first horizontal then vertical to x+1 and y+1 from previous coordinate (x,y)
            to [nos] ++(2,0)%Normal Open Switch from previous coordinate (x',y') to (x'+2,y'+0)
            to [battery] ++ (0,-1.4)
            to [battery] ++ (0,-1.4)
            -- ++ (-2,0)
            |- (C2--east);
        
        %labels
        \scriptsize
        \begin{pgfonlayer}{foreground layer}    
            \draw($(A--west)+(0.5,0)$) -- ++(-1,0.5)node[left] {ferrous core};
            \draw($(B--west)+(0.25,0)$) -- ++(-1.2,0.5)node[left] {Aluminium ring};
            \draw($(C18--west)+(0.07,0)$) -- ++(-1,0.5)node[left] {Coil of insulated wire};
        \end{pgfonlayer}     
                   
    \end{tikzpicture}   
\end{document}

글쎄, 실제로 모든 것을 그렸는데 해결해야 할 남은 것은 그것을 3D 객체로 표시하는 방법입니다. 그러기 위해서는 2개의 추가 레이어로 작업해야 합니다. 하나는 뒤에 있는 객체용이고 다른 하나는 앞에 있는 객체용입니다. 모든 것을 반복할 필요를 피하기 위해 사용 가능한 모든 유형의 음영을 추가했습니다. 이를 링과 원통이라는 2개의 드로잉 개체로 그룹화했습니다. 몇 번의 시행착오를 거쳐 그림을 그릴 수 있도록 수정했습니다. 주어진 반경, 너비, 길이, 색상 및 이름을 사용하여 특정 위치에 배치합니다. 이렇게 하면 모든 항목을 다시 입력할 필요 없이 모든 개체에 음영을 적용할 수 있습니다. 링은 앞 레이어와 뒷 레이어에 있으므로 기본 레이어의 원통은 원통이 링의 중앙을 통과하는 듯한 느낌을 줍니다. 변수가 있어 \alt겉보기 3D 보기의 높이를 수정할 수 있습니다.

결과:

여기에 이미지 설명을 입력하세요

MWE: (참고: 컴파일에는 평소보다 몇 초가 더 걸릴 수 있습니다. 이는 강제 음영을 여러 번 반복하기 때문입니다)

\documentclass[border=3.14pt,tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\definecolor{cooper}{HTML}{CC9671}
\definecolor{aluminium}{HTML}{F1F1F2}
\definecolor{iron}{HTML}{646464}
\begin{document}
    \begin{tikzpicture}
        \def\alt{0.55}
        \def\Ring#1#2#3#4#5[#6]{%\Ring{position}{Radious}{widht}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#6--east) at (0:#2);
                \coordinate (#6--west) at (180:#2);
                \begin{pgfonlayer}{background layer}
                    \shade[left color=#5,even odd rule](0:#2) arc (0:180:#2 and #2*\alt) -- (180:#2-#3) arc (180:0:#2-#3 and #2*\alt-#3*\alt);
                    \shade[draw,right color=black,left color=#5]
                        (0:#2-#3)
                            arc (0:180:#2-#3 and #2*\alt-#3*\alt)
                            --++(0,-#4)
                            arc (180:0:#2-#3 and #2*\alt-#3*\alt)
                            -- cycle;
                    \draw[black](0:#2) arc (0:180:#2 and #2*\alt);
                    \draw[black](0:#2-#3) arc (0:180:#2-#3 and #2*\alt-#3*\alt);
                    \foreach \r in {45,135}{%forced radial shade
                        \foreach \i [evaluate={\s=30}] in {0,2,...,30}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)  -- (\r-\s+\i:#2-#3 and #2*\alt-#3*\alt)
                            arc (\r-\s+\i:\r+\s-\i:#2-#3 and #2*\alt-#3*\alt) -- cycle;
                        }
                    }                   
                \end{pgfonlayer}
                \begin{pgfonlayer}{foreground layer}
                    \shade[left color=#5,even odd rule]
                    (180-1:#2)
                        arc (180-1:360+1:#2 and #2*\alt)
                        -- (360+1:#2-#3)
                        arc (360+1:180-1:#2-#3 and #2*\alt-#3*\alt);
                    \shade[draw,left color=black!60!#5,middle color=#5,right color=#5!50!white]
                    (0:#2)
                        arc (360:180:#2 and #2*\alt)
                        --++(0,-#4)
                        arc (180:360:#2 and #2*\alt)
                        -- cycle;
                    \draw[black](180-1:#2) arc (180-1:360+1:#2 and #2*\alt);
                    \draw[black](180-1:#2-#3) arc (180-1:360+1:#2-#3 and #2*\alt-#3*\alt);
                    \foreach \r in {-45,-135}{%forced radial shade
                        \foreach \i [evaluate={\s=30}] in {0,2,...,30}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)  -- (\r-\s+\i:#2-#3 and #2*\alt-#3*\alt)
                            arc (\r-\s+\i:\r+\s-\i:#2-#3 and #2*\alt-#3*\alt) -- cycle;
                        }
                    }
                    \foreach \r in {-45,-90}{%forced radial side shade
                        \foreach \i [evaluate={\s=30}] in {0,2,...,30}{
                            \fill [black, fill opacity=1/50] 
                            (\r+\s-\i:#2 and #2*\alt) 
                            arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- ++(0,-#4) arc (\r-\s+\i:\r+\s-\i:#2 and #2*\alt) -- cycle;
                        }
                    }
                \end{pgfonlayer}    
            \end{scope}

        }
        
        \def\cilinder#1#2#3#4[#5]{%\cilinder{position}{Radious}{height}{color}[ID]
            \begin{scope}[shift={(#1)}]
                \coordinate (#5--east) at (0:#2);
                \coordinate (#5--west) at (180:#2);
                \shade[draw,left color=black!60!#4,middle color=#4,right color=#4!50!white] (0:#2) arc (0:180:#2 and #2*\alt) -- ++ (0,-#3) arc (180:360:#2 and #2*\alt) -- cycle;
                \shade[draw,left color=#4](0:#2) arc (0:360:#2 and #2*\alt);
                \foreach \r in {135,45,-45,-135}{%forced radial shade
                    \foreach \i [evaluate={\s=30}] in {0,2,...,30}{
                        \fill [black, fill opacity=1/50] 
                        (0,0) -- (\r+\s-\i:#2 and #2*\alt) 
                        arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- cycle;
                    }
                }
                \foreach \r in {-85,-135}{%forced radial side shade
                    \foreach \i [evaluate={\s=30}] in {0,2,...,30}{
                        \fill [black, fill opacity=1/50] 
                        (\r+\s-\i:#2 and #2*\alt) 
                        arc (\r+\s-\i:\r-\s+\i:#2 and #2*\alt)-- ++(0,-#3) arc (\r-\s+\i:\r+\s-\i:#2 and #2*\alt) -- cycle;
                    }
                }
                
            \end{scope}
        }
        
        %The metals
        \cilinder{0,0}{1}{5}{iron}[FeCore-1]
        \Ring{0,-1}{1.8}{0.5}{1}{aluminium}[AlRing-1]
        \foreach \i in {1,...,18}{%Generate 18 named rings from CuRing-1 to CuRing-18
            \Ring{0,-4.5+0.06*\i}{1.1}{0.1}{0mm}{cooper}[CuRing-\i]
        }
            
        %The circuit
        \draw
        (CuRing-14--east)%From te coordinate east of CuRing-14
            -| ++(1,1)% Squared path first horizontal then vertical to x+1 and y+1 from previous coordinate (x,y)
            to [nos] ++(2,0)%Normal Open Switch from previous coordinate (x',y') to (x'+2,y'+0)
            to [battery] ++ (0,-1.4)
            to [battery] ++ (0,-1.4)
            -- ++ (-2,0)
            |- (CuRing-2--east);
    
        %labels
        \scriptsize
        \begin{pgfonlayer}{foreground layer}    
        \draw($(FeCore-1--west)+(0.5,0)$) -- ++(-1,0.5)node[left] {ferrous core};
        \draw($(AlRing-1--west)+(0.25,0)$) -- ++(-1.2,0.5)node[left] {Aluminium ring};
        \draw($(CuRing-18--west)+(0.07,0)$) -- ++(-1,0.5)node[left] {Coil of insulated wire};
        \end{pgfonlayer}        
    \end{tikzpicture}   
\end{document}

관련 정보