34

Are the tikzducks used to explain any scientific stuff?

I'm currently compiling a list of such applications for an upcoming talk, so even if you are not able to share your image, it would be helpful to hear examples of topics the tikzducks are used for.

Please note, that no ducks may be harmed in your answers

  • 16
    Isn't this question just off-topic? Ducks are flooding the site and are used as rep generators. :-/ – Johannes_B Mar 25 '18 at 9:04
  • 2
    @Johannes_B If you are worried about the rep, I can turn it into a CW question. But I don't think it is off topic - it is about the application of a package, for which I like to collect examples in preparation of a talk at a tex user group meeting. – user36296 Mar 25 '18 at 10:03
  • 3
    \let\qed=\duck gets a duck at the end of every proof. – Loop Space Mar 25 '18 at 16:25
  • 5
    @LoopSpace qed is short for quack erat demonstrandum, isn't it? – user36296 Mar 25 '18 at 17:26
  • 3
    @samcarter Or quod erat duck. – Loop Space Mar 25 '18 at 18:44

12 Answers 12

28

Using the wake of a duck to explain the opening angle of Cherenkov light

(See https://physics.stackexchange.com/a/9483 for more details about this analogy)

\documentclass{standalone}
\usepackage{tikzducks}

\begin{document}

\begin{tikzpicture}
  \begin{scope}[scale=0.5,xshift=-23,yshift=320] 
    \duck
  \end{scope}  
  \draw[black] 
    (10,6) circle (4.45)
    (9,6) circle (4)  
    (8,6) circle (3.55)
    (7,6) circle (3.1)  
    (6,6) circle (2.68)
    (5,6) circle (2.24)  
    (4,6) circle (1.8)
    (3,6) circle (1.35)  
    (2,6) circle (0.9)            
    (1,6) circle (0.47)      
  ; 
  \draw[blue,thick] 
    (12,0) -- (0,6) -- (12,12)
    (0,6) -- (15,6)
    (8.15,1.96) -- (10,6) -- (8.15,10.04)
    (8.8,6)arc(180:120:1.345551)
  ;
  \draw[thick,rotate=26.5,blue,->]   (4,5.35) -- ++(0,0.8);
  \draw[thick,rotate=26.5,blue,->]   (6,5.35) -- ++(0,0.8);
  \draw[thick,rotate=26.5,blue,->]   (8,5.35) -- ++(0,0.8);
  \draw[thick,rotate=26.5,blue,->]   (10,5.35) -- ++(0,0.8);
  \draw[thick,rotate=26.5,blue,->]   (12,5.35) -- ++(0,0.8);
  \draw[thick,rotate=26.5,blue,->]   (14,5.35) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (-1.4,4.55) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (0.6,4.55) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (2.6,4.55) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (4.6,4.55) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (6.6,4.55) -- ++(0,0.8);
  \draw[thick,rotate=-26.5,blue,<-]   (8.6,4.55) -- ++(0,0.8);  
  \node at (9.35,6.4) {\Large $\Theta_{c}$};
\end{tikzpicture}

\end{document}

enter image description here


Improved 3D version by @marmot

from https://chat.stackexchange.com/transcript/message/43703817#43703817

\documentclass{standalone}
\usepackage{tikzducks}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{0}{0}
\begin{tikzpicture}
\begin{scope}[scale=0.5,xshift=-20,yshift=-20]
\duck
\end{scope}
\tdplotsetrotatedcoords{-30}{40}{45}
\begin{scope}[tdplot_rotated_coords]
\foreach \X in {1,...,10}
{
\draw[black] (0,0,\X) circle ({\X*0.45});
\draw[thick,blue,->] (0,{\X*0.45},\X) -- ++(0,0.32,{-0.3*0.45});
\draw[thick,blue,->] (0,{-\X*0.45},\X) -- ++(0,-0.32,{-0.3*0.45});
}
\draw[blue,thick]
(0,4.5,10) -- (0,0,0) -- (0,-4.5,10)
(0,0,0) -- (0,0,14.5) coordinate (P)
(0,4.5,10) -- (0,0,14.5) -- (0,-4.5,10);
\coordinate (M) at (0,0,10);
\end{scope}
\tdplotsetrotatedcoords{-120}{150}{0}
\begin{scope}[tdplot_rotated_coords,red]
\draw (M) arc (-90:-57:3) node[midway,right,yshift=-5]{\Large $\Theta_{c}$};
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

27

It is possible to form a grammatical English sentence of length n, using only the words "duck" and "ducks", for all values of n.

Using tikzducks perhaps makes the visualization of the structures easier.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\usepackage{tikzducks}
\usepackage[linguistics]{forest}
\usepackage{multicol}
\newcommand{\Ducks}{\begin{tikzpicture}[scale=.2]\duck\begin{scope}[xshift=1.5cm]\duck\end{scope}\end{tikzpicture}}
\let\ducks\Ducks
\usepackage{gb4e}
\begin{document}
\begin{theorem}
For any $n$, there is a grammatical English sentence of length $n$ consisting only of some combination of the words \emph{duck} and \emph{ducks}.  
\end{theorem}
Here are the first $6$ (with very simplified trees).
\begin{multicols}{2}
\begin{exe}
\ex Duck!
\ex Ducks duck.
\ex Ducks duck ducks.
\ex Ducks ducks duck duck.
\ex Ducks ducks duck duck ducks.
\ex Ducks ducks ducks duck duck duck.
\end{exe}
\columnbreak\setcounter{exx}{0}
\begin{exe}
\ex Duck!
\ex \Ducks{} duck.
\ex \Ducks{} duck \ducks.
\ex \Ducks{} \ducks{} duck duck.
\ex \Ducks{} \ducks{} duck duck \ducks.
\ex \Ducks{} \ducks{} \ducks{} duck duck duck.
\end{exe}
\end{multicols}
\setcounter{exx}{0}
\begin{multicols}{2}
\begin{exe}
\ex\begin{forest}
[S [NP\\pro ] [VP [V\\duck ]]]
\end{forest}
\ex\begin{forest}
[S [NP\\\Ducks ] [VP [V\\duck]]]
\end{forest}
\ex\begin{forest}
[S [NP\\\Ducks ] [VP [V\\duck ] [NP\\\ducks ]]]
\end{forest}
\ex\begin{forest}
[S [NP [NP\\\Ducks ][S [NP\\\Ducks ] [VP [V\\duck]]]] [VP [V\\duck]]]
\end{forest}
\ex
\begin{forest}
[S [NP [NP\\\Ducks ][S [NP\\\Ducks ] [VP [V\\duck]]]] [VP [V\\duck ] [NP\\\ducks ]]]
\end{forest}
\ex
\begin{forest}
[S [NP [NP\\\Ducks ][S [NP [NP\\\Ducks ][S [NP\\\Ducks ] [VP [V\\duck]]]] [VP [V\\duck]]]][VP [V\\duck]]]
\end{forest}
\end{exe}
\end{multicols}
\end{document}

output of code

  • Wow! The only stopping criterion is how often one can say ducks duck in a row without getting confused :) – user36296 Mar 25 '18 at 14:26
  • 5
    Now we just need a tikzbuffalo package. – Richard Mar 25 '18 at 15:47
