- edited description
Vector subtraction in function 'rod::point_lies_on_rod_line_element()' gives inconsistent results
The vector subtraction:
vec3d(n){vec3d(n){r1_c[n] = c[n] - r1[n];}
will inconsistently give strange results, such as [1,0,0]-[0,0,0] = [1.07,0,0], usually appearing to add something on when attempting to subtract.
This only seems to happen when the function is called from a larger function, rod::get_point_on_connecting_line(), during the test ffea_test::line_connecting_rod_elements(). Are the arguments being passed in wrong?
The independent unit test of rod::point_lies_on_rod_line_element() does not show such behaviour.
This bug could interfere with assigning point of connection during rod collision.
The attached output shows an example (line 47). There is an error of -0.0669873 in x, and -0.25 in z.
Comments (7)
-
reporter -
reporter - edited description
- attached subtract_error_test_output.txt
-
reporter Printing c - r1 per-element seems to solve this problem. See second attached text file.
-
reporter - attached individual_print_output.txt
-
reporter However, replacing the vec3d statement with individual subtractions replicates the error!!
-
reporter Turns out, doing the vector subtraction before vs. after the if-statements that assign c to a rod node or not, gives different outcomes! (subtracting before gives the buggy behaviour)
-
reporter - changed status to resolved
Did some fiddling around and it seems to have solved itself. I have a strong suspicion that I was using the wrong values of r1 and c to check if the answer to the function was correct. No apparent 'error' in the calculation now occurs! Hooray for silly mistakes!!
- Log in to comment