Pgfplot - 绘制滑雪坡的最简单方法

Pgfplot - 绘制滑雪坡的最简单方法

我想使用 pgfplot 绘制下图。我知道 latex 中的基本几何知识,但图中的曲线部分很难理解。

任何帮助,将不胜感激。

在此处输入图片描述

编辑1:抱歉,没有添加我的起始代码。

\begin{tikzpicture}[thick]
\coordinate (W) at (1,4.5);
\coordinate (X) at (0, 0);
\coordinate (Y) at (0, 3);
\coordinate (Z) at (7, 0);
\coordinate (A) at (7,0.5);
\coordinate (B) at (8,1.5);
\coordinate (C) at (8,2);
\draw (X) -- node[pos = 0.5, left, font=\footnotesize] {5.0 m} (Y) -- (W);  
\draw (X) -- node[pos = 0.5, below, font=\footnotesize] {74 m} (Z);
\draw (Z) -- (A) -- (C) -- (B) -- (Z);

\draw (10,1) node {NOT TO SCALE};
\end{tikzpicture}

结果图: 在此处输入图片描述

编辑 2:根据@marmot 的回答,我可以绘制如下所示的图形(加上标签)。

在此处输入图片描述

问题:剩下的唯一问题是如何标记阴影部分。因为我们一边有一个方程式,另外三边有线条。任何帮助都将不胜感激。

编辑 3:我能够使用以下命令进行填充:

\fill [pattern=north west lines, domain=0:500,smooth,variable=\x]
              (X) -- plot ({\x/71.5},{3-\x/222-0.4*sin(\x)}) -- (Z);

在此处输入图片描述 最终的代码如下:

\begin{tikzpicture}[thick]
        \coordinate (W) at (1,4.5);
        \coordinate (X) at (0, 0);
        \coordinate (Y) at (0, 3);
        \coordinate (Z) at (7, 0);
        \coordinate (A) at (7,0.5);
        \coordinate (B) at (8,1.5);
        \coordinate (C) at (8,2);
        \draw (X) -- node[pos = 0.5, left, font=\footnotesize] {5.0 m} (Y) -- (W);  
        \draw (X) -- (Z);
        \draw (Z) -- (A) -- (C) -- (B) -- node[pos = 0.5, right, font=\footnotesize] {28 m}(Z);
        \coordinate (P) at (1.75,0);
        \coordinate (Q) at (1.75,2.1);
        \coordinate (R) at (3.5,0);
        \coordinate (S) at (3.5,2.25);
        \coordinate (T) at (5.25,0);
        \coordinate (U) at (5.25,1.2);
        \draw (P) -- node[pos = 0.5, left, font=\footnotesize] {3.5 m} (Q);
        \draw (R)  -- node[pos = 0.5, left, font=\footnotesize] {4.0 m} (S);
        \draw (T) -- node[pos = 0.5, left, font=\footnotesize] {2.3 m} (U);
        \tkzMarkRightAngle[size=0.2](Z,P,Q);
        \tkzMarkRightAngle[size=0.2](Z,R,S);
        \tkzMarkRightAngle[size=0.2](Z,T,U);
        \draw [dashed] (1.75,2.1) -- (2.75,3.6);
        \draw [dashed] (3.5,2.25) -- (4.5,3.75);
        \draw [dashed] (5.25,1.2) -- (6.25,2.7);
        \draw[domain=0:500,smooth,variable=\x] plot ({\x/71.5},{3-\x/222-0.4*sin(\x)});
        \draw[domain=0:500,smooth,variable=\x] plot ({\x/71.5+1},{4.5-\x/222-0.4*sin(\x)});
        \fill [pattern=north west lines, domain=0:500,smooth,variable=\x]
              (X) -- plot ({\x/71.5},{3-\x/222-0.4*sin(\x)}) -- (Z);
        \draw[latex-latex] (0,-1) -- node [fill=white, font=\footnotesize] {74 m}(7,-1);
        \draw[latex-latex] (8.2,1.5) -- (8.2,2);
        \draw (9,1.75) node {70 cm};
        \draw (8,3) node {NOT TO SCALE};
        \end{tikzpicture}

最后,

  • 为何我的西北线如此“断断续续”?
  • 如果有更简洁的方法来编写此代码,请告诉我。

答案1

只是为了给你一个起点......

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.15,view={10}{10},
/pgfplots/colormap={gray}{rgb255=(155,155,155) rgb255=(225,225,225)}
}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=5-\x-0.8*sin(100*\x);}] 
\begin{axis}[domain=0:5,samples=20,hide axis,shader=interp]
    \addplot3 [surf] {f(x,y)};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:感谢您的 MWE!这是关于斜坡的提案。

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[thick]
        \coordinate (W) at (1,4.5);
        \coordinate (X) at (0, 0);
        \coordinate (Y) at (0, 3);
        \coordinate (Z) at (7, 0);
        \coordinate (A) at (7,0.5);
        \coordinate (B) at (8,1.5);
        \coordinate (C) at (8,2);
        \draw (X) -- node[pos = 0.5, left, font=\footnotesize] {5.0 m} (Y) -- (W);  
        \draw (X) -- (Z);
        \draw (Z) -- (A) -- (C) -- (B) -- node[pos = 0.5, right, font=\footnotesize] {28 m}(Z);
        \coordinate (P) at (1.75,0);
        \coordinate (Q) at (1.75,2.1);
        \coordinate (R) at (3.5,0);
        \coordinate (S) at (3.5,2.25);
        \coordinate (T) at (5.25,0);
        \coordinate (U) at (5.25,1.2);
        \draw (P) -- node[pos = 0.5, left, font=\footnotesize] {3.5 m} (Q);
        \draw (R)  -- node[pos = 0.5, left, font=\footnotesize] {4.0 m} (S);
        \draw (T) -- node[pos = 0.5, left, font=\footnotesize] {2.3 m} (U);
        \tkzMarkRightAngle[size=0.2](Z,P,Q);
        \tkzMarkRightAngle[size=0.2](Z,R,S);
        \tkzMarkRightAngle[size=0.2](Z,T,U);
        \draw [dashed] (1.75,2.1) -- (2.75,3.6);
        \draw [dashed] (3.5,2.25) -- (4.5,3.75);
        \draw [dashed] (5.25,1.2) -- (6.25,2.7);
        \draw[domain=0:500,smooth,variable=\x] plot ({\x/71.5},{3-\x/222-0.4*sin(\x)});
        \draw[domain=0:500,smooth,variable=\x] plot ({\x/71.5+1},{4.5-\x/222-0.4*sin(\x)});
        \fill [pattern=north west lines, domain=0:500,smooth,variable=\x]
              (X) -- plot ({\x/71.5},{3-\x/222-0.4*sin(\x)}) -- (Z);
        \draw[latex-latex] (0,-1) -- node [fill=white, font=\footnotesize] {74 m}(7,-1);
        \draw[latex-latex] (8.2,1.5) -- (8.2,2);
        \draw (9,1.75) node {70 cm};
        \draw (8,3) node {NOT TO SCALE};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容