<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<div class="moz-cite-prefix">On 8/6/2015 7:40 AM, Cory Quammen
wrote:<br>
</div>
<blockquote
cite="mid:CAB5Fpx7g=JksY4oYX50S8-W2LndGX=KrrHs7xnQ_2uDLW21CsA@mail.gmail.com"
type="cite">
<div dir="ltr">TK,
<div><br>
</div>
<div>You can get the orientation in angle-axis representation
with</div>
<div><br>
</div>
<div>double wxyz[4];</div>
<div>t->GetOrientationWXYZ(wxyz);</div>
<div><br>
</div>
<div>From the docs [1]:</div>
<div><br>
</div>
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">The
angle (w) is in degrees and the axis (xyz) is a unit vector.</span><br>
</div>
<div><br>
</div>
<div>You should be able to apply this rotation to your molecule
model's RotateAboutVector function.</div>
<div><br>
</div>
<br>
</div>
</blockquote>
Thanks for the response. <br>
I modified the boxwidget example in order to test your approach
using a vtk actor, instead of my model, and what I believe I'm
seeing is that the data from getOrientationWXYZ () is from the
'initial' orientation, instead of a progressive transformation. E.g
using the following code in the callback function:<br>
<br>
virtual void Execute(vtkObject *caller, unsigned long, void*)<br>
{<br>
static int callCount = 0;<br>
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();<br>
vtkBoxWidget *widget =
reinterpret_cast<vtkBoxWidget*>(caller);<br>
widget->GetTransform(t);<br>
//widget->GetProp3D()->SetUserTransform(t);<br>
<br>
double* wxyz = t->GetOrientationWXYZ();<br>
if(anActor)<br>
{<br>
cout<<"CallCount: "<<callCount<<"
Angle "<<wxyz[0]<<endl;<br>
anActor->RotateWXYZ(wxyz[0], wxyz[1],
wxyz[2],wxyz[3]);<br>
}<br>
callCount++;<br>
}<br>
<br>
Gives an angle output like this: <br>
CallCount: 0 Angle 0<br>
CallCount: 1 Angle 0.848528<br>
CallCount: 2 Angle 1.69706<br>
CallCount: 3 Angle 2.54558<br>
CallCount: 4 Angle 3.39411<br>
CallCount: 5 Angle 5.9397<br>
CallCount: 6 Angle 6.78823<br>
CallCount: 7 Angle 7.63675<br>
CallCount: 8 Angle 8.48528<br>
CallCount: 9 Angle 8.48528<br>
CallCount: 10 Angle 8.48528<br>
<br>
when moving the widget slightly with the mouse. Each 'callcount'
represent a movement using the mouse.<br>
<br>
Question is, how would one go about getting the 'latest'
transformation, instead of the 'accumulated' one from the box
widgets GetTransform()? <br>
<br>
I guess I could save the transformation each time and do a 'back
transformation' before applying the new transformation. But that
would be more work (I assume), than applying an incremental
rotation. <br>
-tk<br>
<br>
<br>
<br>
<br>
<blockquote
cite="mid:CAB5Fpx7g=JksY4oYX50S8-W2LndGX=KrrHs7xnQ_2uDLW21CsA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px"><br>
</span></div>
<div><span
style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">[1] </span><font
color="#000000" face="Roboto, sans-serif"><span
style="font-size:14px;line-height:22px"><a
moz-do-not-send="true"
href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f"><a class="moz-txt-link-freetext" href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f">http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f</a></a></span></font></div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Aug 5, 2015 at 8:54 PM, Totte
Karlsson <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
I'm using vtk to visualize 3D models of molecules.<br>
The actual molecular model is decoupled from vtk code, and
visualization is implemented using a model-view kind of
design.<br>
<br>
Currently I have the following challenge. If a user wants to
manipulate the absolute orientation of the molecule, it is
done by manipulating the underlying model using rotation
functions, like RotateX, RotateY, RotateAboutVector, and
translation functions TranslateX, Y etc.<br>
<br>
For now 3D rotations are simply done using two scrollbars,
one horizontal and one vertical, causing the underlying
model being rotated about the vtk viewUP vector and the vtk
cameraPlane normal respectively. This works fine, but is
not so intuitive for the user.<br>
<br>
Instead I believe allowing interaction with something like a
box widget that encapsulates the molecule view, (with
disabled handles), would be better.<br>
<br>
The challenge is how to figure out how to capture the
boxwidgets orientation in a callback, and using this
information in order to manipulate the underlying molecular
model.<br>
<br>
For example, a boxwidget callback (from boxwidget example at
<a moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget"
rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget</a>):<br>
<br>
class vtkMyCallback : public vtkCommand<br>
{<br>
public:<br>
static vtkMyCallback *New() {
return new vtkMyCallback; }<br>
<br>
virtual void Execute(vtkObject *caller, unsigned long,
void*)<br>
{<br>
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();<br>
vtkBoxWidget *widget =
reinterpret_cast<vtkBoxWidget*>(caller);<br>
widget->GetTransform(t);<br>
<br>
double* angles?? = t->GetOrientation();<br>
if(aMoleculeModel)<br>
{<br>
//Use some secret(!) code to manipulate
orientation of a molecule to 'rotate' it together with the
boxWidget<br>
aMoleculeModel->RotateZ(??);<br>
aMoleculeModel->RotateY(??);<br>
aMoleculeModel->RotateZ(??);<br>
}<br>
}<br>
Molecule* aMoleculeModel;<br>
<br>
Anyone seeing how to do this or have some pointers?<br>
<br>
Cheers,<br>
tk<br>
<br>
_______________________________________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com" rel="noreferrer"
target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a
moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
rel="noreferrer" target="_blank"><a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a
moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer"
target="_blank"><a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a></a><br>
<br>
Search the list archives at: <a moz-do-not-send="true"
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 moz-do-not-send="true"
href="http://public.kitware.com/mailman/listinfo/vtkusers"
rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">Cory Quammen<br>
R&D Engineer<br>
Kitware, Inc.</div>
</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<hr size="1">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><a moz-do-not-send="true"
href="http://www.dunescientific.com/" target="_blank"><img
moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/ds_logo_233x60.png"
alt="" border="0" height="40"></a></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="15"></td>
<td bgcolor="#cccccc"><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="1"></td>
<td><img moz-do-not-send="true"
src="http://www.dunescientific.com/images/email/spacer.gif"
alt="" border="0" height="1" width="10"></td>
<td>
<div style="font-size:10px;color:#666666"> Totte Karlsson:
<a moz-do-not-send="true"
href="mailto:totte@dunescientific.com" target="_blank">totte@dunescientific.com</a>
or <a moz-do-not-send="true"
href="tel:%20425%20%20780-9648" value="+14257809648"
target="_blank">(425) 780-9648</a><br>
<a moz-do-not-send="true"
href="http://www.dunescientific.com/" target="_blank">http://www.dunescientific.com/</a>
<br>
© 2015 Dune Scientific, LLC. All rights reserved. </div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</body>
</html>