[vtkusers] Relative Rotation with VTK Transform

Lonni Besançon lonni.besancon at gmail.com
Sun Feb 14 14:22:34 EST 2016


Hello,

I'm experimenting a little with the gyroscope of my android tablet to rotate
vtk datasets.

For the sake of simplicity let's imagine that both the tablet and the the
vtk coordinate systems are the same.
So when I tilt my tablet, rotating around the x axis, my dataset rotates
around the x axis as well.
However, if I rotate first say 90 degrees around the y axis and then rotate
again around the x axis, the dataset doesn't rotate around the x axis
anymore but rather around the z axis.
Therefore, what I get does not make sense anymore. However I thought that
what I did was supposed to give me relative transformation.

My algorithm is basically this (I simplify the code as I think the logic
matters and the code really doesn't here).

///Retrieve the current matrix of the dataset and set a transform with this
matrix
vtkSmartPointer<vtkTransform> t = vtkTransform::New();
t->SetUserMatrix(actor->GetMatrix());

//I get the quaternion corresponding to the current rotation of the dataset,
let's call it qD.

//I get from a function call the current rotation performed relatively to
the previous one with the gyroscope, let's call it rotation and assume it's
in the right format directly (WXYZ) of a quaternion qR 

//I perform
qf = qD.inverse() * qR 

//I rotate the user matrix
t->RotateXYZ(qf[0], ...)
/
But this does not work at all and I get the result previously described.

I even tried directly using the RotateWXYZ with both rotations in different
orders and with either Post or Pre multiply but it doesn't seem to change a
thing to set Post or Pre multiply and no matter what order of rotations I
use, I don't get an interesting result.

Would anyone know what's wrong with my thinking here?

Thanks in advance.





--
View this message in context: http://vtk.1045678.n5.nabble.com/Relative-Rotation-with-VTK-Transform-tp5736566.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list