Solution to Problem 1-12

Matlab input

% Solution of Problem 1-12 using Matlab
N = [3 4 8];
d = -15;
n = 1;
p = [ 0.2 0.3 -1.04];
k = [ 0.1 0 0.9];
disp('Intersect plane')
q = -(dot(p,N)+d)/dot(N,k)
p1 = p + q*k
% Normalize to unit vectors
k = k / norm(k);
N = N / norm(N);
disp('Refract ray')
Gi = n*dot(k,N)
Ii = acos(abs(Gi)/n)*180/pi
nr = 1.517;
Gr = sqrt(Gi^2 + nr^2 - n^2)
if Gi < 0.0
   Gr = -Gr;
end
% refracted ray
kr = (n*k+(Gr-Gi)*N)/nr

Matlab output

>> prob1_12
Intersect plane

q =

    2.8693


p1 =

    0.4869    0.3000    1.5424

Refract ray

Gi =

    0.8779


Ii =

   28.6065


Gr =

    1.4395


kr =

    0.1905    0.1569    0.9691


Maintained by John Loomis, last updated 10 Sept, 1997