26

enter image description here

\documentclass{article}
\usepackage{tikzducks}
\begin{document}
\section*{Length contraction}
\begin{tabular}{ccc}
 $v=0$ & $v=0.5\cdot c$ & $v=0.9\cdot c$\\
 \begin{tikzpicture}
 \path[use as bounding box](0,0) rectangle (2.4,2.4);
 \duck
 \end{tikzpicture}
 &
 \begin{tikzpicture}
 \path[use as bounding box](-0.25,0) rectangle (2.15,2.4);
 \pgftransformcm{sqrt(1-0.5^2)}{0}{0}{1}{\pgfpoint{0cm}{0cm}} 
 \duck
 \end{tikzpicture}
 &
 \begin{tikzpicture}
 \path[use as bounding box](-0.5,0) rectangle (1.9,2.4);
 \pgftransformcm{sqrt(1-0.9^2)}{0}{0}{1}{\pgfpoint{0cm}{0cm}} 
 \duck
 \end{tikzpicture}
\end{tabular}\\
Don't worry, the ducks are fine!
\end{document}

Just for fun: rocket ducks.

\documentclass{article}
\addtolength{\textwidth}{2cm}
\usepackage{tikzducks}
\usetikzlibrary{shadings,fadings}
\newcommand{\RocketDuck}{ \duck
 \shade[ball color=blue,opacity=0.15] (1,1) circle (1.3);
 \fill [color=orange,path fading=east] (3.9,-0.75) 
 -- ++({3*cos(25)},{3*sin(25)}) arc (25:-25:3) 
 -- ++ ({-3*cos(25)},{3*sin(25)}) -- cycle;
 \shade[bottom color=red,top color=red!25!white] (4,0.25) arc (90:-90:0.25 and 1) -- (-2,-1.75) 
 arc (-90:90:0.25 and 1) -- cycle;
 \shade[bottom color=blue,top color=blue!25!white] (-2,-1.75) arc (-90:90:0.25 and 1) 
 -- (-3.2,-0.75) -- cycle;
}
\begin{document}
\section*{Length contraction (Don't worry, the ducks are fine!)}
 \begin{tikzpicture}
 \draw[ultra thick,-latex] (-1,1.8) -- (-3,1.8) node[midway,above]{$v=0$};
 \RocketDuck
 \begin{scope}[yshift=-5cm]
 \draw[ultra thick,-latex] (-1,1.8) -- (-3,1.8) node[pos=0.45,above]{$v=0.5\cdot c$};
 \pgftransformcm{sqrt(1-0.5^2)}{0}{0}{1}{\pgfpoint{0cm}{0cm}} 
 \RocketDuck
 \end{scope}
 \begin{scope}[yshift=-10cm]
 \draw[ultra thick,-latex] (-1,1.8) -- (-3,1.8) node[pos=0.45,above]{$v=0.9\cdot c$};
 \pgftransformcm{sqrt(1-0.9^2)}{0}{0}{1}{\pgfpoint{0cm}{0cm}} 
 \RocketDuck
 \end{scope}
 \end{tikzpicture}
\end{document}

enter image description here

  • Ducks in Space? :D – user31729 Mar 25 '18 at 21:18
  • 2
    @ChristianHupfer You are worried about egreg's reaction, right? He's a bit allergic to space(s)... ;-) – marmot Mar 25 '18 at 21:53
25

Here's my math joke about the formula calculating the volume of cylinder/disk which might be easier remembered by students/pupils:

The chef duck is perfectly suited for this:

enter image description here

\documentclass[10pt]{article}

\usepackage[most]{tcolorbox}
\usepackage{amsmath}
\usepackage{tikzducks}


\begin{document}
\boldmath
\begin{tcbraster}[raster columns=2,raster rows=2,height=15cm,raster equal height]
\begin{tcolorbox}[height=0.5\linewidth,valign=center,halign=center,width=0.5\linewidth,enhanced, fontupper={\large},colback=yellow!20!white, circular arc, drop shadow]

  What is the formula for the volume of a cylinder with

  \begin{itemize}
  \item radius $z$ 
  \item[]  and
  \item height $a$
  \end{itemize}


  ?
\end{tcolorbox} 
\begin{tcolorbox}[drop shadow,colback=yellow!20!white]
\begin{tikzpicture}[scale=2.5]
\duck[chef=white!95!yellow,
rollingpin=brown!80!black, think={$ V = pi \cdot z \cdot z \cdot a$}]
\end{tikzpicture}
\end{tcolorbox}
\end{tcbraster} 
\end{document}

No ducks were harmed → they are just the pizza chefs...

  • can ducks be used rather than rabbit in Fibonacci sequence ? – touhami Mar 25 '18 at 7:04
  • 1
    You last statement is only true of the duck chefs are not forced to make pineapple pizza :) – user36296 Mar 25 '18 at 10:25
  • 1
    @samcarter: They are not physically harmed... although being forced to use delicious pizza dough in conjunction with pineapple could make them mad, of course ;-) – user31729 Mar 25 '18 at 10:27
  • I was about asking a stupid question about nomenclature ;-) – AlexG Mar 25 '18 at 11:08
  • @AlexG: Nomenclature? Good pizza vs. Evil pizza ? – user31729 Mar 25 '18 at 11:24
