如何填充由一系列控制点和 x 轴定义的曲线之间的区域?
平均能量损失:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\def\xmin{-30}
\def\xmax{450}
\def\ymin{-30}
\def\ymax{150}
\def\nula{55}
\def\phase{2.2}
\def\myscale{0.5}
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=0.5pt, y=1pt,x=1pt, scale=\myscale]
\draw[->] (\xmin,\nula) -- (\xmax,\nula) node[right] {$t$} coordinate(x axis);
\draw[->] (\phase,\ymin) -- (\phase,\ymax) node[left] {$v(t)$} coordinate(y axis);
\path[name path=fce1,draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00] (2.2036044,23.21323707) .. controls
(2.2036044,23.21323707) and (7.1896734,29.00183707) .. (11.896862,37.80963707) .. controls
(14.463984,42.61313707) and (16.430404,45.91313707) .. (19.958399,53.79007707) .. controls
(23.178819,60.98027707) and (34.001913,68.16119707) .. (44.701755,69.73912707) .. controls
(55.401595,71.31705707) and (62.430335,112.41315707) .. (84.285711,112.14281707) .. controls
(106.14109,111.87247707) and (131.61574,2.01243707) .. (164.28572,1.78563707) .. controls
(196.9557,1.55883707) and (217.37186,52.05023707) .. (217.37186,52.05023707);
\end{scope}
\end{tikzpicture}
\end{document}
我想填充 x 轴和曲线正部分之间的空间(两个零交叉点之间)。我找到了很多例子,但没有找到任何方便的方法。因此,我向社区寻求一些建议。
答案1
有两种\MyPath
表示原始路径的方法
添加以 x 轴结尾的路径的起点和终点:
\draw (\phase,\nula) -- \MyPath -- (217.37186,\nula)
这样,所有操作只需一步即可完成。但是,这种方法会产生一些额外的绘制,这可能是不理想的。
首先填充区域,然后绘制它:
\fill [fill=yellow!10] (\phase,\nula) -- \MyPath -- (217.37186,\nula); \draw \MyPath;
得出的结果是:
我推荐方法#2。
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\newcommand{\MyPath}{%
(2.2036044,23.21323707) .. controls
(2.2036044,23.21323707) and (7.1896734,29.00183707) ..
(11.896862,37.80963707) .. controls
(14.463984,42.61313707) and (16.430404,45.91313707) ..
(19.958399,53.79007707) .. controls
(23.178819,60.98027707) and (34.001913,68.16119707) ..
(44.701755,69.73912707) .. controls
(55.401595,71.31705707) and (62.430335,112.41315707) ..
(84.285711,112.14281707) .. controls
(106.14109,111.87247707) and (131.61574,2.01243707) ..
(164.28572,1.78563707) .. controls
(196.9557,1.55883707) and (217.37186,52.05023707) ..
(217.37186,52.05023707)
}%
\begin{document}
\def\xmin{-30}
\def\xmax{450}
\def\ymin{-30}
\def\ymax{150}
\def\nula{55}
\def\phase{2.2}
\def\myscale{0.5}
\begin{tikzpicture}
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=0.5pt, y=1pt,x=1pt, scale=\myscale]
\path[fill=yellow!10, name path=fce1,draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00]
(\phase,\nula) -- \MyPath -- (217.37186,\nula);
\draw[->] (\xmin,\nula) -- (\xmax,\nula) node[right] {$t$} coordinate(x axis);
\draw[->] (\phase,\ymin) -- (\phase,\ymax) node[left] {$v(t)$} coordinate(y axis);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=0.5pt, y=1pt,x=1pt, scale=\myscale]
\fill [fill=yellow!10] (\phase,\nula) -- \MyPath -- (217.37186,\nula);
\path[name path=fce1,draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00]
\MyPath;
\draw[->] (\xmin,\nula) -- (\xmax,\nula) node[right] {$t$} coordinate(x axis);
\draw[->] (\phase,\ymin) -- (\phase,\ymax) node[left] {$v(t)$} coordinate(y axis);
\end{scope}
\end{tikzpicture}
\end{document}
\end{document}