<p dir="ltr">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 your camera.</p>
<p dir="ltr">Felipe</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I'm experimenting a little with the gyroscope of my android tablet to rotate<br>
vtk datasets.<br>
<br>
For the sake of simplicity let's imagine that both the tablet and the the<br>
vtk coordinate systems are the same.<br>
So when I tilt my tablet, rotating around the x axis, my dataset rotates<br>
around the x axis as well.<br>
However, if I rotate first say 90 degrees around the y axis and then rotate<br>
again around the x axis, the dataset doesn't rotate around the x axis<br>
anymore but rather around the z axis.<br>
Therefore, what I get does not make sense anymore. However I thought that<br>
what I did was supposed to give me relative transformation.<br>
<br>
My algorithm is basically this (I simplify the code as I think the logic<br>
matters and the code really doesn't here).<br>
<br>
///Retrieve the current matrix of the dataset and set a transform with this<br>
matrix<br>
vtkSmartPointer<vtkTransform> t = vtkTransform::New();<br>
t->SetUserMatrix(actor->GetMatrix());<br>
<br>
//I get the quaternion corresponding to the current rotation of the dataset,<br>
let's call it qD.<br>
<br>
//I get from a function call the current rotation performed relatively to<br>
the previous one with the gyroscope, let's call it rotation and assume it's<br>
in the right format directly (WXYZ) of a quaternion qR<br>
<br>
//I perform<br>
qf = qD.inverse() * qR<br>
<br>
//I rotate the user matrix<br>
t->RotateXYZ(qf[0], ...)<br>
/<br>
But this does not work at all and I get the result previously described.<br>
<br>
I even tried directly using the RotateWXYZ with both rotations in different<br>
orders and with either Post or Pre multiply but it doesn't seem to change a<br>
thing to set Post or Pre multiply and no matter what order of rotations I<br>
use, I don't get an interesting result.<br>
<br>
Would anyone know what's wrong with my thinking here?<br>
<br>
Thanks in advance.<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Relative-Rotation-with-VTK-Transform-tp5736566.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/Relative-Rotation-with-VTK-Transform-tp5736566.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</div>