Understand the mathematical side of the 2D Photo Feature

Hi all,
Have very often implemented the Camera feature into my projects and used the code provided. However, ive recently tried to understand how it works, and although the brief comments at the top are helpful ive realised that I dont really understand what the bigger functions do (have attached a photo for ref).

If anyone could explain a bit more why we do certain things or have a link to a similar implementation that has explanations that would be great.

Cheers all and good health,
T