22

In order to add some chemistry to this list, here is a laboratory duck helping to explain the concept of chirality.

enter image description here

\documentclass{standalone}
\usepackage{tikzducks}
\usepackage{chemfig}
\usepackage{arydshln}
\begin{document}
\colorbox{black!20!white}{
\begin{tabular}{c:c}
\begin{tikzpicture}[xscale=-1,transform shape]
    \duck[glasses=gray,tshirt=black!10!white,jacket=white]
    \path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw,clip] (-0.5,1.75) to[rounded corners=2pt]++(0,-1)to[rounded corners=2pt]++(-1,-2.5)to[rounded
corners=2pt, bend right=10pt]++(3,0) to[rounded corners=2pt]++(-1,2.5)--++(0,1)++(-0.5,0) circle [x radius=0.5, y radius=0.1];
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,fill=green!90!black](-1.6,-2) rectangle (1.6,{1cm-2cm});
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,fill=green!90!white] (0,1cm-2cm) circle [x radius=1.5cm-(1cm-0.25cm)*0.4 , y radius=0.1 cm];
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0,0) circle (5pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (-0.2,0.75) circle (3pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0.25,1.15) circle (2pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0,1.4) circle (4pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (-0.25,-0.5) circle (3pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0.25,-1) circle (5pt);
\end{tikzpicture}
&
\begin{tikzpicture}
   \duck[glasses=gray,tshirt=black!10!white,jacket=white]
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw,clip] (-0.5,1.75) to[rounded corners=2pt]++(0,-1)to[rounded corners=2pt]++(-1,-2.5)to[rounded
corners=2pt, bend right=10pt]++(3,0) to[rounded corners=2pt]++(-1,2.5)--++(0,1)++(-0.5,0) circle [x radius=0.5, y radius=0.1];
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,fill=green!90!black](-1.6,-2) rectangle (1.6,{1cm-2cm});
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,fill=green!90!white] (0,1cm-2cm) circle [x radius=1.5cm-(1cm-0.25cm)*0.4 , y radius=0.1 cm];
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0,0) circle (5pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (-0.2,0.75) circle (3pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0.25,1.15) circle (2pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0,1.4) circle (4pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (-0.25,-0.5) circle (3pt);
\path[xshift=35,yshift=20,scale=0.2,rotate=-10,draw=black,  line width=0.2pt, fill=green!70!white] (0.25,-1) circle (5pt);
\end{tikzpicture}
\\[0.25cm]
\scalebox{0.6}{\chemfig{A-[:30](-[:90]B)(<:[:-10]C)(<[:-50]D)}}
&
\scalebox{.6}{\chemfig{A-[:150](-[:90]B)(<:[:190]C)(<[:230]D)}}
\end{tabular}
}

\end{document}

PS: Thanks to appropriate personal protective equipment (safety glasses and a lab coat) no ducks were harmed during the experiments...

The code for the erlenmeyer flask is heavily inspired frome this question: tikz and \pgfdeclareshape why the text is not at the center anchor?

  • Fantastic! I hope the duck does not blow up anything :) – user36296 Mar 25 '18 at 14:44
  • FYI: the next version of the tikzducks will include buttons for the lab coat i.stack.imgur.com/bXN1a.png – user36296 Mar 26 '18 at 14:19
  • @samcarter: As long as the duck keeps in mind the hazard and precautionary statements, nothing will be blown up by accident. Thanks for including the buttons. With them the lab coat looks a lot more realistic. – leandriis Mar 26 '18 at 18:56
