我想在平面上画一个全连接图,然后调整它与平面的倾斜度,并将网络中的每个节点链接到 z 方向上垂直的另一个角色。现在我想到了这个,但结果并不令人满意,也不可调。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\begin{scope}[canvas is xz plane at y=0]
\foreach \x /\alph/\name in {0/a/one, 60/b/two, 120/c/three, 180/d/four, 240/e/five, 300/f/six}{
\coordinate (\alph) at (\x:2cm);}
\foreach \alpha in {a,b,c,d,e,f}%
{%
\foreach \alphb in {a,b,c,d,e}%
{%
\draw (\alpha) -- (\alphb);%
}}
\foreach \alph in {a,b,c,d,e,f}{%
\node[circle, minimum width=1pt,draw] at(\alph) {};
\draw[red](\alph) -- ($(\alph) + (-.1cm, -.2cm, 0)$) node[circle, minimum width=1pt,draw]{};}
\end{scope}
\end{tikzpicture}
\end{document}
答案1
我想你需要这样的东西。你可以根据自己的需要调整它,使用角度\def\anglex{20}
和\def\anglez{35}
选项,从而产生围绕轴的旋转。
\documentclass[border=2mm]{standalone}
\usepackage {tikz}
\usetikzlibrary{calc}
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zy{sqrt(2/3)}
% dimensions
\def\l{2} % hexagon edge length
\def\h{3} % height
\def\r{0.15} % node radius
% rotation angles
\def\anglex{20}
\def\anglez{35}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,%
x={({-\xx cm,-\xy cm})},y={(\xx cm,-\xy cm)},z={(0 cm,\zy cm)},%
rotate around z=\anglez,rotate around x=\anglex]
\foreach\i in {1,...,6}
{
\coordinate (A\i) at (60*\i-60:\l);
\coordinate (B\i) at ($(A\i)+(0,0,\h)$);
\draw (A\i) circle (\r cm);
\draw[red] (B\i) circle (\r cm);
\draw[red] (A\i) -- (B\i);
}
\foreach\i in{1,...,5}
{%
\pgfmathtruncatemacro\ii{\i+1}
\foreach\j in {\ii,...,6}
{%
\draw (A\i) -- (A\j);
}
}
\node at (0 cm,-2cm) {rotate around z=$\anglez$, rotate around x=$\anglex$};
\end{tikzpicture}
\end{document}