Closed ekuusi closed 7 years ago
Ok so the issue is that 1+pose_mat[0][0]+pose_mat[1][1]+pose_mat[2][2] can return values less than 0. Just add abs to the calculation should fix this, not sure if it messes up quaternion calculation somehow though:
r_w = math.sqrt(abs(1+pose_mat[0][0]+pose_mat[1][1]+pose_mat[2][2]))/2
works
Good catch and thank you for suggesting a fix! I committed the change!
If 1+pose_mat[0][0]+pose_mat[1][1]+pose_mat[2][2] produces a value close enough to 0, for example as in my last test run 5.699694156646729e-07, the line
r_w = math.sqrt(1+pose_mat[0][0]+pose_mat[1][1]+pose_mat[2][2])/2
Returns a math error. Not completely sure why as math.sqrt(0) should work fine