|
|
Question : Snell's Law
|
|
I apologize upfront as this is probably not the most appropriate question but I want to give it a shot. I'm developing a graphics portion of my code. Here is what I need. I have a vector of a light ray hitting a surface in 3D. I have the normal vector. I want the refracted light vector. I, of course, have the indices of refration. Using Snell's law I see a complicated way (several rotations) to do it but I'm thinking there is a simple mathematical way to calculate the refracted vector but I'm missing it. Does anybody have a piece of code or code snipet to get the refracted vector of the light ray given the incoming vector, normal vector (both 3D vectors) and the indices?
Thanks!
|
Answer : Snell's Law
|
|
given normal unit vector v, incident vector i, indices of refraction n1/n2, take v×i×v*n1/n2 + v·i·v
|
|
|
|
|