\begin{tikzpicture}
\def\nuPi{3.1459265}
\foreach \a in {0,6,12,18,24}{
\foreach \x in {0,3}{
\foreach \y in {0,2*sqrt(3),4*sqrt(3),6*sqrt(3)}{
\foreach \i in {0,...,5}{
\draw [ultra thick,blue]({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) -- ({\x + \a+2*cos(360*(\i+1)/6)},{\y+sqrt(\x)+2*sin(360*(\i+1)/6)});
\shade[ball color=red] ({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) circle(0.45);
}
}
}
}
\end{tikzpicture}
我怎样才能将这张石墨烯图片放在倾斜的平面上?所有六边形都应该变形,我怎样才能在 TikZ 中做出这种变形?
答案1
使用 PSTricks 将盒子放在倾斜的平面上。
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{dimen=monkey,fillstyle=solid,opacity=.5}
\def\object{%
\psframe[linestyle=none,fillcolor=blue](-2,-1)(2,1)
\psaxes[linecolor=gray,labels=none,ticks=none]{->}(0,0)(-3,-3)(3,2)[$x$,0][$y$,90]
\rput{*0}{%
\psline{->}(0,-2)%
\uput[-90]{*0}(0,-2){$\vec{w}$}}
}
\begin{document}
\multido{\i=0+10}{5}{%
\begin{pspicture}(9,7)
\pspolygon[fillcolor=gray](8,0)(!8 dup \i\space tan mul)
\rput(5;\i){\rput{\i}{\rput(0,1){\object}}}
\end{pspicture}}
\end{document}
答案2
正如评论中提到的,您可以使用xslant
和 yslant` 以及合适的值。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[xslant=.6,yslant=.8]
\def\nuPi{3.1459265}
\foreach \a in {0,6,12,18,24}{
\foreach \x in {0,3}{
\foreach \y in {0,2*sqrt(3),4*sqrt(3),6*sqrt(3)}{
\foreach \i in {0,...,5}{
\draw [ultra thick,blue,]({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) -- ({\x + \a+2*cos(360*(\i+1)/6)},{\y+sqrt(\x)+2*sin(360*(\i+1)/6)});
\shade[ball color=red] ({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) circle(0.45);
}
}
}
}
\end{tikzpicture}
\end{document}
您可以通过这种方式检查xslant
和的合适值yslant
。(需要时间进行编译)
\documentclass[tikz]{standalone}
\begin{document}
\foreach \xslant in {.4,.8}{
\foreach \yslant in {.1,.2,...,.9}{
\begin{tikzpicture}
\useasboundingbox (-8,-8) rectangle (65,45);
\def\nuPi{3.1459265}
\foreach \a in {0,6,12,18,24}{
\foreach \x in {0,3}{
\foreach \y in {0,2*sqrt(3),4*sqrt(3),6*sqrt(3)}{
\foreach \i in {0,...,5}{
\draw [ultra thick,blue,xslant=\xslant,yslant=\yslant]({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) -- ({\x + \a+2*cos(360*(\i+1)/6)},{\y+sqrt(\x)+2*sin(360*(\i+1)/6)});
\shade[ball color=red,xslant=\xslant,yslant=\yslant] ({\x + \a+2*cos(360*\i/6)},{\y+sqrt(\x)+2*sin(360*\i/6)}) circle(0.45);
}
}
}
}
\end{tikzpicture}
}
}
\end{document}