在 tikz 中使用坐标时输出的图像不同

在 tikz 中使用坐标时输出的图像不同

在 tikz-3dplot 中使用命名的 v/s 原始坐标时,我得到了不同的输出图像。有没有办法打印出坐标值来帮助调试或检查任何日志文件。下面是最小示例:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{calc}

\begin{document}

    \tdplotsetmaincoords{70}{100}%right hand
    \begin{tikzpicture}[scale=2]
        \def\xmax{2}
        \def\ymax{2}
        \def\dz{0.2}
        \coordinate (M) at (0.5*\xmax,0.5*\ymax,0);
        \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords]
        ({0},{0},{0}) to [out=30,in=200]
        ({0},{\ymax},{0}) to
        ({\xmax},{\ymax},{0}) to[out=200,in=30]
        ({\xmax},{0},{0}) to
        ({0},{0},{-\dz}) to
         (M) to
        (0,0,0);
        \end{tikzpicture}

    \tdplotsetmaincoords{70}{100}%right hand
    \begin{tikzpicture}[scale=2]
        \def\xmax{2}
        \def\ymax{2}
        \def\dz{0.2}
        \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords]
        ({0},{0},{0}) to [out=30,in=200]
        ({0},{\ymax},{0}) to
        ({\xmax},{\ymax},{0}) to[out=200,in=30]
        ({\xmax},{0},{0}) to
        ({0},{0},{-\dz}) to
         (0.5*\xmax,0.5*\ymax,0) to
        (0,0,0);
        \end{tikzpicture}

\end{document}

输出图像

答案1

tdplot_main_coords定义符号坐标时未使用M。如果替换

\coordinate (M) at (0.5*\xmax,0.5*\ymax,0);

经过

\path[tdplot_main_coords] (0.5*\xmax,0.5*\ymax,0) coordinate (M);

两个结果都匹配。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}

    \tdplotsetmaincoords{70}{100}%right hand
    \begin{tikzpicture}[scale=2]
        \def\xmax{2}
        \def\ymax{2}
        \def\dz{0.2}
        \path[tdplot_main_coords] (0.5*\xmax,0.5*\ymax,0) coordinate (M);
        \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords]
        ({0},{0},{0}) to [out=30,in=200]
        ({0},{\ymax},{0}) to
        ({\xmax},{\ymax},{0}) to[out=200,in=30]
        ({\xmax},{0},{0}) to
        ({0},{0},{-\dz}) to
         (M) to
        (0,0,0);
        \end{tikzpicture}

    \tdplotsetmaincoords{70}{100}%right hand
    \begin{tikzpicture}[scale=2]
        \def\xmax{2}
        \def\ymax{2}
        \def\dz{0.2}
        \draw[fill=green!40!white, opacity = 0.5,tdplot_main_coords]
        ({0},{0},{0}) to [out=30,in=200]
        ({0},{\ymax},{0}) to
        ({\xmax},{\ymax},{0}) to[out=200,in=30]
        ({\xmax},{0},{0}) to
        ({0},{0},{-\dz}) to
         (0.5*\xmax,0.5*\ymax,0) to
        (0,0,0);
        \end{tikzpicture}

\end{document}

在此处输入图片描述

calc库由 自动加载tikz-3dplot,允许您比较命名节点/坐标的屏幕坐标。非官方库3dtools允许您检索用于定义节点/坐标的坐标,但此时不存储它们在哪个坐标系中定义的信息。

相关内容