[37] | 1 | % Test code for the fundamental quaternion functions. |
---|
| 2 | |
---|
| 3 | % Copyright © 2005, 2006 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 4 | % See the file : Copyright.m for further details. |
---|
| 5 | |
---|
| 6 | check(qi == q1, 'qi and q1 are not equal.'); |
---|
| 7 | check(qj == q2, 'qj and q2 are not equal.'); |
---|
| 8 | check(qk == q3, 'qk and q3 are not equal.'); |
---|
| 9 | |
---|
| 10 | check(qi .* qj .* qk == -1, 'ijk is not -1.'); |
---|
| 11 | |
---|
| 12 | check(abs(qi) == 1, 'abs(qi) is not 1'); |
---|
| 13 | check(abs(qj) == 1, 'abs(qj) is not 1'); |
---|
| 14 | check(abs(qk) == 1, 'abs(qk) is not 1'); |
---|
| 15 | |
---|
| 16 | check(quaternion(1,1,1,1) == 1 + qi + qj + qk, 'Constructor error.'); |
---|
| 17 | check(abs(quaternion(1,1,1,1)) == 2, 'abs(1,1,1,1) is not 2.'); |
---|
| 18 | check(abs(quaternion(1,1,1,1)+quaternion(1,1,1,1).*i) == 2 + 2.*i,... |
---|
| 19 | 'abs error on complex value.'); |
---|
| 20 | |
---|
| 21 | check(quaternion(5, 6, 7, 8) .* (1 + 2 .* qi + 3 .* qj + 4 .* qk) ... |
---|
| 22 | - quaternion(-60,20,14,32) == 0, 'Error in simple multiplication.'); |
---|
| 23 | |
---|
| 24 | compare(axis(quaternion(42,1,1,1)), axis(quaternion(3,3,3)), 1e-14,... |
---|
| 25 | 'Error in axis comparison.'); |
---|
| 26 | |
---|
| 27 | % To be continued.... |
---|