在3d pgfplot轴内绘制圆圈

在3d pgfplot轴内绘制圆圈

我想在半圆柱体的末端画一个圆。但是我无法改变这个圆的方向(平面)。我发现这个帖子建议使用,[x={(0,0, 1)}]但它似乎在 pgfplots 环境中不起作用axis。我尝试引用正确的坐标系axis cs:进行转换,但这也没有帮助。

梅威瑟:

\documentclass{standalone}

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

\newcommand{\ycenter}{1}
\newcommand{\zcenter}{1}
\newcommand{\myradius}{1}

\newcommand{\myxmax}{5}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[xmax=\myxmax]
        \addplot3[
            domain y = \ycenter-\myradius:\ycenter+\myradius,
            surf,
        ]
        {-sqrt(\myradius^2 - (y-\ycenter)^2) + \zcenter};

        % center of the circle at the right end of semicylinder
        \node at (\myxmax, \ycenter, \zcenter) {O};

        % this circle is not oriented correctly
        \draw[red] (\myxmax, \ycenter, \zcenter) circle (1);
        % sadly this does not help
        \draw[green] (\myxmax, \ycenter, \zcenter) [x={(0,0,1)}] circle (1);
        % neither does this
        \draw[black] (1, 0, 0) [x={(axis cs: 0,0,1)}] circle (1);


    \end{axis}
    % this does not refer to the correct coordinate system
    \draw[blue] (\myxmax, \ycenter, \zcenter) circle (1);
    \draw[blue] (\myxmax, \ycenter, \zcenter) [x={(0,0,1)}] circle (1);
\end{tikzpicture}
\end{document}

产量:

在此处输入图片描述

谢谢你的帮助,

弗朗兹

答案1

这是绘制圆的一种简单方法(制作许多小曲线)和另一种绘制真实圆的更复杂的方法

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{3d, calc}
\newcommand{\ycenter}{1}
\newcommand{\zcenter}{1}
\newcommand{\myradius}{1}
\newcommand{\myxmax}{5}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=\myxmax]
\addplot3[domain=-\myxmax:\myxmax, domain y=\ycenter-\myradius:\ycenter+\myradius, surf,
] {-sqrt(\myradius^2 - (y-\ycenter)^2) + \zcenter};
\addplot3[ultra thick, domain=0:360, variable=t, smooth] (\myxmax,{\ycenter+\myradius*cos(t)},{\zcenter+\myradius*sin(t)});
\begin{scope}[canvas is yz plane at x=\myxmax]
\draw[red, thick] let \p1=(\myradius,0), \n1={veclen(\x1,\y1)} in (\ycenter,\zcenter) circle[radius=\n1];
\end{scope}
\end{axis}
\end{tikzpicture}
\end{document}

末端带有圆圈的 3D 表面

相关内容