17

Moebius Duck's evocation

enter image description here

\documentclass[margin=1cm,tikz]{standalone}
\usepackage{luatex85,tikzducks,ifthen}
\usetikzlibrary{calc}

\begin{document}

\foreach \frame in {0,...,81} {%

\pgfmathtruncatemacro{\x}{mod(\frame,41)}

\ifthenelse{\x>64 \OR \x<4}{\def\Orient{-1}}{\def\Orient{1}}

\begin{tikzpicture}[x  = {(1cm,0cm)},
                    y  = {(45:.5cm)},
                    z  = {(0cm,1.5cm)},
                    scale=3]

\foreach \L [count=\z from -2, evaluate=\z as \y using \z/4 ] in {A,...,E} {%
    \foreach \x [count=\n from 0] in {0,9,...,360} {%
        \pgfmathsetmacro{\T}{1+0.5*\y*cos(\x/2)}
        \pgfmathsetmacro{\X}{\T*cos(\x)}
        \pgfmathsetmacro{\Y}{\T*sin(\x)}
        \pgfmathsetmacro{\Z}{0.5*\y*sin(\x/2)}
        \path (\X,\Y,\Z) coordinate (\L\n)
            ;
    }
}


    \ifthenelse{\frame=62 \OR \frame=63}{%
    \begin{scope}[x={(1cm,0cm)},
                    y={(0cm,1cm)},
                    shift={($(C\x)-(.05,.03)$)},
                    scale=.05]
    \duck
    \end{scope}}{}



\foreach \i  [evaluate=\i as \j using int(\i+1),
            evaluate=\i as \K using 80-30*cos(9*(\i-22.5))
            ] in {0,1,...,39} {%
    \ifthenelse{\frame=18 \AND \i>17 \AND \i<20}{%
    \begin{scope}[x={(1cm,0cm)},
                    y={(0cm,1cm)},
                    shift={($(C18)-(.05,.03)$)},
                    scale=.05]
    \duck
    \end{scope}}{}
    \draw[smooth,gray,fill=orange!25!white!\K!blue]
                (A\i) -- (E\i) -- (E\j) -- (A\j) -- cycle ;
    \draw[smooth,gray] (B\i) -- (B\j) (D\i) -- (D\j) ;
    \draw[smooth,thick] (C\i) -- (C\j) ;
}

    \ifthenelse{\frame<18 \OR \frame>63}{%
    \begin{scope}[x={(1cm,0cm)},
                    y={(0cm,1cm)},
                    shift={($(C\x)-(.05,.03)$)},
                    scale=.05]
    \duck
    \end{scope}}{}


\end{tikzpicture}   }

