Sleeping lights.
ocaml
let v1 t = Float.sin @@ (Float.pi *. t) /. 5.;;
let p = plot v1 0. 20.;;
let a = axis 0. 0.;;
display ~dev:pdf ~output:"v1.pdf" [ Color red; p; Color black; a ]
()
1.2246467991473532e-16
ocaml
va 20.
-4.898587196589413e-16
the ibook g3 debuted with a light on the hinge. this light would 'breath' over time. i like that breathing effect, so lets recreate it.
12 breaths per minute, or 5 seconds per breath, is a decent estimate for a person at rest.
we can get a mildly ok approximation using a sin wave with a 5 second period:
\[\begin{align} v(t) &= \frac{\sin\left(\frac{\pi t}{5} + 1\right)}{2} \end{align}\]
this is ok… but the extremes still feel a little unnatural
when we breath, we like to linger at the extremes for a sec; fully exhaled or fully inhaled.
we can scale the sine wave and clamp it to emulate this:
\[\begin{align} v'(t) &= \texttt{clamp}\left(c\cdot v(t), 0, 1\right) \end{align}\]
giving us a new constant \(c\) to play with.