我有一些照片http://www.mediafire.com/view/?58gs6ye0zf149fv 我怎样才能在 Tex 中绘制多头龙的发展?请帮帮我。
答案1
这是正则凸多面体的解:
- 三角形解决方案(四边形、八边形、二十边形)使用坐标轴的重新定义(0°、60°)。您必须指定右下角(
\uptrig
)或右上角(\downtrig
)的坐标。 - 正方形解决方案(六边形)很简单,因为它只需要画正方形
- 对于五边形解决方案(十二边形),有 10 个方向(见图)。对于这两个
\uppent
,\downpent
您必须指定到达目的地的路径。所以{10,1,10,7}
意味着在方向 10、1、10 和 7 上每走一步
代码
\documentclass[parskip]{scrartcl}
\usepackage[margin=5mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
% === regular triangles ===
\newcommand{\uptrig}[2][blue!50!gray,draw=white,thick]% [options], list of coordinates e.g {1,2},{1,3},{4,2}
{ \foreach \c in {#2}
\fill[#1] (\c) -- ($(\c)+(1,0)$) -- ($(\c)+(0,1)$) -- cycle;
}
\newcommand{\downtrig}[2][blue!50!gray,draw=white,thick]% [options], list of coordinates e.g {1,2},{1,3},{4,2}
{ \foreach \c in {#2}
\fill[#1] (\c) -- ($(\c)+(1,0)$) -- ($(\c)+(1,-1)$) -- cycle;
}
% === squares ===
\newcommand{\squares}[2][blue!50!gray,draw=white,thick]% [options], list of coordinates e.g {1,2},{1,3},{4,2}
{ \foreach \c in {#2}
\fill[#1] (\c) rectangle ($(\c)+(1,1)$) -- cycle;
}
% === regular pentagon ==
\newcommand{\downpent}[2][blue!50!gray,draw=white,thick]% [options], list of direction steps e.g {10/2/1/1}
{
\coordinate (temp) at (0,0);
\foreach \p in {#2}
{ \foreach \s in \p
{ \coordinate (temp) at ($(temp)+(\s*36-18:1)$);
}
\fill[#1] ($(temp)+(54:0.618)$) -- ($(temp)+(126:0.618)$) -- ($(temp)+(198:0.618)$) -- ($(temp)+(270:0.618)$) -- ($(temp)+(342:0.618)$) -- cycle;
\coordinate (temp) at (0,0);
}
}
\newcommand{\uppent}[2][blue!50!gray,draw=white,thick]% [options], list of coordinates e.g {1,2},{1,3},{4,2}
{
\coordinate (temp) at (0,0);
\foreach \p in {#2}
{ \foreach \s in \p
{ \coordinate (temp) at ($(temp)+(\s*36-18:1)$);
}
\fill[#1] ($(temp)+(-54:0.618)$) -- ($(temp)+(-126:0.618)$) -- ($(temp)+(-198:0.618)$) -- ($(temp)+(-270:0.618)$) -- ($(temp)+(-342:0.618)$) -- cycle;
\coordinate (temp) at (0,0);
}
}
\begin{document}
\section*{3}
\begin{tikzpicture}
[ x={(0:1cm)},
y={(60:1cm)},
scale=2
]
\uptrig[red,draw=white,thick]{{0,0},{1,0},{-1,1},{0,-1}}
\downtrig{{-1,1},{0,1},{0,0},{0,-1}}
\end{tikzpicture}
\section*{4}
\begin{tikzpicture}[scale=2]
\squares[green!50!gray,dashed,draw= white]{{0,0},{-1,0},{1,0},{0,1},{0,-1},{0,-2}}
\end{tikzpicture}
\section*{5}
\begin{tikzpicture}[scale=2]
\downpent[orange,draw=white,thick]{{2},{4},{6},{8},{10},{10,1,10}}
\uppent[cyan!50!blue,draw=white,thick]{{},{10,1},{10,1,10,3},{10,1,10,1},{10,1,10,9},{10,1,10,7}}
\foreach \a [count=\c] in {18,54,...,342} \draw[->,thick] (0,0) -- (\a:1cm) node[label=\a:\c] {};
\end{tikzpicture}
\end{document}