<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><div>HTH,</div><div>Cory</div><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 href="http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f">http://www.vtk.org/doc/nightly/html/classvtkTransform.html#aa8244cbab95a2dbb20e94af6e7f16b7f</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 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 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 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>
</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>