<div dir="ltr">The scale should be:<div><br></div><div> transform->Scale(length, 1.0, 1.0);<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 13, 2016 at 10:48 AM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The arrow source is originally aligned with the x-axis, The cylinder source is aligned with the y-axis. Also the cylinder origin is different. Replace the transform with<div><br></div><div><div> vtkSmartPointer<vtkTransform> transform =</div><div> vtkSmartPointer<vtkTransform>:<wbr>:New();</div><div> transform->Translate(<wbr>startPoint);</div><div> transform->Concatenate(matrix)<wbr>;</div><div> transform->Scale(length, length, length);</div><div> transform->RotateZ(-90.0); // orient along x axis</div><div> transform->Translate(0, .5, 0); // translate to end of cylinder</div></div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Tue, Dec 13, 2016 at 10:15 AM, M. Jordan <span dir="ltr"><<a href="mailto:mjordan@live.at" target="_blank">mjordan@live.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_4107274521854434116m_5412927093321539544divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" dir="ltr">
<p>Thank you very much!<br>
The example works fine, but when I change the source from arrow to cylinder the result is strange (not aligned).<br>
I don't know why<br>
</p>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div id="m_4107274521854434116m_5412927093321539544divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>><br>
<b>Gesendet:</b> Dienstag, 13. Dezember 2016 15:23<br>
<b>An:</b> Cory Quammen<br>
<b>Cc:</b> VTK Users; M. Jordan<br>
<b>Betreff:</b> Re: [vtkusers] Align vtk cylinder source to a given vector</font>
<div> </div>
</div>
<div>
<div dir="auto">This example may help
<div dir="auto"><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/OrientedArrow" id="m_4107274521854434116m_5412927093321539544LPlnk574861" target="_blank">http://www.vtk.org/Wiki/VTK/Ex<wbr>amples/Cxx/GeometricObjects/Or<wbr>ientedArrow</a>
<div id="m_4107274521854434116m_5412927093321539544LPBorder_GT_14816420598130.05547824368409249" style="margin-bottom:20px;overflow:auto;width:100%;text-indent:0px">
<table id="m_4107274521854434116m_5412927093321539544LPContainer_14816420598090.0042604169287056015" style="width:90%;background-color:rgb(255,255,255);overflow:auto;padding-top:20px;padding-bottom:20px;margin-top:20px;border-top:1px dotted rgb(200,200,200);border-bottom:1px dotted rgb(200,200,200)" cellspacing="0">
<tbody>
<tr style="border-spacing:0px" valign="top">
<td id="m_4107274521854434116m_5412927093321539544TextCell_14816420598100.886515364853037" style="vertical-align:top;padding:0px;display:table-cell" colspan="2">
<div id="m_4107274521854434116m_5412927093321539544LPRemovePreviewContainer_14816420598100.6588594714355362"></div>
<div id="m_4107274521854434116m_5412927093321539544LPTitle_14816420598100.9171813806865823" style="color:rgb(0,120,215);font-weight:400;font-size:21px;font-family:"wf_segoe-ui_light","Segoe UI Light","Segoe WP Light","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif;line-height:21px">
<a id="m_4107274521854434116m_5412927093321539544LPUrlAnchor_14816420598110.35002429549377434" style="text-decoration:none" href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/OrientedArrow" target="_blank">VTK/Examples/Cxx/GeometricObje<wbr>cts/OrientedArrow ...</a></div>
<div id="m_4107274521854434116m_5412927093321539544LPMetadata_14816420598120.5402721156705114" style="margin:10px 0px 16px;color:rgb(102,102,102);font-weight:400;font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif;font-size:14px;line-height:14px">
<a href="http://www.vtk.org" target="_blank">www.vtk.org</a></div>
<div id="m_4107274521854434116m_5412927093321539544LPDescription_14816420598130.5861063479832308" style="display:block;color:rgb(102,102,102);font-weight:400;font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif;font-size:14px;line-height:20px;max-height:100px;overflow:hidden">
Download and Build OrientedArrow. Click here to download OrientedArrow. and its CMakeLists.txt file. Once the tarball OrientedArrow.tar has been downloaded and extracted,</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
</div><div><div class="m_4107274521854434116h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Dec 13, 2016 9:13 AM, "Cory Quammen" <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here's a sketch of how to do this in VTK:<br>
<br>
* Find the cross product h between the normalized default cylinder<br>
axis c and your normalized direction vector v.<br>
* Now compute theta = acos(d) where d is the dot product of c and v.<br>
theta is the rotation angle about h you need to rotate the cylinder to<br>
the direction vector.<br>
* Use vtkTransformFilter with the transform set to a vtkTransform<br>
where you have called vtkTransform::RotateWXYZ (double angle, double<br>
x, double y, double z). theta is in radians, but angle is expected to<br>
be in degrees, so you'll need to convert.<br>
<br>
Hope that helps,<br>
Cory<br>
<br>
On Tue, Dec 13, 2016 at 6:33 AM, M. Jordan <<a href="mailto:mjordan@live.at" target="_blank">mjordan@live.at</a>> wrote:<br>
> Hi,<br>
><br>
> i have a cylinder and a given direction vector. Now I want to align the<br>
> cylinder along that vector.<br>
> How can I do this?<br>
><br>
> Thank you!<br>
><br>
><br>
> ______________________________<wbr>_________________<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<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">
http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</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=<wbr>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/mail<wbr>man/listinfo/vtkusers</a><br>
><br>
<br>
<br>
<br>
--<br>
Cory Quammen<br>
Staff R&D Engineer<br>
Kitware, Inc.<br>
______________________________<wbr>_________________<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/opensou<wbr>rce/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_FA<wbr>Q</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=<wbr>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/mail<wbr>man/listinfo/vtkusers</a><br>
</blockquote>
</div>
</div>
</div></div></div>
</div>
</div>
</div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_4107274521854434116gmail_signature" data-smartmail="gmail_signature">Unpaid intern in BillsBasement at noware dot com<br></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Unpaid intern in BillsBasement at noware dot com<br></div>
</div>