Tikz:堆叠空心实体圆柱体

Tikz:堆叠空心实体圆柱体

有没有办法在 TikZ 中绘制三个具有有限厚度的空心圆柱体?结果应该看起来像这样:

空心圆柱体厚度

我已经找到了shape=cylinder选项这里或者这里。但我不知道如何在“真实” 3D 中获得厚度和所有这些

编辑:

尽管只要求对特定形状或选项进行提示,但我会尽力取悦@cfr并添加没有内容的MWE

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
\usepackage[latin1]{inputenc}
\usepackage{geometry}
\geometry{a4paper,left=25mm,right=25mm, top=25mm, bottom=25mm}
\usepackage{tikz}

\begin{document}
% There is absolutely no content here
\end{document}

答案1

您可以使用Qrrbrbirlbel 的回答在这里。在我看来,它看起来是真正的 3D。

\documentclass[tikz,border=4]{standalone}
\usetikzlibrary{calc,shapes.geometric}
\pgfmathparse{atan2(0,1)}
\ifdim\pgfmathresult pt=0pt % atan2(y, x)
  \tikzset{declare function={atanXY(\x,\y)=atan2(\y,\x);atanYX(\y,\x)=atan2(\y,\x);}}
\else                       % atan2(x, y)
  \tikzset{declare function={atanXY(\x,\y)=atan2(\x,\y);atanYX(\y,\x)=atan2(\x,\y);}}
\fi
\begin{document}
\begin{tikzpicture}[font=\sffamily\small,
   mycylinder/.style={draw, shape=cylinder, aspect=1.5, minimum height=+3cm,
    minimum width=+2cm, left color=blue!30, right color=blue!60, middle color=blue!10,
    shape border rotate=90, append after command={%
      let \p{cyl@center} = ($(\tikzlastnode.before top)!0.5! (\tikzlastnode.after top)$),
          \p{cyl@x}      = ($(\tikzlastnode.before top)-(\p{cyl@center})$),
          \p{cyl@y}      = ($(\tikzlastnode.top)       -(\p{cyl@center})$)
      in (\p{cyl@center}) edge[draw,double distance=1pt,double=gray!40!white, fill=blue!10, to path={
        ellipse [x radius=veclen(\p{cyl@x})-1\pgflinewidth,
                 y radius=veclen(\p{cyl@y})-1\pgflinewidth,
                 rotate=atanXY(\p{cyl@x})]}] () }}]
\node[thick,mycylinder] (a) at (0,0){};
\coordinate (b) at ($(a.after top)!0.5!(a.before top)$);
\coordinate (c) at ($(a.north)!2!(b)$);
\node[thick,mycylinder,anchor=south] at (c){};
\end{tikzpicture}
\end{document}

在此处输入图片描述

调整minimum widthminimum heightaspect添加第三个气缸可得

\documentclass[tikz,border=4]{standalone}
\usetikzlibrary{calc,shapes.geometric}
\pgfmathparse{atan2(0,1)}
\ifdim\pgfmathresult pt=0pt % atan2(y, x)
  \tikzset{declare function={atanXY(\x,\y)=atan2(\y,\x);atanYX(\y,\x)=atan2(\y,\x);}}
\else                       % atan2(x, y)
  \tikzset{declare function={atanXY(\x,\y)=atan2(\x,\y);atanYX(\y,\x)=atan2(\x,\y);}}
\fi
\begin{document}
\begin{tikzpicture}[font=\sffamily\small,
   mycylinder/.style={draw, shape=cylinder, aspect=1, minimum height=+2cm,
    minimum width=+3cm, left color=blue!30, right color=blue!60, middle color=blue!10,
    shape border rotate=90, append after command={%
      let \p{cyl@center} = ($(\tikzlastnode.before top)!0.5! (\tikzlastnode.after top)$),
          \p{cyl@x}      = ($(\tikzlastnode.before top)-(\p{cyl@center})$),
          \p{cyl@y}      = ($(\tikzlastnode.top)       -(\p{cyl@center})$)
      in (\p{cyl@center}) edge[draw,double distance=1pt,double=gray!40!white, fill=blue!10, to path={
        ellipse [x radius=veclen(\p{cyl@x})-1\pgflinewidth,
                 y radius=veclen(\p{cyl@y})-1\pgflinewidth,
                 rotate=atanXY(\p{cyl@x})]}] () }}]
\node[thick,mycylinder] (a) at (0,0){};
\coordinate (b) at ($(a.after top)!0.5!(a.before top)$);
\coordinate (c) at ($(a.north)!2!(b)$);
\node[thick,mycylinder,anchor=south] (d) at (c){};
\coordinate (bb) at ($(d.after top)!0.5!(d.before top)$);
\coordinate (cc) at ($(d.north)!2!(bb)$);
\node[thick,mycylinder,anchor=south] (e) at (cc){};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容