angstn =mod(atan2(norm(det([P2-P0;P1-P0])),dot(P2-P0,P1-P0)),2*pi);
norm() is always non-negative, so you are taking atan2() in the case where y is positive and x is potentially either positive or negative. That is always going to give you a result between 0 and pi, so the mod() against 2*pi is always going to just return the same value.