Cody

# Problem 42755. Angle bisectors

Solution 838569

Submitted on 26 Feb 2016 by Jan Orwat
• Size: 36
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
v1 = [1 0]; v2 = [0 1]; [b1,b2] = bisectors(v1,v2); b1ok = [1 1]/sqrt(2); b2ok = [-1 1]/sqrt(2); % Tests performed t1 = (abs(norm(b1)-1)<1e-6); % Unit b1 t2 = (abs(norm(b2)-1)<1e-6); % Unit b2 t3 = (abs(b1*b2') < 1e-12); % b1 and b2 are perpendicular t4 = (abs(sum((b1-b1ok)))<1e-12); % b1 is equal to [1/sqrt(2) 1/sqrt(2)] t5 = (abs(sum((b1+b1ok)))<1e-12); % or its opposite t6 = (abs(sum((b2-b2ok)))<1e-12); % b2 is equal to [1/sqrt(2) -1/sqrt(2)] t7 = (abs(sum((b2+b2ok)))<1e-12); % or its opposite test = (t1 && t2 && t3 && xor(t4,t5) && xor(t6,t7));

2   Pass
v1 = [4 0 3]; v2 = [-2 2 1]; [b1,b2] = bisectors(v1,v2); b1ok=[0.2 1 1.4]/sqrt(3); b2ok=[2.2 -1 0.4]/sqrt(6); % Tests performed t1 = (abs(norm(b1)-1)<1e-6); % Unit b1 t2 = (abs(norm(b2)-1)<1e-6); % Unit b2 t3 = (abs(b1*b2') < 1e-12); % b1 and b2 are perpendicular t4 = (abs(sum((b1-b1ok)))<1e-12); % b1 is equal to [1/sqrt(2) 1/sqrt(2)] t5 = (abs(sum((b1+b1ok)))<1e-12); % or its opposite t6 = (abs(sum((b2-b2ok)))<1e-12); % b2 is equal to [1/sqrt(2) -1/sqrt(2)] t7 = (abs(sum((b2+b2ok)))<1e-12); % or its opposite test = (t1 && t2 && t3 && xor(t4,t5) && xor(t6,t7));