openvr icon indicating copy to clipboard operation
openvr copied to clipboard

How to get translation, rotation, reflection, scaling and shearing through Affine transformation.

Open qywako opened this issue 9 years ago • 5 comments

vr::VRCompositor()->WaitGetPoses(m_rTrackedDevicePose, vr::k_unMaxTrackedDeviceCount, NULL, 0 ); m_rmat4DevicePose[nDevice] = ConvertSteamVRMatrixToMatrix4( m_rTrackedDevicePose[nDevice].mDeviceToAbsoluteTracking );

through this method i can get a matrix includes translation, rotation, reflection and so on,but how can i get rotation?

qywako avatar Apr 18 '17 09:04 qywako

This matrix only contains translation and rotation. No shearing or scaling will be present. This is the location of a physical rigid body in space, so those kinds of transforms don't make sense in this context.

JoeLudwig avatar Apr 18 '17 16:04 JoeLudwig

See the remark of the method Matrix4& Matrix4::invertAffine() in Matrices.cpp. if so,i neet to get the rotation (Vector4) to set my model in my own engine that not open sourse,how can i get it. i don't need shearing or scaling.

qywako avatar Apr 19 '17 00:04 qywako

like this, /////////////////////////////////////////////////////////////////////////////// // compute the inverse of a 4x4 affine transformation matrix // // Affine transformations are generalizations of Euclidean transformations. // Affine transformation includes translation, rotation, reflection, scaling, // and shearing. Length and angle are NOT preserved. // M = [ R | T ] // [ --+-- ] (R denotes 3x3 rotation/scale/shear matrix) // [ 0 | 1 ] (T denotes 1x3 translation matrix) // // y = Mx -> y = Rx + T -> x = R^-1*(y - T) -> x = R^-1y - R^-1T // // [ R | T ]-1 [ R^-1 | -R^-1 * T ] // [ --+-- ] = [ -----+---------- ] // [ 0 | 1 ] [ 0 + 1 ] /////////////////////////////////////////////////////////////////////////////// Matrix4& Matrix4::invertAffine()

qywako avatar Apr 19 '17 00:04 qywako

yaw pitch roll from rotation matrix

http://planning.cs.uiuc.edu/node103.html

On 19 April 2017 at 01:58, qywako [email protected] wrote:

like this, //////////////////////////////////////////////////////////// /////////////////// // compute the inverse of a 4x4 affine transformation matrix // // Affine transformations are generalizations of Euclidean transformations. // Affine transformation includes translation, rotation, reflection, scaling, // and shearing. Length and angle are NOT preserved. // M = [ R | T ] // [ --+-- ] (R denotes 3x3 rotation/scale/shear matrix) // [ 0 | 1 ] (T denotes 1x3 translation matrix) // // y = Mx -> y = Rx + T -> x = R^-1*(y - T) -> x = R^-1y - R^-1T // // [ R | T ]-1 [ R^-1 | -R^-1 * T ] // [ --+-- ] = [ -----+---------- ] // [ 0 | 1 ] [ 0 + 1 ] //////////////////////////////////////////////////////////// /////////////////// Matrix4& Matrix4::invertAffine()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ValveSoftware/openvr/issues/477#issuecomment-295030351, or mute the thread https://github.com/notifications/unsubscribe-auth/ACrxdi44J3kE8naiAy967eBIwxSaPZP6ks5rxVwmgaJpZM4NAHg7 .

ruiying avatar Apr 19 '17 11:04 ruiying

It's helpful. But the order of rotation matrix OpenVR used is x,y,z or z,y,x or else?

LouHan-0325 avatar Sep 18 '20 08:09 LouHan-0325