%%%%%%%%%%%%%%%%%%%%%%%%%%%% Same Side %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % SAMESIDE % Usage: SAMESIDE(tri,X) % % Inputs: tri - a triangle [P Q R] % X - a point % % Output: returns 1 if R and X are on the same side of the segment [P Q] % returns 0 otherwise function w = sameside(tri,X) %flops(0); f= []; t0 =clock; et =[]; I = sqrt(-1); x = tri(1); y = tri(2); z = tri(3); m = (x+y)/2; % midpoint of Euclidean segment d = I*(x-y)/2; % vector orthogonal to vector to segment u = abs(m); % calculate some scalars v = abs(d); rt = 2*real(m*conj(d))/(u^2-v^2-1); s = rt/(1+sqrt(1+rt^2)); mc = m+s*d; % (euclidean) midpoint of H-segment L = lft([x mc y], [-1 0 1]); % LFT mapping H-segment to interval [-1 1] w = imag(lftact(L,z)); if (w < 0) L = [I 0; 0 -I]*L; end; w = imag(lftact(L,X));