绘制圆柱体、圆柱壳和长方体

绘制圆柱体、圆柱壳和长方体

我想关注这张图片:

例子

我已经尝试过我的这个 MWE(拼凑):

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,perspective}
\makeatletter
\pgfmathdeclarefunction{az}{0}{\pgfmathparse{\pgf@view@az}}%
\pgfmathdeclarefunction{el}{0}{\pgfmathparse{\pgf@view@el}}%
\makeatother
\begin{document}
    \begin{tikzpicture}[bullet/.style={circle,fill,inner sep=1.5pt},
        pics/half cylinder shell/.style={code={
                \tikzset{half cylinder shell/.cd,#1}
                \def\pv##1{\pgfkeysvalueof{/tikz/half cylinder shell/##1}}%
                \pgfmathsetmacro{\alphacrit}{(az < 0 ? 180+az : az)} 
                \pgfmathsetmacro{\alphamax}{(az < 0 ? 180 : 0)} 
                \draw plot[variable=\t,domain=0:180,smooth]
                ({\pv{r}*cos(\t)},{\pv{r}*sin(\t)},-\pv{h}/2)
                plot[variable=\t,domain=180:0,smooth]
                ({\pv{r}*cos(\t)},{\pv{r}*sin(\t)},\pv{h}/2)
                plot[variable=\t,domain=\alphacrit:\alphamax,smooth]
                ({(\pv{r}+\pv{dr})*cos(\t)},{(\pv{r}+\pv{dr})*sin(\t)},-\pv{h}/2)
                plot[variable=\t,domain=180:0,smooth]
                ({(\pv{r}+\pv{dr})*cos(\t)},{(\pv{r}+\pv{dr})*sin(\t)},\pv{h}/2)
                ;
                \foreach \XX/\YY in {-1/L,1/R} 
                {\draw[fill=gray!20]  
                    ({\XX*\pv{r}},0,-\pv{h}/2) coordinate (-plate-\YY-ib)
                    -- ({\XX*(\pv{r}+\pv{dr})},0,-\pv{h}/2) coordinate (-plate-\YY-ob)
                    -- ({\XX*(\pv{r}+\pv{dr})},0,\pv{h}/2) coordinate (-plate-\YY-ot)
                    -- ({\XX*\pv{r}},0,\pv{h}/2) coordinate (-plate-\YY-it)
                    -- cycle;}
                \draw 
                ({(\pv{r}+\pv{dr})*cos(\alphacrit)},{(\pv{r}+\pv{dr})*sin(\alphacrit)},-\pv{h}/2) 
                -- 
                ({(\pv{r}+\pv{dr})*cos(\alphacrit)},{(\pv{r}+\pv{dr})*sin(\alphacrit)},\pv{h}/2);
        }},
        half cylinder shell/.cd,r/.initial=1,dr/.initial=0.2,h/.initial=1]
        
        \begin{scope}[shift={(2.,0)}]
            \draw [fill=blue, fill opacity=.25]
            (180:5mm) coordinate (a)
            -- ++(0,-12.5mm) coordinate (b)
            arc (180:360:5mm and 1.75mm) coordinate (d)
            -- (a -| d) coordinate (c) arc (0:180:5mm and 1.75mm);
            \draw [fill=blue, fill opacity=.25]
            (0,0) coordinate (t) circle (5mm and 1.75mm);
            \draw [densely dashed] (d) arc (0:180:5mm and 1.75mm);
            \draw []
            (180:7.5mm) coordinate (A)
            -- ++(0,-12.5mm) coordinate (B) node [midway, right, inner sep=1pt] {$$}
            arc (180:360:7.5mm and 2.625mm) coordinate (D)
            -- (A -| D) coordinate (C) arc (0:180:7.5mm and 2.625mm);
            \draw []
            (0,0) coordinate (T) circle (7.5mm and 2.625mm);
            \draw [densely dashed] (D) arc (0:180:7.5mm and 2.625mm);
            \draw [densely dashed ]
            ([yshift=-12.5mm]T) coordinate (B)
            edge [-Latex] node [pos=1, right] {$y$} +(-30:7.5mm)
            edge [-Latex] node [pos=1, left] {$x$} +(-150:7.5mm)
            -- (T) node [midway, right, anchor=west, fill=white, inner sep=.5pt] 
            {} node [anchor=center, circle, draw, solid, inner sep=.5pt, fill=white] 
            {} edge [solid, -Latex] node [right, pos=1] {$z$} ++(0,5mm) ;
            
        \end{scope}
        
        \begin{scope}[3d view={20}{15}, shift={(6.,-1)}, scale=1.5,transform shape]
            \path
            (0,0,0) pic(hc1){half cylinder shell={h=0.8}}
            ;
            node[midway,above,black]{$$}; 
        \end{scope}
        
        \begin{scope}[shift={(8.,-1.5)}]
            \draw (0,0)node[left](a){}--(3,0)node[right](b){}--(3.2,0.5)node[right](c){};
            \draw (0,0)--(0,2)[left]node(e){}--(3,2)node[right](f){}--(3,0);
            \draw (0,2)--(1,2.1)node[above](g){}--(3.2,2.1);
            \draw (3,2)--(3.2,2.1)node[right](h){}--(3.2,0.5);
            \draw (1,2.1);
        \end{scope}
    \end{tikzpicture}
\end{document}

图像

肯定需要大量的修饰、化妆或者别的什么,我的问题是:

  1. 如何添加注释以及r的符号等等。
  2. 另一部分涂成蓝色

答案1

我会这样做。这是等距视图,在我看来,它更容易绘制,而且看起来更好。

\documentclass[border=2mm,tikz]{standalone}
\usetikzlibrary{3d,perspective}

\tikzset
{
  light cyan/.style={fill=cyan!20},
  dark  cyan/.style={fill=cyan!60},
}


\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,
                    isometric view,rotate around z=180]
% DIMENSIONS
\def\r{2}
\def\dr{0.5}
\def\h{4}
% CYLINDER
\draw[light cyan] (-45:\r) arc (-45:135:\r) --++ (0,0,\h) arc (135:-45:\r) -- cycle;
\draw[even odd rule,dark cyan] (0,0,\h) circle   (\r)
                               (0,0,\h) circle   (\r-\dr);
\draw[light cyan]              (0,0,\h) circle   (\r-\dr);
\draw[dashed]    (0,\r,0) --++ (0,0,\h)    --++  (0,-\dr,0);
% annotations
\foreach\i in {\r,\r-\dr,0,-\r}
  \draw (\i,0,\h) --++ (0,0,3);
\fill (0,0,\h) circle (0.3mm);
\draw[latex-latex] (\r,0,\h+2.75) --++ (-\dr,0,0) node[midway,yshift=4mm] {$\Delta r$};
\draw[latex-latex]  (0,0,\h+2.75) --++  (-\r,0,0) node[midway,yshift=4mm] {$r$};
% SHELL
\begin{scope}[shift={(135:7)}]
\draw[light cyan] (-45:2*\r-\dr) arc (-45:-180:2*\r-\dr) --++ (0,0,\h) arc (-180:-45:2*\r-\dr) -- cycle;
\foreach\i in {1,-1}
  \draw[canvas is xz plane at y=0,dark cyan] (2*\i*\r,0) rectangle (2*\i*\r-\i*\dr,\h);
\draw[dark cyan]  (0:2*\r) ++  (0,0,\h) arc (0:-180:2*\r) --++ (\dr,0,0) arc (-180:0:2*\r-\dr) -- cycle;
\draw[light cyan] (0:2*\r) arc (0:-45:2*\r) --++ (0,0,\h) arc  (-45:0:2*\r) -- cycle;
\end{scope}
% CUBOID
\begin{scope}[shift={(135:15)}]
\draw[canvas is xz plane at y=\dr ,light cyan] (pi*\r,0) rectangle (-pi*\r,\h);
\draw[canvas is yz plane at x=pi*\r,dark cyan] (0,0)     rectangle (\dr,\h);
\draw[canvas is xy plane at z=\h   ,dark cyan] (pi*\r,0) rectangle (-pi*\r,\dr);
% annotations
\foreach\i in {-1,1}
  \draw (pi*\r*\i,0,\h) --++ (0,0,3);
\draw  (-pi*\r,\dr ,\h) --++ (0,0,3);
\foreach\i in {0,\h}
  \draw (-pi*\r,\dr,\i) --++ (-3,0,0);
\draw[latex-latex]  (pi*\r,0,\h+2.75)  --++ (-2*pi*\r,0,0) node[midway,yshift=4mm] {$2\pi r$}; 
\draw[latex-latex] (-pi*\r,0,\h+2.75)  --++ (0,\dr,0)      node[midway,yshift=4mm] {$\Delta r$};
\draw[latex-latex] (-pi*\r-2.75,\dr,0) --++ (0,0,\h)       node[midway,right]      {$h$};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容