# The mathML formulae

The width of the field the camera captures is relative to how far away any object is, more precisely:

$\mathrm{tan}\left(\mathrm{fov}/2\right)=\frac{{\mathrm{viewwidth}}_{\mathrm{cm}}/2}{{\mathrm{distance}}_{\mathrm{cm}}}$

which gives us:

${\mathrm{distance}}_{\mathrm{cm}}=\frac{\left({\mathrm{viewwidth}}_{\mathrm{cm}}/2\right)}{\mathrm{tan}\left(\mathrm{fov}/2\right)}$

So what's the view width at the point where the face is? We know that the proportion of the screen the face will fill is given by:

$\mathrm{proportion}=\frac{{\mathrm{facewidth}}_{\mathrm{cm}}}{{\mathrm{viewwidth}}_{\mathrm{cm}}}$

However, this is the same for pixels, so:

$\mathrm{proportion}=\frac{{\mathrm{facewidth}}_{\mathrm{px}}}{{\mathrm{viewwidth}}_{\mathrm{px}}}=\frac{{\mathrm{facewidth}}_{\mathrm{cm}}}{{\mathrm{viewwidth}}_{\mathrm{cm}}}$

And this gives us:

${\mathrm{viewwidth}}_{\mathrm{cm}}=\frac{\left({\mathrm{facewidth}}_{\mathrm{cm}}*{\mathrm{viewwidth}}_{\mathrm{px}}\right)}{{\mathrm{facewidth}}_{\mathrm{px}}}$

Inserting this, we get:

${\mathrm{distance}}_{\mathrm{cm}}=\frac{\left({\mathrm{facewidth}}_{\mathrm{cm}}*{\mathrm{viewwidth}}_{\mathrm{px}}\right)}{\left({\mathrm{facewidth}}_{\mathrm{px}}*2*\mathrm{tan}\left(\mathrm{fov}/2\right)\right)}$

In our case ${\mathrm{viewwidth}}_{\mathrm{px}}$ is the width of the canvas, ${\mathrm{facewidth}}_{\mathrm{px}}$ is the width of the face on the canvas, and we assume ${\mathrm{facewidth}}_{\mathrm{cm}}$ is around 17 cm.