# Formulas to determine the illuminated phase and orientation of the Moon

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.

-
Well phase you could do with just a calendar. Orientation is a whole of a different matter though. – harogaston May 3 '14 at 3:22
Are you familiar with the CSPICE libraries (naif.jpl.nasa.gov/naif/tutorials.html) which already have a routine to do this, and are open source? The computations are accurate, but fairly complicated. – barrycarter Dec 30 '15 at 14:33