我想画一条有限正弦曲线。
我的问题是,我知道如何绘制 1/4 sin
,但不知道如何仅获取其中的一部分。
\setlength{\unitlength}{1mm}
\begin{minipage}{\linewidth}
\begin {nofloat}{figure}
\begin{center}
\begin{tikzpicture}[ cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}, x=1cm, y=1cm]
\colorlet{grey}{black!50}
\draw[-,thick,dashed] (-4,2) node[left] {$UpperLimit$} -- (2,2);
\draw[->,thick] (-4,1) -- (2,1)node[right] {$t$};
\draw[-,thick,dashed] (-4,0) node[left] {$LowerLimit$} -- (2,0);
\draw[->,thick] (-3,-0.5) -- (-3,2.5)node[above] {$\textcolor{grey}{u} |\textcolor{red}{ \ind{u}{Clipped}}$};
\draw[thick, dashed, grey] (-3,1) sin (-2,2.5);
\draw[thick, dashed, grey] (-2,2.5) cos (-1,1);
\draw[thick, dashed, grey] (-1,1) sin (0,-0.5);
\draw[thick, dashed, grey] (0,-0.5) cos (1,1);
\draw[ultra thick, red] (-3,1) sin (-2,2.5);
\draw[ultra thick, red] (-2.53545,2) -- (-1.46455,2);
\draw[ultra thick, red] (-2,2.5) cos (-1,1);
\draw[ultra thick, red] (-1,1) sin (0,-0.5);
\draw[ultra thick, red] (-0.53545,0) -- (0.53545,0);
\draw[ultra thick, red] (0,-0.5) cos (1,1);
% \draw [red,thick,domain=0:-2.53545] plot ( {1.5*sin(\x*2*pi/4)+1});
\end{tikzpicture}
\end{center}
\caption{Effect of the Accuracy Shutdown}
\label{fig:accshut}
\end{nofloat}
\end{minipage}
我想要的是最小值的东西,但我只能生产出最大值的东西。
答案1
在绘制红线之前定义一个剪切区域:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\setlength{\unitlength}{1mm}
\begin{minipage}{\linewidth}
% \begin{nofloat}{figure}
\begin{center}
\begin{tikzpicture}[ cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}, x=1cm, y=1cm]
\colorlet{grey}{black!50}
\draw[-,thick,dashed] (-4,2) node[left] {$UpperLimit$} -- (2,2);
\draw[->,thick] (-4,1) -- (2,1)node[right] {$t$};
\draw[-,thick,dashed] (-4,0) node[left] {$LowerLimit$} -- (2,0);
\draw[->,thick] (-3,-0.5) -- (-3,2.5)node[above] {$\textcolor{grey}{u} |\textcolor{red}{d}$};
\draw[thick, dashed, grey] (-3,1) sin (-2,2.5);
\draw[thick, dashed, grey] (-2,2.5) cos (-1,1);
\draw[thick, dashed, grey] (-1,1) sin (0,-0.5);
\draw[thick, dashed, grey] (0,-0.5) cos (1,1);
{
\clip (-3,0) rectangle (1,2);
\draw[ultra thick, red] (-3,1) sin (-2,2.5);
\draw[ultra thick, red] (-2.53545,2) -- (-1.46455,2);
\draw[ultra thick, red] (-2,2.5) cos (-1,1);
\draw[ultra thick, red] (-1,1) sin (0,-0.5);
\draw[ultra thick, red] (-1,1) sin (0,-0.5);
\draw[ultra thick, red] (-0.53545,0) -- (0.53545,0);
\draw[ultra thick, red] (0,-0.5) cos (1,1);}
% \draw [red,thick,domain=0:-2.53545] plot ( {1.5*sin(\x*2*pi/4)+1});
\end{tikzpicture}
\end{center}
% \caption{Effect of the Accuracy Shutdown}
% \label{fig:accshut}
% \end{nofloat}
\end{minipage}
\end{document}
答案2
另一种方法是使用plot
函数和intersections
:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,intersections}
\begin{document}
\begin{tikzpicture}[
LR/.style = {draw=red, ultra thick, line cap=round},
LG/.style = {draw=gray, thick, dashed, line cap=round},
> = Straight Barb
]
% limit
\def\LLV{1} % <--- for setings of limiter level value
% axis
\draw[->,thick] (-1,0.0) -- ++ (5,0.0) node[right] {$t$};
\draw[->,thick] (0,-2.2) -- ++ (0,4.4) node[above] {\textcolor{gray}{$u|$}%
\textcolor{red}{ $d$}};
% limits
\coordinate (UL) at (-0.5, \LLV);
\coordinate (LL) at (-0.5,-\LLV);
\draw[LG, name path=A]
(UL) node[left] {\textit{UpperLimit}} -- ++ (4,0);
\draw[LG, name path=B]
(LL) node[left] {\textit{LowerLimit}} -- ++ (4,0)
coordinate (LD);
% sinusoide
\draw[thick, dashed, gray, name path=S]
plot[domain=0:6.28, samples=60] (\x/2,{2*sin(\x r)});
\draw[LR,
name intersections={of=A and S, by={u1,u2}}]
(u1) -- (u2);
\draw[LR,
name intersections={of=B and S, by={l1,l2}}]
(l1) -- (l2);
% cliped sinusoide
\clip (UL) rectangle (LD);
\draw [LR]
plot[domain=0:6.28, samples=60] (\x/2,{2*sin(\x r)});
\end{tikzpicture}
\end{document}
通过设置,\LLV
您可以轻松更改限制器夹紧水平。这为所提出的解决方案提供了额外的灵活性。