\end{document}
15

I will admit that this was slightly inspired by this question, but here is a genuine worksheet that I used today.

Projectiles with ducks

  • 3
    Are you sure this duck didn't get harmed? – gusbrs Mar 26 '18 at 21:13
  • @gusbrs It was given the Easter egg as a reward for all its hard work. – Loop Space Mar 26 '18 at 21:21
  • Ah!, just like the human cannonball, I see. :) But I suppose it is fair to admit tikzducks are even more resistant than rubber-ducks. – gusbrs Mar 26 '18 at 21:26
  • Very nice answer! – user36296 Mar 27 '18 at 8:57
13

Ducks preserve the amount of movement

enter image description here

\documentclass[tikz,margin=1cm]{standalone}
\usepackage{tikzducks,luatex85,ifthen}
\usetikzlibrary{calc,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\newcommand{\Duck}[1]{%
\begin{scope}[scale=\scl,shift={(-1.05,-1.075)}]
\clip (.1,.1) rectangle (2.1,2.15) ;
\coordinate (dck) at (1.05,1.075) ;
\duck
\end{scope}
\begin{pgfonlayer}{background}
\draw[gray!25] (dck) -- (A#1) ;
\end{pgfonlayer}
}

\begin{document}

\def\pas{.434}
\def\scl{.22}

\foreach \x in {-9,...,9,8,7,...,-8} {%


\begin{tikzpicture}

\path[use as bounding box] (-2,0) rectangle (4,1.5) ;

\foreach \i [evaluate=\i as \j using (\i-1)*\pas] in {0,...,6} {%
\coordinate[] (A\i) at (\j,1.5) ;
\fill (A\i) circle (1pt) ;
}

\ifthenelse{\x<0}{%
    \pgfmathsetmacro{\L}{-90+60*sin(10*\x)}
    \gdef\R{-90}
    }{%
    \gdef\L{-90}
    \pgfmathsetmacro{\R}{-90+60*sin(10*\x)}
    }

\begin{scope}[shift=($(A6)+(\R:1.5)$)]
\Duck{6}
\end{scope}

\begin{scope}[shift=($(A0)+(\L:1.5)$)]
\Duck{0}
\end{scope}


\foreach \i in {1,...,5} {%
    \begin{scope}[xshift=\pas*\i cm -\pas cm]
    \Duck{\i}
    \end{scope}
}


\end{tikzpicture}}
\end{document}
  • 1
    Really awesome! – user36296 Apr 5 '18 at 9:09
12

It can be used to illustrate Occam's razor, which could be argued to be the epitome of scientific guessing:

If it looks like a duck, floats like a duck, and bobs its head like a duck, then obviously it is a duck! (Even if it is just a toy duck.)

toy duck

  • 1
    Of course this raises the very tricky question of whether a "toy duck" is in fact a duck. – Alan Munn Mar 25 '18 at 14:06
  • 1
    @AlanMunn: That's a very interesting question, and incidentally I thought a lot about that very question before. My conclusion is that linguistically a "toy duck" is in fact a "duck", because an adjective can be treated as a function that on an input noun phrase produces an output that is also a noun phrase, appropriately modified from the input. There are 2 sorts of adjectives. One sort is an operator on its domain; its domain is closed under it. The other sort is not an operator on its domain. The adjective "toy" is an operator, while the adjective "fake" is not. – user21820 Mar 25 '18 at 14:52
  • @AlanMunn: Anyway, I deliberately made the example comical, rather than serious, and it's up to the dear reader to come up with the hard questions in philosophy of science/language. =D – user21820 Mar 25 '18 at 14:54
  • Well as my dissertation advisor once said: which would you prefer to be shot with, a gun or a toy gun? So it's not clear that 'toy' is substantially different from 'fake'. – Alan Munn Mar 25 '18 at 14:56
  • @AlanMunn: You're making a fallacious argument here. A brown duck is a duck. And a yellow duck is also a duck. But a brown duck is certainly not a yellow duck. Similarly, a toy gun is a gun, but that does not mean all guns are identical to a toy gun. – user21820 Mar 25 '18 at 15:09
11

The Doppler Duck's affect

enter image description here

\documentclass[margin=1cm,tikz]{standalone}
\usepackage{luatex85,tikzducks,ifthen}
\usetikzlibrary{calc,decorations.markings,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\begin{document}

\foreach \i [count=\frame from 1] in {-12.5,...,12.5} {

\ifthenelse{\frame>14}{\def\K{blue}}{\def\K{red}}

\begin{tikzpicture}

\def\X{15}
\def\Y{2}

\filldraw[gray!50,transform canvas={xslant=2}] (-\X,-\Y) -- (\X,-\Y) -- (\X,\Y) -- (-\X,\Y) -- cycle ;


\draw[line width=5pt,
    white,
    transform canvas={xslant=2},
    dash pattern=on 20mm off 8mm] (-\X,0) -- (\X,0) ;

    \begin{pgfonlayer}{foreground}
    \begin{scope}[shift={(\i,-.9)},xscale=-1]
    \ifthenelse{\frame=14}{%
        \duck[speech={Coin !},bubblecolour=white!95!yellow]}{%
        \duck
        }
    \coordinate (LH) at (wing) ;
    \end{scope}
    \end{pgfonlayer}

    \begin{scope}[shift={(-\i,.6)}]
    \duck
    \coordinate (RH) at (wing) ;
    \end{scope}

    \path[decoration={%
    markings,% switch on markings
    mark=between positions .18 and .98 step 0.2 with {
        \draw[ultra thick,\K] (0,0)
            arc (0:15:\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) ;
        \draw[ultra thick,\K] (0,0)
            arc (0:-15:\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) ;
        }
    },
    postaction={decorate}] (LH) -- (RH) ;

\end{tikzpicture}
}
\end{document}

The redshift version :

enter image description here

\documentclass[margin=1cm,tikz]{standalone}
\usepackage{luatex85,tikzducks,ifthen}
\usetikzlibrary{calc,decorations.markings,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}


\begin{document}

\foreach \i [count=\frame from 1] in {-12.5,...,12.5} {

\pgfmathsetmacro{\Koeff}{100*cos(\i/15*90)}

\ifthenelse{\frame<14}{%
    \def\K{yellow!\Koeff!blue}}{%
    \def\K{yellow!\Koeff!red}
}

\begin{tikzpicture}

\def\X{15}
\def\Y{2}

\filldraw[gray!50,transform canvas={xslant=2}] (-\X,-\Y) -- (\X,-\Y) -- (\X,\Y) -- (-\X,\Y) -- cycle ;


\draw[line width=5pt,
    white,
    transform canvas={xslant=2},
    dash pattern=on 20mm off 8mm] (-\X,0) -- (\X,0) ;

    \begin{pgfonlayer}{foreground}
    \begin{scope}[shift={(\i,-.9)},xscale=-1]
    \ifthenelse{\frame=14}{%
        \duck[body=\K,speech={Coin !},bubblecolour=white!95!yellow]}{%
        \duck[body=\K]
        }
    \coordinate (LH) at (wing) ;
    \end{scope}
    \end{pgfonlayer}

    \begin{scope}[shift={(-\i,.6)}]
    \duck[body=\K]
    \coordinate (RH) at (wing) ;
    \end{scope}

\end{tikzpicture}
}
\end{document}
  • @ Tarass Amazing! – user36296 Mar 31 '18 at 13:59
  • @samcarter I wonder if you plane to make a rotative duck shape, let say every 45° ? and btw, duck looses his eyes with xshift=-1, but not with xscale=-1, also with rotate around y. – Tarass Mar 31 '18 at 14:04
  • I'll give it a +1 for the idea, and −1 for the scientific content. Those sound waves, if that is what they are, don't behave like sound waves! But there is potential here. – Harald Hanche-Olsen Mar 31 '18 at 14:08
  • @Tarass Do you have a MWE of the duck losing its eyes? \begin{tikzpicture} \begin{scope}[xshift=-1] \duck \end{scope} \end{tikzpicture} works fine for me – user36296 Mar 31 '18 at 14:09
  • 1
    Don't the ducks see a red shift when moving apart, and a blue shift when approaching each other? – Harald Hanche-Olsen Mar 31 '18 at 14:15
10

Visualization of a sinus function

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc} %probably not needed ...
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{papersize={128mm,96mm},margin=0.5cm} %\textwidth=11.8, \textheight=8.6
\usepackage[x11names]{xcolor}
\usepackage{tikzducks}
\usetikzlibrary{shapes.geometric}
\pagestyle{empty}
\parindent=0pt
\usepackage{eso-pic}
\usepackage{xfp}
\tikzstyle{witchstars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]



\begin{document}
\AddToShipoutPictureBG{%
 \AtPageLowerLeft{%
 \begin{tikzpicture}[overlay,remember picture]
 \fill[DeepSkyBlue3] (0,0) rectangle (\paperwidth,\paperheight);
 \pgfmathsetseed{2}
 \end{tikzpicture}}}

\newcommand\loopmax{30}

\foreach \z in {1,2,...,\loopmax}{%
\begin{tikzpicture}
\path (0,0) rectangle (\textwidth,\textheight);
\begin{scope}[scale=2]
%\draw[domain=0:10, black,smooth]   plot (\x,{sin(\x r)+0.5}) ;
\end{scope}
\begin{scope}[overlay,
              xshift=\fpeval{0.67-\z*(0.67/\loopmax)}\textwidth,
              yshift=\fpeval{sin(\z/\loopmax*2*pi)+0.5}cm ]
\begin{scope}[scale=2]

\duck[witch=black!50!gray,
longhair=red!80!black,
jacket=black!50!gray,
magicwand]
\fill[red] (0,0) node[witchstars,fill=red,inner sep=2.3pt]{};
\end{scope}
\end{scope}
\foreach \y in {1,2,...,\loopmax}{%
 \begin{scope}[overlay,
              xshift=\fpeval{0.67-\y*(0.67/\loopmax)}\textwidth,
              yshift=\fpeval{sin(\y/\loopmax*2*pi)+0.5}cm ]
 \fill[] (0,0) node[witchstars,fill=yellow,inner sep=1.3pt]{};
 \end{scope}
}

\end{tikzpicture}\newpage}

\end{document}
  • 2
    If you rotate the duck as it travels along the curve you can show that the derivative is the cosine as well. – Loop Space Mar 31 '18 at 15:51
8

Here are some ducks illustrating the need for sidelobe supression in radar. (I may have been a little bit inspired by this question, but I used this in a real presentation.)

radar ducks

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, positioning, shapes.arrows}
\usepackage{tikzducks}

%%% extract coordinate
\newdimen\XCoord
\newdimen\YCoord
\newcommand*{\ExtractCoordinate}[1]{\path (#1); \pgfgetlastxy{\XCoord}        
{\YCoord};}%

%%% Waves, source: https://tex.stackexchange.com/questions/423489/concentric-circle-segments-between-two-points-in-tikz/423567#423567 
%#1=Number of waves
%#2 ans #3 point A and B
%#4 Angle of first wave
%#5 Colour of waves
\def\NumSignalsFromToAngle#1#2#3#4#5{%
    \def\NumberSignals{#1}
    \ExtractCoordinate{#2}
    \xdef\Xa{\XCoord}
    \xdef\Ya{\YCoord}
    \ExtractCoordinate{#3}
    \xdef\Xb{\XCoord}
    \xdef\Yb{\YCoord}
    \def\lw {2} %line width
    \pgfmathsetmacro\dist{10*sqrt((\Xb/10-\Xa/10)^2+(\Yb/10-\Ya/10)^2)}
    \pgfmathsetmacro\step{\dist/\NumberSignals}
    \def\offset{0.02*\dist}
    \pgfmathsetmacro\AngleFromAToB{\ifdim\Xb>\Xa atan((\Yb/10-\Ya/10)/(\Xb/10 -\Xa/10))\else \ifdim \Xb<\Xa 180+atan((\Yb/10-\Ya/10)/(\Xb/10 -\Xa/10))\else\ifdim\Ya>\Yb -90\else90\fi\fi\fi}
    \foreach \i in {1,...,\NumberSignals}
        {%
        \coordinate(Point) at ($(#2)+({((\step pt)*(2*\i-1)/2-\offset)*cos(\AngleFromAToB) },{(((\step pt)*(2*\i-1)/2-\offset)*sin(\AngleFromAToB)})$);
        \pgfmathsetmacro\r{\step/2*(2*\i-1)}
        %\l_1=\l_i => \angle_i=\angle_1/(2i-1)
        \pgfmathsetmacro\angle{#4/(2*\i-1)}
        \draw[line width = \lw, #5]  (Point) arc (\AngleFromAToB:    {\AngleFromAToB+\angle/2}:\r pt);
        \draw[line width = \lw, #5]  (Point) arc (\AngleFromAToB:{\AngleFromAToB-\angle/2}:\r pt);
    }
}

\begin{document}

\begin{tikzpicture}
    %%% radar
    \def\h{2} %height
    \def\xd{0.5} %x-depth
    \def\yd{0.12} %y-depth
    \def\xw{1.2}   %x-width
    \def\yw{1} %y-width
    \coordinate (A) at (0,0);
    \coordinate (B) at ($(A) + (\xd,\yd) $);
    \coordinate (C) at ($(B) + (0,\h)$);
    \coordinate (D) at ($(A) + (0,\h)$);
    \coordinate (E) at ($(A) + (-\xw, \yw)$);
    \coordinate (F) at ($(E) + (0, \h)$);
    \coordinate (G) at ($(F) + (\xd,\yd)$);

    \shade[bottom color=gray!90, top color=black!30](A) -- (B) -- (C) -- (D) -- (A);
    \shade[bottom color=gray!80, top color=black!10](A) -- (D) -- (F) -- (E) -- (A);
    \shade[bottom color=gray!80, top color=black!10] (D) -- (C) -- (G) -- (F) -- (D);

    \coordinate (radar) at ($ (A) !0.5! (F)$);

    %%% graduate duck
    \coordinate (T) at ($ (radar) + (-5,0) $);
    \begin{scope}[shift = {($(T) + (-1,-0.4)$)}, scale = 0.5]
        \duck[book=\scalebox{0.6}{$\beta$},
            bookcolour=blue!60!red!70!white,graduate=gray!20!black,
            tassel=red!70!black];
    \end{scope}
    \NumSignalsFromToAngle{6}{radar}{T}{130}{blue!70}
    \NumSignalsFromToAngle{6}{T}{radar}{130}{red!70}
    \coordinate (midpos) at ($(radar) !0.5! (T) $);
    \node[single arrow,fill=red!50, above = of midpos]  {\scriptsize reflected};
    \node[single arrow,fill=blue!50, below = of midpos, shape border rotate = 180]  {\scriptsize emitted};

    %%% kulturman duck 
    \coordinate (T) at ($ (radar) + (-2,2) $);
    \coordinate (R) at ($ (radar) + (0,\h/3) $);
    \begin{scope}[shift = {($(T) + (+0.2,-0.3)$)}, yscale=.5,xscale=-.5]
        \duck[crazyhair, wine=red!70!black];
    \end{scope}
    \NumSignalsFromToAngle{3}{T}{R}{130}{red!70}

    %%% mirror duck
    \coordinate (T) at ($ (radar) + (-0.5,-1.5) $);
    \coordinate (R) at ($ (radar) + (0,-\h/3) $);
    \begin{scope}[shift = {($(T) + (-1,-1)$)}, scale = 0.5]
        \duck[beret=red!40!blue!90!white, signpost, signback=white!80!brown];
    \end{scope}
    \NumSignalsFromToAngle{2}{R}{T}{130}{blue!50}
    \NumSignalsFromToAngle{2}{T}{R}{130}{red!70}

    %%% mystery duck
    \coordinate (T) at ($ (radar) + (-6,-2) $);
    \coordinate (R) at (radar);%($ (radar) + (\xw/2,-\h/3) $);
    \begin{scope}[shift = {($(T) + (0,-0.5)$)}, yscale=.5,xscale=-.5]
        \duck[mask=black,cape=black];
    \end{scope}
    \NumSignalsFromToAngle{7}{T}{R}{130}{red!70}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.