PGFPlots 中的截头圆柱体

PGFPlots 中的截头圆柱体

我希望圆柱体的表面能够到达左侧的蓝色弧线(y-axis),但不要穿过它们。

我怎样才能实现这个目标?

在此处输入图片描述

\documentclass[border=3mm]{standalone}

\usepackage{pgfplots}
    \pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[%
    axis lines=middle, ticks=none,
    zmin=-2, zmax=2,
    xmin=-3, xmax=3,
    ymin=-1, ymax=3,
    view/h=125, view/v=25
    ]

    \addplot3[%
    opacity = 0.02,
    fill opacity=0.5,
    mesh/interior colormap name=hot,
    surf,
    colormap/hot,
    faceted color=black,
    z buffer = sort,
    samples = 50,
    variable = \u,
    variable y = \v,
    domain = 0:360,
    y domain = -3:3,
    ]
    ({cos(u)}, {max(v,cos(v))}, {sin(u)});

    % ARCS
    \addplot3[%
    variable= \t,
    mesh,
    blue!80!,
    semithick,
    samples=30,
    opacity = 0.025,
    z buffer = sort,
    domain= 0:180,
    ] 
    ({sin(t)}, {sin(t)}, {cos(t)});

    \addplot3[%
    variable= \t,
    mesh,
    blue!80!,
    semithick,
    samples=30,
    opacity = 0.025,
    z buffer = sort,
    domain= 0:-180,
    ] 
    ({sin(t)}, {-sin(t)}, {cos(t)});

  \end{axis}
\end{tikzpicture}

\end{document} 

答案1

我想您已经快到了。我只是cos(v)用替换了abs(cos(u))。(编辑:我还删除了一个,因为在用 替换并将范围扩展到\addplot3之后,它是多余的。)sin(u)abs(sin(u))0:360

\documentclass[border=3mm]{standalone}

\usepackage{pgfplots}
    \pgfplotsset{compat=1.15}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[%
    axis lines=middle, ticks=none,
    zmin=-2, zmax=2,
    xmin=-3, xmax=3,
    ymin=-1, ymax=3,
    view/h=125, view/v=25
    ]

    \addplot3[%
    opacity = 0.02,
    fill opacity=0.5,
    mesh/interior colormap name=hot,
    surf,
    colormap/hot,
    faceted color=black,
    z buffer = sort,
    samples = 50,
    variable = \u,
    variable y = \v,
    domain = -180:180,
    y domain = 0:3,
    ]
    ({cos(u)}, {max(v,abs(cos(u)))}, {sin(u)});

    % ARCS
    \addplot3[%
    variable= \t,
    mesh,
    blue!80!,
    semithick,
    samples=30,
    opacity = 0.025,
    z buffer = sort,
    domain= 0:360,
    ] 
    ({sin(t)}, {abs(sin(t))}, {cos(t)});

  \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容