The phase of the Moon (the bright limb) looks different depending on where on Earth the observer is located and the time of the observation. I've located this video and the accompanying spreadsheet that supposedly handles this sort of calculation, however I am somewhat confused on what formulas are actually used. I would greatly appreciate if someone with a bit more experience could decipher the spreadsheet a bit and perhaps write down or link me to the formulas being used.
I'm most interested in determining the illuminated phase (i.e the size of the bright limb) and the apparent orientation of the illuminated portion relative to the horizon. My goal is to understand how this type of calculation is done, in order to re-implement it in code for an application to use - displaying the typical crescent moon icon for night-time, but at the correct angle for a specific location and time.
PS! First post here, so I hope I have used the correct terminology for things.
EDIT: Eventhough the author of the spreadsheet left an answer to the topic, it doesn't feel like it really answers the question. Not to sound clueless and needy, but the question talks about formulas, which I know can be derived from the spreadsheet, however as I have no idea how to approach this, then the answer I was hoping for would help a bit more.