Incidence angle correct principle

Hello everyone, what are the specific formulas and rules for the process from the incident angle to the local incident angle?

I donnot find the code from github, sorry for that ! Anybody can help me find that? (the incidence angle correct , get local incidence angle )
Thank you !!!