-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestcomputeBasisFromAxis.m
33 lines (29 loc) · 1.29 KB
/
TestcomputeBasisFromAxis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
classdef TestcomputeBasisFromAxis < matlab.unittest.TestCase
% TestcomputeBasisFromAxis performs unit testing for computeBasisFromAxis.
% testComputation tests the computation against a known solution.
% testOrthogonal tests if the 3 vectors form an orthogonal triad.
% testZerosInput tests if the error is thrown for a no axis vector (zeros(3,1))
properties
end
methods (Test)
function testComputation(testCase)
% testComputation tests against a known solution.
vi = [1 0 -3]';
[vi1, vi2] = computeBasisFromAxis(vi);
actSol = [vi1, vi2];
expSol = [[3 -3 1]', [-9 -10 -3]'];
testCase.verifyEqual(actSol, expSol, 'AbsTol', sqrt(eps));
end
function testOrthogonal(testCase)
% testOrthogonal tests to see if the 3 vectors are perpendicular.
vi = [1 0 -3]';
[vi1, vi2] = computeBasisFromAxis(vi);
actSol = [vi1' * vi, vi2' * vi, vi1' * vi2];
expSol = [0 0 0];
testCase.verifyEqual(actSol, expSol, 'AbsTol', sqrt(eps));
end
function testZerosInput(testCase)
testCase.verifyError(@()computeBasisFromAxis(zeros(3,1)),'computeBasisFromAxis:InputIsZeros');
end
end
end