openvr icon indicating copy to clipboard operation
openvr copied to clipboard

The order of rotation matrix OpenVR used is x,y,z or z,y,x or else?

Open LouHan-0325 opened this issue 6 years ago • 4 comments

I want to calculate the Euler angle from the rotation matrix. So the order of rotation is important. Is it roll first, then the pitch, and finally the yaw or else? Thanks for your any help.

LouHan-0325 avatar Sep 21 '20 09:09 LouHan-0325

last time i checked x is the horizontal axis(left/right) so it will be your pitch, then y is the vertical axis(up/down) so it will be your yaw and z is the forward facing axis(front/back) so it will be your roll

BUT

DO. NOT. USE. EULER. ANGLES.

they suffers from gimbal lock which makes it unusable for VR

aviation industry uses bc they don't need the full range for orientation in 3D

so for VR either stay with the matrix OR use a quaternion, quaternions are WAY more stable and unlike matrices easier to understand just by looking at them(im kinda lying here so read up on quaternions)

okawo80085 avatar Sep 27 '20 12:09 okawo80085

That depends on what you want. Euler angles are not uniquely defined. Your application defines the Euler angles that it wants, and you can then calculate them from the quaternions / rotation matrices that you get from OpenVR. Depending on how you define your operations, OpenVR's rotation matrices may be the transposed of what you expect (this depends on whether you are used to applying rotation matrices to column or row vectors), but besides that there is no ambiguity in the rotation matrices.

Just to be very clear, and because I think what you wrote implies a bit of confusion: rotation matrices and Euler angles are different, separate and independent concepts. A rotation matrix is independent of whatever Euler angle convention you chose.

TobiSchluter avatar Oct 12 '20 07:10 TobiSchluter

There is no rotating order in a matrix rotation. Its all in one, just like a quaternion. You may have rotation order in your euler angles, but that is up to you and your euler angle definition.

TheWhiteAmbit avatar Mar 06 '21 12:03 TheWhiteAmbit

As folks have suggested, you're better off with quaternions than Euler angles. But in any case, this is entirely up to you. The API only needs the matrix at the end, so you can convert it into whatever other formats you like inside your own application.

JoeLudwig avatar Mar 06 '21 17:03 JoeLudwig