<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Thank you very much!<br>
<br>
The problem is that most of the points are on the surface. Therefore test point = closest point.<br>
I only use the cellLocator to get the corresponding cell.<br>
</p>
<p>Now I try to get the normale vector of the whole cell (orientation of the cell).<br>
<br>
Is there a way to get that vector?<br>
</p>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>Von:</b> Girish Lande <girish.lande@agiliad.com><br>
<b>Gesendet:</b> Mittwoch, 11. Jänner 2017 12:43<br>
<b>An:</b> M. Jordan<br>
<b>Betreff:</b> Re: [vtkusers] Get normal vector of the closest polydata cell to a given test point</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi Jordan,</div>
<div><br>
</div>
<div>You can use vector between your test point and closest point as NORMAL vector.</div>
<div>Please see code snippet below.</div>
<div>normalizedX is output <br>
</div>
<div><br>
</div>
<div>double* pos = picker->GetPickPosition();</div>
<div><br>
</div>
<div>        double testPoint[3] = {pos[0],pos[1],pos[2]};</div>
<div><br>
</div>
<div>        //Find the closest points to TestPoint</div>
<div>        double closestPoint[3];//the coordinates of the closest point will be returned here</div>
<div>        double closestPointDist2; //the squared distance to the closest point will be returned here</div>
<div>        vtkIdType cellId; //the cell id of the cell containing the closest point will be returned here</div>
<div>        int subId; //this is rarely used (in triangle strips only, I believe)</div>
<div>        cellLocator->FindClosestPoint(testPoint, closestPoint, cellId, subId, closestPointDist2);</div>
<div><br>
</div>
<div>        std::cout << "Coordinates of closest point: " << closestPoint[0] << " " << closestPoint[1] << " " << closestPoint[2] << std::endl;</div>
<div>        std::cout << "Squared distance to closest point: " << closestPointDist2 << std::endl;</div>
<div>        std::cout << "CellId: " << cellId << std::endl;</div>
<div><br>
</div>
<div>        endPoint[0]=pos[0];</div>
<div>        endPoint[1]=pos[1];</div>
<div>        endPoint[2]=pos[2];</div>
<div>        startPoint[0]=closestPoint[0];</div>
<div>        startPoint[1]=closestPoint[1];</div>
<div>        startPoint[2]=closestPoint[2];</div>
<div><br>
</div>
<div>
<div>// Compute a basis</div>
<div>         double normalizedX[3];</div>
<div>         double normalizedY[3];</div>
<div>         double normalizedZ[3];</div>
<div><br>
</div>
<div>         // The X axis is a vector from start to end</div>
<div>         vtkMath::Subtract(endPoint, startPoint, normalizedX);</div>
<div>         double length = vtkMath::Norm(normalizedX);</div>
<div>         length=1;</div>
<div>         vtkMath::Normalize(normalizedX);</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 11 January 2017 at 16:32, 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_-7214395725855727816divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hello,<br>
<br>
i have a test point p[x,y,z] and a polydata.<br>
I use <span>vtkCellLocator to get the closest cell of the polydata to this point.<br>
<br>
</span>I get:<br>
- the closest point<br>
- the squared distance to the closest point<br>
- cell ID<br>
<br>
Now I want to get the normal vector of the cell. I know the cell ID but I don't know how to get the
<br>
normal vector from it.<br>
<br>
Thank you!<br>
</p>
</div>
</div>
<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/<wbr>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_<wbr>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=<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/<wbr>mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">thanks & regards,
<div>Girish</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>