|The angle to refract, in degrees
|The mirror angle to refract from, in degrees
|The refraction index of the input angle
|The refraction index of the mirror
Refractions are sided, meaning the resulting refraction angle depends on which direction the input angle is coming from (relative to the orientation of the mirror "line"). Angles between 0-180 degrees are considered to be inside the refractive surface, whereas angles between 180-360 degrees are considered to be outside. A mirror angle of 0 degrees is considered horizontal.
How much an angle refracts depends on the difference between the substance it is coming from and the substance it is going into. The refractivity of a substance is called the "refraction index". Indices are given for both the area outside and inside the mirror "line", where, for example, an index of 1.0 is a vacuum, 1.0003 is air, 1.333 is water, and 2.42 is diamond. Mathematically, refraction index typically ranges from 1.0-3.0, no less or greater.
In addition to controlling the amount of refractivity, these indices also determine the refraction "critical angle", at which point internal refractions will become reflections instead. Higher index equals lower critical angle, refracting sharp angles only and merely reflecting the rest (which is responsible for that diamond glitter!).
See the included interactive demo for a visual example of this function!