<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 16, 2016 at 5:29 PM, Lonni Besançon <span dir="ltr"><<a href="mailto:lonni.besancon@gmail.com" target="_blank">lonni.besancon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">David,<br>
<br>
I decided to get back to a basic version of the code to make sure that I did<br>
not do anything wrong.<br>
<br>
/void method(double* rotation, double* translation){<br>
//rotation is in the form of a quaternion with angle in radians<br></blockquote><div><br></div><div>The above comment confuses me. None of the elements of a quaternion are angles, so why say "in radians"?</div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class="">vtkSmartPointer<vtkTransform>t = vtkTransform::New();<br></span></blockquote><div><br></div><div>This is a minor point, but using a VTK smart pointer like the above creates a memory leak. Proper use of vtkSmartPointer is this:</div><div><br></div><div>vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();<br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
</span>double axis[3] ;<br>
t->SetMatrix(actor->GetMatrix());<br>
vtkQuaternion<double> q =<br>
vtkQuaternion<double>(rotation[3],rotation[0],rotation[2],rotation[1]);<br>
</blockquote><div><br></div><div>This line of code also confuses me. What are the elements of "rotation"? Why is this strange ordering used?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">q.Normalize();<br>
angle = q.GetRotationAngleAndAxis(axis);<br>
t->PreMultiply();<br>
t->RotateWXYZ(angle*180.0/3.14,axis[0],axis[1],axis[2]);<br></blockquote><div><br></div><div>Using "3.14" for pi is not very precise.</div><div><br></div><div><br></div><div>Please fix my confusion regarding the elements of "rotation" before I go any further with this...</div><div><br></div><div> - David</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
actor->SetUserMatrix(t->GetMatrix());<br>
<br>
}/<br>
<br>
So this is a basic version that does not work.<br>
<br>
Yet I thought this was only linked to the Pre or Post Multiply setup, so I<br>
tried changing it and it did not actually change anything.<br>
<br>
So then I thought that what I was missing was to take into account the<br>
current orientation of my actor and so I did:<br>
<br>
/void method(double* rotation, double* translation){<br>
double quatActor[4] ;<br>
double axis[3] ;<br>
//rotation is in the form of a quaternion with angle in radians<br>
<span class="">vtkSmartPointer<vtkTransform>t = vtkTransform::New();<br>
</span>t->SetMatrix(actor->GetMatrix());<br>
vtkQuaternion<double> q =<br>
vtkQuaternion<double>(rotation[3],rotation[0],rotation[2],rotation[1]);<br>
t->GetOrientationWXYZ (quatActor) ;<br>
vtkQuaternion<double> qA =<br>
vtkQuaternion<double>(quatActor[3],quatActor[0],quatActor[1],quatActor[2]);<br>
q = qA.Inverse() * q ;<br>
q.Normalize();<br>
angle = qA.GetRotationAngleAndAxis(axis);<br>
t->RotateWXYZ(angle*180.0/3.14,axis[0],axis[1],axis[2]);<br>
}/<br>
<br>
But I don't get a better result.<br>
Is there a crucial point that I'm missing here? Or maybe I misunderstood how<br>
the Transform works. In any case, I have a feeling there is something<br>
obvious that I don't get right with vtkTransforms right now.<br>
<br>
My aim is to mimic what you would get with a mouse or a touch input. Imagine<br>
we use the bunny.vtp dataset, tilting the tablet along the x axis causes the<br>
bunny to show its feet. If we rotate with 90 degrees, its ears are not shown<br>
and we only see the paws.<br>
Then if the rotation was along the y axis, say 90 degrees, we would get to<br>
see its tail in front of us. If we were then to perform a rotation along the<br>
x-axis, we should see as a result the tail going up. However, in my case,<br>
what I see is the bunny rotating as if it was still in its original position<br>
( the paws are going up, and not the tail ).<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-tp5736566p5736602.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/Relative-Rotation-with-VTK-Transform-tp5736566p5736602.html</a><br>
<div class=""><div class="h5">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></div></blockquote></div><br></div></div>