如何用勾股三角形外的曲线绘制填充形状?

如何用勾股三角形外的曲线绘制填充形状?

我想创建这个,曲线基本上可能只是一个 $\sin(3x) + \log(2x)$ 或类似的函数,所有曲线都位于三角形各边的外部。每条曲线都有不同填充颜色的区域。

在此处输入图片描述

答案1

这些\pic就是为此而制作的。如果您创建了\pic具有所需形状的,则可以将其绘制在任何您想要的位置,调整大小、旋转角度、颜色等。

这是一个具有近似形状的示例(您可以根据您建议的功能或您需要的任何内容更改我的定义):

\documentclass[tikz,border=2mm]{standalone}

\tikzset
{%
   pics/my shape/.style n args={7}{% #1=base lenght,        #2=node (inside),
                                   % #3=node (below left),  #4=node (below center),
                                   % #5=node (below right), #6=node (above right),  
      code={%
        \begin{scope}[scale=#1]
          % shape
          \path[pic actions] (0,0)      to[out=75,in=180] (0.225,0.4) to[out=0,in=180]
                             (0.55,0.2) to[out=0,in=180]  (0.75,0.25) to[out=0,in=105] (1,0) -- cycle;
          % nodes
          \node at (0.5 ,0.1)      {$#2$};
          \node at (0   ,-0.25/#1) {\strut$#3$};
          \node at (0.5 ,-0.25/#1) {\strut$#4$};
          \node at (1   ,-0.25/#1) {\strut$#5$};
          \node at (0.75,0.325)    {\strut$#6$};
        \end{scope}
    }},
}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
% triangle lengths
\def\aa{3}
\def\bb{4}
\pgfmathsetmacro\cc{sqrt(\aa*\aa+\bb*\bb)}
% angle (hypotenuse)
\pgfmathsetmacro\dd{atan(\aa/\bb)}
% triangle
\pic[rotate=\dd,draw=cyan, fill=cyan!30,text=cyan] at (0,0)     {my shape={\cc}{C}{}{c}{}{}};
\pic[rotate=-90,draw=black,fill=gray!30]           at (\dd:\cc) {my shape={\aa}{A}{}{a}{}{}};
\pic[rotate=180,draw=cyan, fill=cyan!50,text=cyan] at (\bb,0)   {my shape={\bb}{B}{}{b}{}{}};
% right angle 
\draw (\bb-0.25,0) |-++ (0.25,0.25);
% shapes
\pic[draw=cyan, fill=cyan!30,text=cyan] at (0,-4) {my shape={\cc}{C}{0}{}{c}{y=f(x)}};
\pic[draw=black,fill=gray!30]           at (0,-6) {my shape={\aa}{A}{0}{}{a}{y=g(x)}};
\pic[draw=cyan, fill=cyan!50,text=cyan] at (0,-8) {my shape={\bb}{B}{0}{}{b}{y=h(x)}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容