Testing
- The testing is based on the current code.
- The output is recorded in the table below.
V1 | V2 | V3 | O | D | Exception | intersect? | intersection point | expected output |
---|---|---|---|---|---|---|---|---|
(1,0,0) | (0,1,0) | (0,0,1) | (0,0,0) | (1,1,1) | Yes | (0.333,0.333,0.333) | (0.333,0.333,0.333) | |
(1,0,0) | (0,1,0) | (0,0,1) | (0,0,0) | (1,0,0) | No | (1,0,0) | (0,0,0) | |
(1,0,0) | (0,1,0) | (0,0,1) | (0,0,0) | (-1,-1,-1) | Yes | (-0.333,0.333,0.333) | (0,0,0) | |
(1,0,0) | (0,1,0) | (0,0,1) | (0,0,0) | (1.32,0.53,4.23) | Yes | (0.164,0.087,0.696) | (0.164,0.087,0.696) | |
(1,0,0) | (0,1,0) | (0,0,1) | (0,0,0) | (1,0,-1) | No | (0,0,0) | (0,0,0) | |
(100,0,0) | (0,100,0) | (0,0,100) | (0,0,0) | (1,1,1) | yes | (33.333,0.33,0.33) | (33.333,33.333,33.333) | |
(100,0,0) | (0,100,0) | (0,0,100) | (0,0,0) | (100,100,100) | yes | (0.33,0.33,0.33) | (33.333,33.333,33.333) |
- The same errors occur in the original code. A deeper look of the algorithm is planned..
- The correct answers is calculated on paper, and the expected output is listed.
Debugging
- Changed the clock cycle period from 10 ns to 100 ns. The output is still wrong.
- A simulator written in C is planned for verification.
- Simulators written in both C and Matlab are used for testing. The results are the same.
- The algorithm shows that the t, u and v values are NOT the real intersection point. Instead, a 2D point (u,v) is the barycentric coodinates on the triangle and t is the distance from origin to the plane that contains the triangle. A detailed explaination is attached here
- As a result, in order to calculate the distance from the ray to the triangle, a vector muliplication, an addtion, and a dot product operations are required.
More Test Cases
- More test cases are created for further verification
Testset 2
V1 |
V2 |
V3 |
O |
D |
Exception |
intersect? |
t,u and v values |
Intersection point |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(1,0,0) |
(-0.1,0,1) |
No |
Yes |
(10,0.16,0.16) |
(0,0,10) |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(-5,-2,-10) |
(1,1,1) |
No |
Yes |
(5,0.19,0.15) |
(0,3,-5) |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(1,1,1) |
(0,0,-1) |
No |
No |
(0,0,0) |
(0,0,0) |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(10,3.1,-100) |
(-1,0,20) |
No |
Yes |
(10,0.08,0.03) |
(0,3.1,100) |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(0,0,0) |
(0,0,-1) |
No |
No |
(0,0,0) |
(0,0,0) |
(0,0,150) |
(0,70,-300) |
(0,-70,-300) |
(100,2,18) |
(-20,-0.01,2) |
No |
yes |
(5,0.15,0.12) |
(0,1.95,28) |
Test Set 3
V1 |
V2 |
V3 |
O |
D |
Exception |
intersect? |
t,u and v values |
Intersection point |
(1,0,0) |
(0,1,0) |
(0,0,1) |
(6,5,4) |
(-1,-0.6,-2) |
No |
No |
(0,0,0) |
(0,0,0) |
(2,0,1) |
(0,0,1) |
(0,2,1) |
(6,5,4) |
(-1,-0.6,-2) |
No |
No |
(0,0,0) |
(0,0,0) |
(16,3,5) |
(0,20,3) |
(3,6,10) |
(6,5,4) |
(-1,-0.6,-2) |
No |
Yes |
(-1.74,0.09,0.53) |
(7.74,6.04,7.47) |
(6,5,4) |
(5,5,4) |
(0,0,0) |
(6,5,4) |
(-1,-0.6,-2) |
No |
Yes |
(0,0,0) |
(6,5,4) |
(1,0,0) |
(0,1,0) |
(0,0,1) |
(6,5,4) |
(-1,-0.6,-2) |
No |
Yes |
(0,0,0) |
(0,0,0) |
(8,5,4) |
(6,7,4) |
(6,5,6) |
(6,5,4) |
(-1,-0.6,-2) |
No |
yes |
(-0.56,0.17,0.56) |
(6.56,5.33,5.11) |
- The outputs are correct for all the test cases we created