Skip to content

Instantly share code, notes, and snippets.

@ppetr
Created March 27, 2015 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppetr/f64c95613ecc481f80a1 to your computer and use it in GitHub Desktop.
Save ppetr/f64c95613ecc481f80a1 to your computer and use it in GitHub Desktop.
Sub/supersonic propeller sound and shock wave diagrams
module Propeller where
import qualified Data.Foldable as F
import Diagrams.Prelude
import Diagrams.Backend.SVG
import Diagrams.Backend.SVG.CmdLine
type Diag = Diagram SVG R2
wave :: Double -> Double -> Diag
wave ang radius = circle radius # translate (r2 (0, 1)) # rotate (ang @@ rad)
waves :: Double -> Diag
waves speed = pad 1.1 $ unitCircle # lc red # lw thick <>
F.foldMap (\i -> let j = i * pi * 2 / density in wave (j * speed) j) [1..count]
where
density = 20
count = density * 3 / 2
example :: Diag
example =
waves 0.6
===
waves 1.0
===
waves 1.3
main = mainWith (example # lw veryThin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment