Question: procedure to generate a line and angle

Can alone explain to me what is happening in this procedure? I know it is it is to generate a line p and an angle theta but don't understand what line and angle or how it does it.

> PolFm := proc(A,B)
 local n, mds, p, theta;
 n := [ A[2]-B[2], B[1]-A[1] ];   # Normal to the line
 if evalf((A[1]+B[1])*n[1] + (A[2]+B[2])*n[2]) < 0 then # makes sure we have the "right" normal
    n := - n
 end if;
 mds := sqrt( n[1]^2 + n[2]^2 );
 n := [(1/mds)*n[1],(1/mds)*n[2]];
 theta := argument(n[1]+I*n[2]);
 p := A[1]*n[1]+A[2]*n[2];
 return p, theta
end proc:

 

Please Wait...