큐브 체인을 그리는 방법?

큐브 체인을 그리는 방법?

라텍스로 3D 큐브 체인을 그리는 가장 쉬운 방법을 찾으려고 노력 중입니다. 도와주세요여기에 이미지 설명을 입력하세요

나는 tikz에서 큐브를 그리는 방법을 알고 있습니다. 예를 들어

\newcommand{\tikzcuboid}[4]{% width, height, depth, scale
\begin{tikzpicture}[scale=#4]
\foreach \x in {0,...,#1}
{   \draw (\x ,0  ,#3 ) -- (\x ,#2 ,#3 );

    \draw (\x ,#2 ,#3 ) -- (\x ,#2 ,0  );
    
   
}
\foreach \x in {0,...,#2}
{   \draw (#1 ,\x ,#3 ) -- (#1 ,\x ,0  );
    \draw (0  ,\x ,#3 ) -- (#1 ,\x ,#3 );
}
\foreach \x in {0,...,#3}
{   \draw (#1 ,0  ,\x ) -- (#1 ,#2 ,\x );
    \draw (0  ,#2 ,\x ) -- (#1 ,#2 ,\x );
}
\end{tikzpicture}
}

\newcommand{\tikzcube}[2]{% length, scale
\tikzcuboid{#1}{#1}{#1}{#2}
}

이 코드는 다음에서 찾을 수 있습니다.TikZ의 2D 노드 세트에서 3D 큐브를 만드는 데 도움이 필요합니다.

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

답변1

tikz 솔루션은 다음과 같습니다. \cubesAmount더 많거나 적은 큐브를 그리도록 변경할 수 있습니다 .

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

\documentclass{article}
\usepackage{tikz}

\begin{document}
 
\begin{tikzpicture}[z={(0.5,0.5)}]

\def\cubesAmount{3}
\foreach \i in {1,...,\cubesAmount}{
    \draw (\i-1,\i-1,\i-1) rectangle +(1,1,0) -- ++(0,1,0) -- ++(0,0,1) -- ++(1,0,0) edge +(0,0,-1) -- ++(0,-1,0) -- ++(0,0,-1);
    \ifnum\i<\cubesAmount
        \node[anchor=north west] at (\i,\i,\i) {$(\i,\i,\i)$};
    \fi
}
\node[anchor=north east] at (0,0,0){$(0,0,0)$};
\node[anchor=south west] at (\cubesAmount,\cubesAmount,\cubesAmount){$(\cubesAmount,\cubesAmount,\cubesAmount)$};
 
\end{tikzpicture}
 
\end{document}

또한 관점을 변경하려면 주변을 조정할 수 있습니다.z={(yaw,pitch)}

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

답변2

업데이트:하나는 수LaTex 문서에 점근선 코드를 포함합니다.그것은 이런 것입니다

\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
// can be directly run on http://asymptote.ualberta.ca/
<asymptote code>        
\end{asy}
\end{document}

내 제안은 Asymptote를 사용하는 것입니다. 그러면 모든 것이 사용 가능합니다. 내장: unitcube표면입니다. unitbox3D 공간의 경로/세그먼트 배열입니다. (0,-2,1)이 경우 투영/관점을 자유롭게 선택할 수 있습니다 .

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

// http://asymptote.ualberta.ca/
import three;
size(5cm);
currentprojection=orthographic(0,-2,1,center=true,zoom=.8);
path3[] p=unitbox;
//surface p=unitcube;
draw(p,red);
draw(shift(1,1,1)*p,blue);
draw(shift(2,2,2)*p,magenta);

와 함께surface p=unitcube;

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

아니면 이거

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

// http://asymptote.ualberta.ca/
import three;
size(5cm);
currentprojection=orthographic(0,-2,1,center=true,zoom=.8);
path3[] p=unitbox;
surface q=unitcube;

draw(q,red+opacity(.1));
draw(shift(1,1,1)*q,blue+opacity(.1));
draw(shift(2,2,2)*q,magenta+opacity(.1));

draw(p,red);
draw(shift(1,1,1)*p,blue);
draw(shift(2,2,2)*p,magenta);

관련 정보