TikZ:平滑曲线的上包络线

TikZ:平滑曲线的上包络线

我使用绘制两条曲线

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\draw[name path=line 1] plot [smooth, tension=1] coordinates {(0,0) (0.5,0.5) (1, 0)};
\draw[name path=line 2] plot [smooth, tension=1] coordinates {(0,0) (0.5, 0) (1,1)};
\end{tikzpicture}
\end{document}

并且它们至少相交一次:

我怎样才能画出它们的上包络线?如果曲线是已知函数f(x)和的图形g(x),我就可以绘制max(f(x),g(x))

答案1

\clip做了奇妙的事情。

在此处输入图片描述

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip[name path=line 1] plot [smooth, tension=1] coordinates {(0,0) (0.5,0.5) (1, 0)} -- (1,1)--(0,1)--(0,0);
\draw[name path=line 2] plot [smooth, tension=1] coordinates {(0,0) (0.5, 0) (1,1)};
\end{scope}
\begin{scope}
\clip[name path=line 3] plot [smooth, tension=1] coordinates {(0,0) (0.5, 0) (1,1)} -- (0,1)--(0,0);
\draw[name path=line 4] plot [smooth, tension=1] coordinates {(0,0) (0.5,0.5) (1, 0)};
\end{scope}
\end{tikzpicture}
\end{document}

相关内容