[vtkusers] Relative Rotation with VTK Transform
felipebordeu at gmail.com
Tue Feb 16 11:55:23 EST 2016
I did the same thing ones on an app (not a vtk app). You have to control
the orientation using absolute values. You must set the camera position
using the information from your phone(not the camera rotation). You will
not be able to keep the orientations in sync using incremental rotations.
Instead you know the orientation of your phone and you know where to put
I'm experimenting a little with the gyroscope of my android tablet to rotate
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
vtkSmartPointer<vtkTransform> t = vtkTransform::New();
//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
qf = qD.inverse() * qR
//I rotate the user matrix
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:
Sent from the VTK - Users mailing list archive at Nabble.com.
Powered by www.kitware.com
Visit other Kitware open-source projects at
Please keep messages on-topic and check the VTK FAQ at:
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers