35 lines
1.2 KiB
TeX
35 lines
1.2 KiB
TeX
\documentclass[varwidth=13.1cm, border={0.0cm 0.0cm 0.0cm 0.0cm}]{standalone}
|
|
\usepackage{tikz}
|
|
\usepackage[dvipsnames]{xcolor}
|
|
\usepackage{pgfplots}
|
|
\pgfplotsset{compat=1.18}
|
|
\usepackage{amsmath}
|
|
\newcommand{\Clamp}[1]{\operatorname{clamp}#1}
|
|
|
|
\begin{document}
|
|
|
|
\begin{tikzpicture}[scale=0.5]
|
|
|
|
\draw[very thin,color=gray] (-pi * 3,-pi * 1.2) grid (pi * 3, pi * 1.2);
|
|
\draw[->] (-3.2*pi,0) -- (3.2*pi,0) node[right] {$x$};
|
|
\draw[->] (0,-pi * 1.4) -- (0,pi * 1.5) node[above] {$f(x)$};
|
|
|
|
\draw[thick, color=NavyBlue] plot [domain=-pi * 3:pi * 3, samples=100] (\x, {min(max(\x, -pi), pi)} );
|
|
\draw[thick, color=OrangeRed] plot [domain=-pi * 3:pi * 3, samples=1000] (\x, {sin(min(max(\x, -pi), pi) r)} );
|
|
|
|
\node[NavyBlue] at (0, -5.4) {$f(x) = \Clamp(x, -\pi, +\pi) $};
|
|
\node[OrangeRed] at (0, -6.6) {$f(x) = \sin(\Clamp(x, -\pi, +\pi)) $};
|
|
|
|
\draw [dashed, color=ForestGreen] (-2 * pi,-3.8) -- (-2 * pi,3.8) node[above] {$x=-2\pi$};
|
|
\draw [dashed, color=Brown] (2 * pi,-3.8) -- (2 * pi,3.8) node[above] {$x=2\pi$};
|
|
|
|
\draw [dashed, color=Fuchsia] (-3.0,pi) -- (3.0,pi) ;
|
|
\draw [color=Fuchsia] (0, pi + 0.5) node {$y=\pi$};
|
|
|
|
\draw [dashed, color=Peach] (-3.0,-pi) -- (3.0,-pi) ;
|
|
\draw [color=Peach] (0, -pi + 0.5) node {$y=-\pi$};
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{document}
|