\tdplotsetmaincoords의 가짜 공간

\tdplotsetmaincoords의 가짜 공간

아래 MWE 결과는 다음을 사용하여 가짜 공간입니다 \tdplotsetmaincoords.

여기에 이미지 설명을 입력하세요

빨간색은 경계 상자이고 회색 상자는 에서 가져온 것입니다 \fbox{}.

(MWE에 주석 처리된) 을 포함하면 \unskip\unskip문제가 해결되지만 더 나은 솔루션이 있는지 궁금합니다.

이것은 버그인가요, 아니면 이렇게 간격을 두는 이유가 있나요?

노트:

  • \tdplotsetmaincoords{70}{115}될 것을 옮기다~ 전에 \begin{document}또한 문제를 해결하지만 내 그림이 클래스를 사용 standalone하고 다른 문서에 포함되어 있기 때문에 이 방법은 쉽게 작동하지 않습니다. 따라서 각 그림에 해당 설정을 현지화해야 합니다.

참고자료:

암호:

\documentclass{article}
\usepackage{tikz,tikz-3dplot}

\newcommand*{\DrawBoundingBox}[1][]{%
    \draw [
        draw=red, thick,
    ]
    ([shift={(-1pt,-1pt)}]current bounding box.south west) rectangle 
    ([shift={(1pt,1pt)}]current bounding box.north east);
}

\begin{document}
\fboxsep=0pt
\fbox{%
  %% code from https://tex.stackexchange.com/a/29342/4301
  \tdplotsetmaincoords{70}{115}%
  %\unskip\unskip% <----- HACK which fixes the problem.
  \begin{tikzpicture}[scale=4,tdplot_main_coords]
    \coordinate (O) at (0,0,0);
    \tdplotsetcoord{P}{1.414213}{54.68636}{45}

    \draw[fill=gray!50,fill opacity=0.5] (O) -- (Py) -- (Pyz) -- (Pz) -- cycle;
    \draw[fill=blue,fill opacity=0.5] (O) -- (Px) -- (Pxy) -- (Py) -- cycle;
    \draw[fill=yellow,fill opacity=0.5] (O) -- (Px) -- (Pxz) -- (Pz) -- cycle;
    \draw[fill=green,fill opacity=0.5] (Pz) -- (Pyz) -- (P) -- (Pxz) -- cycle;
    \draw[fill=red,fill opacity=0.5] (Px) -- (Pxy) -- (P) -- (Pxz) -- cycle;
    \draw[fill=magenta,fill opacity=0.5] (Py) -- (Pxy) -- (P) -- (Pyz) -- cycle;
    
    \DrawBoundingBox
  \end{tikzpicture}%
}%
\end{document}

답변1

코드에 가짜 공백이 있습니다. 관리자에게 알립니다.

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

\newcommand*{\DrawBoundingBox}[1][]{%
    \draw [
        draw=red, thick,
    ]
    ([shift={(-1pt,-1pt)}]current bounding box.south west) rectangle
    ([shift={(1pt,1pt)}]current bounding box.north east);
}
\renewcommand{\tdplotsetmaincoords}[2]{%
%perform some trig for the display transformation
%
%
%store the user-specified angles for possible future use
\pgfmathsetmacro{\tdplotmaintheta}{#1}% <------ changed
\pgfmathsetmacro{\tdplotmainphi}{#2}% <------- changed
%
%
\tdplotcalctransformmainscreen
%
%now here is where the output is performed
\tikzset{tdplot_main_coords/.style={x={(\raarot cm,\rbarot cm)},y={(\rabrot cm, \rbbrot cm)},z={(\racrot cm, \rbcrot cm)}}}%
}

\begin{document}
\fboxsep=0pt 
\fbox{%
  %% code from https://tex.stackexchange.com/a/29342/4301
  \tdplotsetmaincoords{70}{115}%
  %\unskip\unskip% <----- HACK which fixes the problem.
  \begin{tikzpicture}[scale=4,tdplot_main_coords]
    \coordinate (O) at (0,0,0);
    \tdplotsetcoord{P}{1.414213}{54.68636}{45}

    \draw[fill=gray!50,fill opacity=0.5] (O) -- (Py) -- (Pyz) -- (Pz) -- cycle;
    \draw[fill=blue,fill opacity=0.5] (O) -- (Px) -- (Pxy) -- (Py) -- cycle;
    \draw[fill=yellow,fill opacity=0.5] (O) -- (Px) -- (Pxz) -- (Pz) -- cycle;
    \draw[fill=green,fill opacity=0.5] (Pz) -- (Pyz) -- (P) -- (Pxz) -- cycle;
    \draw[fill=red,fill opacity=0.5] (Px) -- (Pxy) -- (P) -- (Pxz) -- cycle;
    \draw[fill=magenta,fill opacity=0.5] (Py) -- (Pxy) -- (P) -- (Pyz) -- cycle;

    \DrawBoundingBox
  \end{tikzpicture}%
}%
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보