%test pass3()

global_defs;


example = 1;
switch example
	case (1)
		perp = [1;0;0];
		a0= get_unit_vec(randn(3,1));
		b0= get_unit_vec(randn(3,1));
		c0= get_unit_vec(randn()*a0 +randn()*b0);
		e0= get_unit_vec(randn(3,1));

		a1= get_unit_vec(randn(3,1));
		b1= get_unit_vec(cross(a1,randn(3,1)));
		c1= get_unit_vec(cross(b1,randn(3,1)));
		e2= get_unit_vec(randn(3,1));
		
		if(-(cross(a0,b0)'*cross(b0,c0))*(b0'*c0)<0)
				a0=-a0;
		endif
	otherwise
		error("example number is out of range");
end
vecs_in=[e0,c0,b0,a0;e2,c1,b1,a1];
[vecs_out, U1, U0] = pass3(vecs_in, perp);
c0f=vecs_out(1:3,1); e0f=vecs_out(1:3,2); b0f=vecs_out(1:3,3); a0f=vecs_out(1:3,4);
c1f=vecs_out(4:6,1); e2f=vecs_out(4:6,2); b1f=vecs_out(4:6,3); a1f=vecs_out(4:6,4);

% e0  c0  b0  a0       c0f  e0f  b0f   a0f    [U0]
% |   |   |   |   -->  |    |    |     |
% |   c1  b1  a1       c1f  |    b1f   a1f    [U1]
% |                         |
% e2                        e2f               [1]

error_pass3 = norm(dr101(e2,e0)*dr011(c1,c0)*dr011(b1,b0)*dr011(a1,a0) -dr011(c1f,c0f)*dr101(e2f,e0f)*dr011(b1f,b0f)*dr011(a1f,a0f)*kron(kron(eye(2),U1),U0) )
