-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Another) Math error in convert_to_quaternion #3
Comments
My earlier implementation for the quaternion calculations were picked from Steam discussions (can't find the link), they went like this (in javascript): w: Math.sqrt(Math.max(0, 1 + pose[0][0] + pose[1][1] + pose[2][2] )) / 2, As I don't really know what the correct formulas are to form the quaternion, I can't say if the above is a better or even a correct way of doing the calculations. The approach seems to differ a bit from how your quaternion is calculated. It does have a similar fix for negative numbers in calculating w though. |
So the values you get in this aren't quite the same as with your formula (I guess the axes are different?), but here's that javascript calculation implemented in python, and seems to work ok in three.js:
|
I also looked into a different reference from Unity, it looks similar to the code that you have pasted above. Peeling back the SteamVR C# code in the Unity plugin, they use the following built in function:
|
Hi Luke, thanks a lot for your wrapper! I changed the matrix to quaternion conversion to
(http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/) And in Unity I did this mess
to have meaningful direction of movement and rotation relative to the lighthouse position. I still need to check it carefully as it might be redundant somewhere with all those modifications to the rotation quaternion .... Hope this can be useful. By the way, could you set a license to this repository? Thanks! |
Not sure if this is somehow related to the proposed fix to having abs() inside math.sqrt(), but r_w just got a value of 0 for me which caused a divide by zero error in
r_x = (pose_mat[2][1]-pose_mat[1][2])/(4*r_w)
Are the calculation formulas correct if there can be a case where you get a divide by zero error?
The text was updated successfully, but these errors were encountered: