<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hi David,<br><br>Thanks for your reply. Three comments:<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">
1. The documentation doesn't explain this is the behavior.<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">2. Projected by what direction. I would assume by the direction of the triangle normal. But this is not consistant with testing p=P((5,1,10)) in the below script which is reported by vtk to <b>not</b> be in the triangle (a,b,c).<br>
</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">3. Could this behavior be related to my other reported bug in vtkCellLocator.FindCell() that return the ''wrong" vtkTriangle, which does not contain the queried point?<br>
<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks!<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Dov<br><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 11:57 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Dov,<br>
<br>
The PointInTriangle method checks whether the point, after being<br>
projected onto the plane of the triangle, lies within the triangle.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Tue, Feb 18, 2014 at 1:11 PM, Dov Grobgeld <<a href="mailto:dov.grobgeld@gmail.com">dov.grobgeld@gmail.com</a>> wrote:<br>
> The following is a comparison of testing whether a point p falls within the<br>
> plane of a triangle a,b,c by basic python code vs by using vtk.<br>
><br>
> #!/usr/bin/python<br>
><br>
> from numpy import cross, dot, sqrt<br>
> from numpy import array as P<br>
> import vtk<br>
><br>
> def norm(v):<br>
> mag = sqrt((v**2).sum())<br>
> return v/mag<br>
><br>
> a,b,c = (P((0,0,0)),<br>
> P((10,0,0)),<br>
> P((10,10,0)))<br>
><br>
> p = P((5,1,1))<br>
><br>
> # Test for linearity<br>
> #<br>
> # b<br>
> # / \<br>
> # / \<br>
> # / p \<br>
> # a-------c<br>
> #<br>
> N1 = norm(cross(b-a, p-a))<br>
> N2 = norm(cross(p-c, b-c))<br>
> N1dotN2 = dot(N1,N2)<br>
> print 'By norms: ', N1dotN2 > 0.99<br>
><br>
> # Same test with vtk<br>
> print 'vtkInTriangle = ', vtk.vtkTriangle.PointInTriangle(p, a,b,c, 1e-10)<br>
><br>
> The result is:<br>
><br>
> By norms: False<br>
> vtkInTriangle = 1<br>
><br>
> It is trivial that the point p does not fall in the triangle. But still vtk<br>
> sais so. Is this a bug in vtk or am I misunderstanding what<br>
> vtkTriangle.PointInTriangle() is doing?<br>
><br>
> Thanks!<br>
> Dov<br>
</div></div></blockquote></div><br></div>