[Tex/LaTex] Drawing a plane in tikz in 3D with a sine wave

3dtikz-pgf

I am trying to draw a plane with the front edge having a sine wave.

Using the code from this example I can draw it by something like

\documentclass{standalone}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}

\tdplotsetmaincoords{70}{70}
\begin{tikzpicture}[scale=3,tdplot_main_coords]
    \filldraw[draw=red,fill=red!20
    ]          (0,0,-0.5)
            -- (0,1,-0.5)
            -- (0,1,1)
            -- (0,0,1)
            -- (0,{0.1*sin(deg(4*pi*0.975)},0.975)
            -- ...lots more points....
            -- (0,{0.1*sin(deg(4*pi*-0.475)},-0.475)
            -- cycle;
    \draw[thick,->] (0,-0.2,0) -- (0,1.2,0) node[anchor=north west]{$x$};
    \draw[thick,->] (0,0,-0.5) -- (0,0,1.2) node[anchor=south]{$z$};
    \draw[thick,->] (-0.5,0,0) -- (1.2,0,0) node[anchor=north east]{$y$};
\end{tikzpicture}

\end{document}

where I specify all the points on the sine curve manually. There must be a better way of doing this, for example something like

--[domain=1:-0.5] (0,{0.1*sin(deg(4*pi*x)},x)

I've attached my results so far doing it manually. I want to be able to vary the sine wave which is why I want a better way of doing it.

enter image description here

Best Answer

You almost got it. See the code:

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

\usepackage{tikz-3dplot}

\tdplotsetmaincoords{70}{70}

\begin{document}
  \begin{tikzpicture}[tdplot_main_coords]
    \draw [red, fill=red!20, domain=-.5:1, samples=100] plot (0,{.1*sin(deg(4*pi*\x))},\x) -- (0,1,1) -- (0,1,-.5) -- cycle;

    \begin{scope}[->, shorten >= 2mm]
        \draw (-.5,0,0) -- (2,0,0) node {$y$};
        \draw (0,-.5,0) -- (0,2,0) node {$x$};
        \draw (0,0,-.5) -- (0,0,2) node {$z$};
    \end{scope}
  \end{tikzpicture}
\end{document}

rendered image