
Ich versuche, den einfachsten Weg zu finden, eine 3D-Würfelkette in Latex zu zeichnen. Hilf mir
Ich weiß, wie man in Tikz einen Würfel zeichnet. Zum Beispiel
\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}
}
Ich finde diesen Code inBrauche Hilfe beim Erstellen eines 3D-Würfels aus einem 2D-Knotensatz in TikZ
Antwort1
Hier ist eine Tikz-Lösung. Sie können \cubesAmount
mehr oder weniger Würfel zeichnen.
\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}
Wenn Sie die Perspektive ändern möchten, können Sie auch Folgendes tun:z={(yaw,pitch)}
Antwort2
Aktualisieren:Man kannFügen Sie den Asymptotencode in ein LaTex-Dokument ein.Es ist so etwas
\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
// can be directly run on http://asymptote.ualberta.ca/
<asymptote code>
\end{asy}
\end{document}
Mein Vorschlag ist die Verwendung von Asymptote, dann ist alles verfügbar und integriert: unitcube
ist eine Oberfläche; ist ein Array von Pfaden/Segmenten im 3D-Raum. Wir können beispielsweise in diesem Fall unitbox
die Projektion/den Blickwinkel frei wählen .(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);
Mitsurface p=unitcube;
oder dieses
// 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);