function [intersectionPoint,vectorMedium2] = refraction(position,vectorMedium1,n1,n2,positionMedium,normalMedium)

%% Sardemann, IPF, TU Dresden, 2022

% intersection point with interface:
[intersectionPoint,~] = line_plane_intersection(vectorMedium1, position, normalMedium, positionMedium);

% orientation of vector in medium 2 interface (Snells law):
vectorMedium2 = n1/n2 * (cross(normalMedium,cross(-normalMedium,vectorMedium1)))-...
    normalMedium*sqrt(1-(n1/n2)^2*...
    dot(cross(normalMedium,vectorMedium1),cross(normalMedium,vectorMedium1)));


end

