Coding a ray tracing
Example intersection ray-sphere Analytic solution showing the math
Vector calculation - (20a) formula is plus because of the direction of the normal, however, the program consider the value of "i - cos(theta)n" as sign for the direction of the normal is passed by the method calling the refract function. - (20b) Appy Pitagoras and use "n" as the direction of the vector. Ray tracer refraction with medium