绘制三维戒指

绘制三维戒指

你能帮忙画一下这个图吗?

\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-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个绘图对象,即环和圆柱体,经过反复试验后,我修复了它们,以便您可以根据给定的半径、宽度、长度、颜色和名称将它们绘制在特定位置,这样,我就可以将这些阴影应用于所有对象,而不必再次输入所有内容,并且由于环位于前后层,而圆柱体位于默认层,因此它们给人的印象是圆柱体穿过环的中间,有一个变量\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}

相关内容