需要 tikz 示例

需要 tikz 示例

我刚刚用 GeoGebra 画了这个,如何用 tikz 画?

在此处输入图片描述

答案1

使用 PSTricks 只是为了好玩!

第一条鱼

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\psset
{
    arrows=|<*->|*,
    hatchangle=10,
    hatchsep=2\pslinewidth,
    nrot=:U,
    offset=-4pt,
    unit=2cm,
    runit=\psunit,
}
\usepackage{siunitx}
\begin{document}
\begin{pspicture}[showgrid=false](-3,0)(3,3)
    \pscustom[arrows=-,fillstyle=vlines]
    {
        \psarc(0,0){2.5}{30}{150}
        \psarcn(0,0){3}{150}{30}
        \closepath
    }
    \uput{12pt}[u](0,0){$120^\circ$}
    \psline[arrows=-,linestyle=dashed](2.5;150)(0,0)(2.5;30)
    \pcline(0,0)(2.5;30)
    \nbput{\SI{14}{\cm}}
    \pcline(2.5;30)(3;30)
    \nbput{\SI{7}{\cm}}
\end{pspicture}
\end{document}

在此处输入图片描述

第二个

\documentclass[pstricks,border={20pt 12pt 12pt 20pt}]{standalone}
\usepackage{pst-node}
\psset
{
    arrows=|<*->|*,
    hatchangle=10,
    hatchsep=3\pslinewidth,
    nrot=:U,
    offset=6pt,
    unit=2cm,
    runit=\psunit,
    %linewidth=5pt,
}
\usepackage{siunitx}
\begin{document}
\begin{pspicture}[showgrid=false](4,4)
    \psframe[dimen=monkey,linestyle=dashed](4,4)
    \pscustom[arrows=-,fillstyle=vlines,]
    {
        \psarc(0,4){2}{-90}{0}
        \psline(4,4)
        \psarc(4,2){2}{90}{180}
        \psline(4,2)
        \psarc(4,0){2}{90}{180}
        \psline(2,2)
        \psarc(2,0){2}{90}{180}
        \closepath
    }
    \pcline(0,0)(0,4)
    \naput{\SI{14}{\cm}}
    \pcline(0,4)(4,4)
    \naput{\SI{14}{\cm}}
\end{pspicture}
\end{document}

在此处输入图片描述

最后一个

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\psset
{
    hatchangle=10,
    hatchsep=3\pslinewidth,
    unit=2cm,
    runit=\psunit,
}
\usepackage{siunitx}
\begin{document}
\begin{pspicture}[showgrid=false](-2,-1)(2,2)
    \pscustom[fillstyle=vlines]
    {
        \psarc(0,0){2}{0}{180}
        \psarc(-1,0){1}{180}{360}
        \psarcn(1,0){1}{180}{0}
        \closepath% always close the path before filling. The option linejoin=1 can show the difference between with and without \closepath!
    }
    \psline[linestyle=dashed](-2,0)(2,0)
\end{pspicture}
\end{document}

在此处输入图片描述

答案2

万一 Geogebra 建议的导出代码让你看不懂,这里有一个基本方法,肯定可以改进。但它应该是一个很好的起点。

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}
  \begin{tikzpicture}[>=stealth]
    \coordinate (0:0) node[above=4pt]{\SI{120}{\degree}};
    \draw[dashed] (0:0) -- (150:2.8) (0:0) -- (30:2.8);
    \draw[pattern=north west lines]
      (150:2.8) -- (150:4.2)
      arc[radius=4.2,start angle=150,end angle=30] -- (30:2.8)
      arc[radius=2.8,start angle=30,end angle=150];

    \draw[|<->|,shift={(300:0.2)}] (0:0) -- (30:2.8) node[midway,sloped,below] {14};
    \draw[|<->|,shift={(300:0.2)},shorten <=-\pgflinewidth] (30:2.8) -- (30:4.2) node[midway,sloped,below] {7};
  \end{tikzpicture}

  \begin{tikzpicture}[>=stealth]
    \draw[dashed] (-3.5,-3.5) rectangle (3.5,3.5);
    \draw[pattern=north west lines]
      (-3.5,-3.5) -- (-3.5,0)
      arc[radius=3.5,start angle=270,end angle=360] -- (3.5,3.5)
      arc[radius=3.5,start angle=90,end angle=180]
      arc[radius=3.5,start angle=90,end angle=180];
    \draw[pattern=north west lines]
      (0,-3.5) |- (3.5,0)
      arc[radius=3.5,start angle=90,end angle=180];

    \draw[|<->|] (-3.7,-3.5) -- (-3.7,3.5) node [midway,left] {\SI{14}{\cm}};
    \draw[|<->|] (-3.5,3.7) -- (3.5,3.7) node [midway,above] {\SI{14}{\cm}};
  \end{tikzpicture}

  \begin{tikzpicture}
    \draw[dashed] (-2,0) -- (2,0);
    \draw[pattern=north east lines]
      (-2,0) arc[radius=2,start angle=180,end angle=0]
      arc[radius=1,start angle=0,end angle=180]
      arc[radius=1,start angle=360,end angle=180];
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

通过 Tikz 提供替代方案

在此处输入图片描述

代码

\documentclass[]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\begin{document}
\begin{minipage}[t]{0.3\textwidth}
\begin{tikzpicture}[scale=0.2]
\draw [fill=blue!10,solid] (30:14)--(30:21) arc (30:150:21) -- (150:14) arc (150:30:14);
\draw [dashed] (0,0) -- (30:14) -- (30:21)  
(0,0) -- (150:14)--(150:21);
\draw [|<->|,shift={(0.5,-1)}] (0,0) --node[anchor=north,rotate=30]{14cm} (30:14);
\draw [|<->|,shift={(0.5,-1)}] (30:14) --node[anchor=north,rotate=30]{7cm} (30:21) ;
\node [above] at (0,0) {$120^\circ$};
\end{tikzpicture}
\end{minipage}
\hspace{4cm}
\begin{minipage}[t]{0.3\textwidth}
\begin{tikzpicture}[scale=0.2]
\path [fill=blue!10] (0,0) rectangle (14,14);
\draw [|<->|] (0,14.5) -- node[above]{14cm} (14,14.5);
\draw [|<->|] (-0.5,0) -- node[xshift=-0.3cm,rotate=90]{14cm} (-0.5,14);
\filldraw[white] (14,7) -- (14,14) arc (90:180:7) 
(7,0) -- (7,7) arc (90:180:7)
(14,0) -- (14,7) arc (90:180:7)
(0,14) -- (0,7) arc (-90:0:7);
\draw [dashed] (0,0) -- (0,14)--(14,14)--(14,0)--cycle;
\end{tikzpicture}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[t]{0.3\textwidth}
\begin{tikzpicture}
\begin{scope}   
\clip (0,0) circle (1cm);
\fill[fill=blue!10] (-1,0) rectangle (1,1);
\end{scope}     
\begin{scope}
\clip (-0.5,0) circle (0.5cm);
\fill[fill=blue!10] (-1,1) rectangle (0,-1);
\end{scope}
\begin{scope}
\clip (0.5,0) circle (0.5cm);
\fill[white] (-1,0) rectangle (1,1);
\end{scope}
\draw [dashed] (-1,0)--(1,0);
\end{tikzpicture}
\end{minipage}
\end{document}

相关内容