Refractive index is a function of velocity in the medium.How is this related to deviation angle inside the medium? I am not asking for the known formula,but for the mechanism behind it.
In optics, Fermat's principle or the principle of least time is the principle that the path taken between two points by a ray of light is the path that can be traversed in the least time. A more modern statement of the principle is that rays of light traverse the path of stationary optical length with respect to variations of the path. In other words, a ray of light prefers the path such that there are other paths, arbitrarily nearby on either side, along which the ray would take almost exactly the same time to traverse. Fermat's principle can be used to describe the properties of light rays reflected off mirrors, refracted through different media, or undergoing total internal reflection. Fermat's principle allows one to derive Snell's law of refraction and the law of reflection. Fore more details see here
Provided that the electron & the atomic beams also exhibit refraction,it seems that this is a particle's property.Deflection angle is proportional to particle's mass/size for specific medium.Photon behaves as particle in this effect.Mass is given by de Broglie equation:m=hv/c^2 , v=frequency