![画出数学考试的图画](https://linux22.com/image/287912/%E7%94%BB%E5%87%BA%E6%95%B0%E5%AD%A6%E8%80%83%E8%AF%95%E7%9A%84%E5%9B%BE%E7%94%BB.png)
芬兰高考时,有这样一个问题:如何使用 LaTeX 绘制这些图片?
正方形 ABCD 位于坐标系中,AB 在 x 轴上,A=(0,0),B=(1,0)。我们绕 B 旋转正方形,使 BC 在 x 轴上,然后绕 C、D 旋转,使 A 再次接触 x 轴。画出 A 相对于时间的位置图。
正六边形 ABCDEF 位于坐标系中,AB 在 x 轴上,A=(0,0),B=(1,0)。我们围绕 B 旋转六边形,使 BC 在 x 轴上,然后围绕 C、D 旋转,依此类推,直到 A 再次接触 x 轴。画出 A 相对于时间的位置图。
手绘图表已打开http://www.mafyvalmennus.fi/images/uploads/pmyo14.pdf第 32 和 33 页(或第 34 和 35 页,取决于如何计算这些页数)。
答案1
这是第一个:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\def\side{1cm}
\tikzset{
smalldot/.style={
circle,
fill,
inner sep=1.2pt
}
}
\begin{document}
\begin{tikzpicture}[
decoration={
markings,
mark=at position 0.5 with {\arrow{>}}
}
]
\draw
(0,0) -- ++(0,\side) --++(4*\side,0) -- ++(0,-\side);
\draw (-0.5\side,0) -- ++(5*\side,0);
\foreach \valor in {1,2,3}
\draw (\valor*\side,0) -- ++(0,\side);
\draw[postaction=decorate]
(0,0) arc [start angle=180,end angle=90,radius=\side];
\draw[postaction=decorate]
(3*\side,\side) arc [start angle=90,end angle=0,radius=\side];
\draw[postaction=decorate]
(\side,\side) arc [start angle=135,end angle=45,radius=1.4142*\side];
\foreach \xcoor/\ycoor in {0/0,\side/\side,{3*\side}/\side,{4*\side}/0}
\node[smalldot] at (\xcoor,\ycoor) {};
\draw[dashed]
(\side,\side) -- (2*\side,0) -- (3*\side,\side);
\foreach \coord in {1,2,3,4}
\node[circle,draw,font=\footnotesize,inner sep=1pt] at ({\side*(\coord-0.5)},-0.5) {\coord};
\begin{scope}[yshift=-3*\side]
\draw (-0.5\side,0) -- ++(5*\side,0);
\draw[postaction=decorate]
(0,0) arc [start angle=180,end angle=90,radius=\side];
\draw[postaction=decorate]
(3*\side,\side) arc [start angle=90,end angle=0,radius=\side];
\draw[postaction=decorate]
(\side,\side) arc [start angle=135,end angle=45,radius=1.4142*\side];
\end{scope}
\end{tikzpicture}
\end{document}
正如您所见,使用\draw
和arc
您可以构建您的图像。
第二个:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\def\side{1cm}% the length of the side of the polygons
\tikzset{
smalldot/.style={
circle,
fill,
inner sep=1.2pt
}
}
\begin{document}
\begin{tikzpicture}[
decoration={
markings,
mark=at position 0.5 with {\arrow{>}}
}
]
% the hexagons
\foreach \inicio in {0,...,5}
{
\draw
(\inicio*\side,0) -- ++(0:\side) -- ++(60:\side) -- ++(120:\side) --
++(180:\side) -- ++(240:\side) -- ++(300:\side);
}
% the horizontal axis
\draw (-0.5\side,0) -- ++(7*\side,0);
% the arcs and small filled dots
\draw[postaction=decorate]
node[smalldot] {} (0,0) arc [start angle=180,end angle=120,radius=\side] node[smalldot] {};
\draw[postaction=decorate]
(60:\side) arc [start angle=150,end angle=90,radius=1.717*\side] node[smalldot] {};
\draw[postaction=decorate]
(2*\side,1.717*\side) arc [start angle=120,end angle=60,radius=2*\side] node[smalldot] {};
\draw[postaction=decorate]
(4*\side,1.717*\side) arc [start angle=90,end angle=30,radius=1.717*\side] node[smalldot] {};
\begin{scope}[xshift=5*\side]
\draw[postaction=decorate]
(60:\side) arc [start angle=60,end angle=0,radius=\side] node[smalldot] {};
\end{scope}
% the dashed lines
\draw[dashed]
(60:\side) -- (2*\side,0) -- ++(0,1.717*\side);
\draw[dashed]
(4*\side,1.717*\side) -- ++(0,-1.717*\side) -- +(30:1.717*\side);
% the circled labels
\foreach \coord in {1,...,6}
\node[circle,draw,font=\footnotesize,inner sep=1pt] at ({\side*(\coord-0.5)},-0.5) {\coord};
% the bottom figure showing only the path
\begin{scope}[yshift=-3*\side]
\draw (-0.5\side,0) -- ++(7*\side,0);
\draw[postaction=decorate]
(0,0) arc [start angle=180,end angle=120,radius=\side];
\draw[postaction=decorate]
(60:\side) arc [start angle=150,end angle=90,radius=1.717*\side];
\draw[postaction=decorate]
(2*\side,1.717*\side) arc [start angle=120,end angle=60,radius=2*\side];
\draw[postaction=decorate]
(4*\side,1.717*\side) arc [start angle=90,end angle=30,radius=1.717*\side];
\begin{scope}[xshift=5*\side]
\draw[postaction=decorate]
(60:\side) arc [start angle=60,end angle=0,radius=\side];
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
答案2
此答案概括了正多边形的顶点数,并\RotateRegularPolygon
以顶点数作为参数定义了宏。如果可选参数为false
,则仅绘制点 A 的圆弧。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes.geometric}
\makeatletter
\newif\ifDrawWithPolygon
\newcommand*{\RotateRegularPolygon}[2][true]{%
\begingroup
\def\VarN{#2}%
\edef\VarM{\the\numexpr\VarN-1\relax}%
\def\DimR{15mm}%
\csname DrawWithPolygon#1\endcsname
%
\pgfmathsetmacro\AngleN{360/\VarN}%
\pgfmathsetmacro\CurrentAngle{270+180/\VarN}%
\pgfmathsetmacro\XM{-cos(\CurrentAngle)}%
\pgfmathsetmacro\YM{-sin(\CurrentAngle)}%
\pgfmathsetmacro\Side{-2*\XM}%
\expandafter\pgfmathsetmacro\csname X0\endcsname{-\XM}%
\expandafter\pgfmathsetmacro\csname Y0\endcsname{-\YM}%
\expandafter
\let\csname X\VarN\expandafter\endcsname\csname X0\endcsname
\expandafter
\let\csname X\VarN\expandafter\endcsname\csname Y0\endcsname
\count@=1\relax
\@whilenum\count@<\VarN\do{%
\pgfmathsetmacro\CurrentAngle{\CurrentAngle-\AngleN}%
\expandafter
\pgfmathsetmacro\csname X\the\count@\endcsname{cos(\CurrentAngle)}%
\expandafter
\pgfmathsetmacro\csname Y\the\count@\endcsname{sin(\CurrentAngle)}%
\advance\count@\@ne
}%
\begin{tikzpicture}[
x=\DimR,
y=\DimR,
]
\draw[]
let
\n1 = {\Side*\VarM*\DimR + \DimR}
in
(-\DimR, -\YM) -- (\n1, -\YM)
;
\ifDrawWithPolygon
\foreach \i in {0, ..., \VarM} {
\draw[xshift=\i*\Side*\DimR]
(\csname X0\endcsname, \csname Y0\endcsname)
\foreach \j in {1, ..., \VarM} {
-- (\csname X\j\endcsname, \csname Y\j\endcsname)
}
-- cycle;
;
% \edef\DimSide{\the\dimexpr\Side\dimexpr\DimR\relax\relax}%
\ifnum \i<\numexpr\VarM-1\relax
\ifnum \i>0 %
\draw[
dashed,
xshift=\i*\Side*\DimR,
blue
]
let
\p1 = (\csname X\the\numexpr\i+2\endcsname + \Side,
\csname Y\the\numexpr\i+2\endcsname)
in
(\p1) --
(\csname X0\endcsname, \csname Y0\endcsname) --
(\csname X\the\numexpr\i+1\endcsname,
\csname Y\the\numexpr\i+1\endcsname)
;
\fi
\fi
}%
\foreach \i in {0, ..., \VarM} {
\draw[
xshift=\i*\Side*\DimR,
yshift=-\YM*\DimR,
]
(0,-8pt)
node[
\ifnum\i<9 circle\else ellipse\fi,
draw,
font=\footnotesize,
inner sep=1pt,
] {\the\numexpr\i+1\relax}
;
}%
\fi
\edef\ArrowPosition{\ifDrawWithPolygon 0.5\else 0.999\fi}%
\tikzset{
decoration={
markings,
mark=at position \ArrowPosition with {\arrow{>}},
},
}%
\foreach \i in {0, ..., \numexpr\VarM-1\relax} {
\draw[
postaction=decorate,
xshift=\i*\Side*\DimR,
red,
]
let
\n{x} = {\csname X\the\numexpr\i+1\endcsname-\csname X0\endcsname},
\n{y} = {\csname Y\the\numexpr\i+1\endcsname-\csname Y0\endcsname},
\n{start} = {atan2(\n{y},\n{x})},
\n{radius} = {sqrt(\n{x}*\n{x} + \n{y}*\n{y})}
in
(\csname X\the\numexpr\i+1\endcsname,
\csname Y\the\numexpr\i+1\endcsname)
arc[start angle=\n{start}, delta angle=-\AngleN, radius=\n{radius}]
;
}%
\end{tikzpicture}%
\endgroup
}
\begin{document}
\centering
\setlength{\parskip}{1ex}
\newcommand*{\test}[1]{%
\par
\vspace{4\parskip}%
\RotateRegularPolygon{#1}\par
\nopagebreak
\RotateRegularPolygon[false]{#1}\par
}
\test{4}
\test{5}
\test{6}
\test{9}
\test{12}
\end{document}
答案3
这是 Metapost 中用于绘制这些路径的微型通用函数。根据需要进行装饰。
prologues:=3;outputtemplate:="%j%c.eps";
% Corner of Rotated Polygon
vardef corp(expr n,size) =
save p; pair p[]; p[0]=(0,0);
p[0] for i=1 upto n-1:
hide(p[i] = p[i-1] rotatedabout((size*i,0),-360/n))
{((size*i,0)-p[i-1]) rotated 90} ..
{((size*i,0)-p[i]) rotated 90} p[i]
endfor
enddef;
beginfig(1);
drawarrow corp(4,3cm);
drawarrow corp(6,2cm) shifted 144up;
endfig;
end
答案4
一个迟来的答案,与之前的答案在精神上有所不同:为了更具说明性,正方形的连续位置不相互接触,并且正方形的边很厚。这迫使我们稍微欺骗一下点 A 的轨迹参数,例如椭圆弧而不是(但非常接近)真实弧。我用过 pstricks
。
\documentclass[a4paper,10pt]{article}
\usepackage[svgnames,x11names, pdf]{pstricks}%
\usepackage{pstricks-add}
\usepackage{multido}
\pagestyle{empty}
\begin{document}
\def\mysquare{{\psset{linewidth = 2pt, dotsize =2pt, showpoints, labelsep = 1cm}%
\psline[linecolor=PaleVioletRed1](0.80,0)(0.80,0.80)\psline[linecolor=PaleVioletRed2](0.80,0.80)(0,0.80)%
\psline[linecolor=PaleVioletRed3](0,0.80)(0,0)\psline[linecolor=PaleVioletRed4](0,0)(0.80,0)}}%
\begin{pspicture*}(-1.25,-1)(5.95,4)
\scriptsize\sffamily
\pnodes{P}(0,0)(1,0)(2,0)(3,0)
\pnodes{Q}(1,1)(2,1)(3,1)(4,1)
%%%%%%%% Successive positions of square
\psset{labelsep = 1.16\pslinewidth}
\uput[u](0.1,0){\mysquare}%
\uput[u]{270}(1.1,0.8){\mysquare}%
\uput[u]{180}(2.9,0.8){\mysquare}%
\uput[u]{90}(3.9,0){\mysquare}%
%%%%%%%%% Labels
\uput{2pt}[d](0.1,0){\rnode{A}{A}}\uput{2pt}[d](0.90,0){B}\uput[u](0.90,0.90){C}\uput[u](0.1,0.90){D}
%%%%%%%%% Successive positions of point A
\psset{linewidth =1pt, linecolor = Thistle3, dotsize = 2pt}
\psellipticarcn{*->}(1.1,1pt)(1.0175, 0.815 ){180}{90}
\psarcn{*->}(2,1pt){1.204}{138}{42}
\psellipticarcn{*->}(2.9,1pt)(1.035, 0.815 ){90}{0}
\psdot(3.9175,1pt)
%%%%%%%%%%%%
\psaxes[linecolor = LightSteelBlue3!90!blue, ticksize = -2pt, tickcolor= LightSteelBlue3,labels = none](0,-0.4pt)(-0.95,-0.4pt)(5.95,-0.4pt)
\end{pspicture*}
\end{document}