File:WaveReflect.gif

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

WaveReflect.gif(251 × 343 pixels, file size: 411 KB, MIME type: image/gif, looped, 55 frames, 5.5 s)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: Reflection of a wave at fixed/loose end.
Deutsch: Reflektion einer Welle am festen/losen Ende.
Date
Source Own work
Author And1mu

Source Code[edit]

created with LaTeX and PGF/TikZ

Script to create the animation:

#!/bin/bash

set -eu
DIR="animate"
FILE="WaveReflect"

NUM=0
rm -f ${DIR}/frame???.png
for ANG in $(seq -0.94 0.22 11) ; do
    echo "Creating frame $NUM ..."
    POS=$ANG
    echo $POS $ANG
    sed -i "s/\\\def\\\myt{.\+}/\\\def\\\myt{$POS}/" ${FILE}.tex
    pdflatex -shell-escape ${FILE}.tex 1> /dev/null
    echo "Convert to png ..."
    NUMSTR=$(printf "%03d" $NUM)
    convert -density 100 ${FILE}.svg -shave 3 ${DIR}/frame${NUMSTR}.png
    NUM=$(($NUM+1))
done
cd $DIR
convert -delay 10 -loop 10000 frame*.png  ${FILE}.gif
cd -

The code to create a single frame:

\documentclass[crop,border=3,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg
    \infile\space\outfile}},multi=false]{standalone}
\usepackage{ifthen}
\usetikzlibrary{math,decorations.pathmorphing,patterns}

\begin{document}

\def\myt{4.78}
\def\mypi{3.141592653589793}

\newcommand{\wave}[4]{
  \def\myA{#1}
  \def\mya{#2}
  \def\myB{#3}
  \def\myb{#4}
  \draw[ultra thick,blue,smooth,domain=0:5,samples=50] plot
  function {\myA*exp(-\mya*(10-x-\myt)**2)+\myB*exp(-\myb*(x-\myt)**2)};

  \foreach \a in {0,0.2,...,5}{
    \tikzmath{\myy=
      \myA*exp(-\mya*(10-\a-\myt)^2)+\myB*exp(-\myb*(\a-\myt)^2);
    }
    \tikzmath{\myv=0.4*(
      \mya*(10-\a-\myt)* \myA*exp(-\mya*(10-\a-\myt)^2)+\myb*(\a-\myt)*\myB*exp(-\myb*(\a-\myt)^2));
    }
    \fill[red] (\a,\myy) circle (0.6mm);

    \pgfmathparse{\a==4?1:0}
    \ifthenelse{\lengthtest{\myv pt > 0.1 pt} \OR \lengthtest{\myv pt < -0.1 pt}}{
      \draw[thick,->,tips=proper] (\a,\myy) -++ (0,\myv);
    }{
      \draw[thick] (\a,\myy) -++ (0,\myv);
    }
  }
}

\begin{tikzpicture}[>=latex,scale=1]
  \fill[white] (-0.5,-5.3) rectangle (6,3.5);
  %\draw[thick,->] (0,-0.3) -- (0,2.8) node[above]{\Large $y$};
  %\draw[thick,->] (-0.1,0) -- (5.5,0) node[below]{\Large $x$};
  \foreach \a in {-0.5,0,...,2.5}{
    \draw[dotted] (0,\a) -- (5.5,\a);
  }
  \wave{1.5}{5}{1.5}{5}
  %\fill[white] (5,-2) rectangle (10,2);
  \begin{scope}[shift={(0,-2.8)}]
    %\draw[thick,->] (0,-1.7) -- (0,1.8) node[above]{\Large $y$};
    %\draw[thick,->] (-0.1,0) -- (5.5,0) node[below]{\Large $x$};
    \foreach \a in {-1.5,-1,...,1.5}{
      \draw[dotted] (0,\a) -- (5.5,\a);
    }
    \wave{-1.5}{5}{1.5}{5}
    %\fill[white] (5,-2) rectangle (10,2);
    \fill[pattern = north east lines] (5,-1) rectangle (5.3,1);
    \draw[ultra thick] (5,-1) -- (5,1);
  \end{scope}
\end{tikzpicture}
\end{document}

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:44, 3 April 2016Thumbnail for version as of 15:44, 3 April 2016251 × 343 (411 KB)And1mu (talk | contribs)remove coordinate system, it's not relevant
09:31, 1 April 2016Thumbnail for version as of 09:31, 1 April 2016251 × 343 (449 KB)And1mu (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: