Graphics

FoV Conversions

\[ f\_x=2\;\arctan\left(\tan\left(\frac{1}{2}\frac{w}{h}f\_y\right)\right) \]
\[ f\_y=2\;\arctan\left(\tan\left(\frac{1}{2}\frac{h}{w}f\_x\right)\right) \]

Audio

Gain and Attenuation

Given \(g\) as linear gain in the range \((0,1]\) and \(a\) as attenuation in \(dB\). Keep in mind that \(\log _{10}(g)\) approaches negative infinity as \(g\) approaches zero – avoid computing the log for small gain values and just return something like \(-96dB\) (silence). As a useful reference points, \(a=-6dB\) for \(g=0.5\), roughly.

\[ a=20\;\log _{10}(g) \]
\[ g=10^{a/20} \]