<div dir="ltr"><div><div>Hi,<br><br></div>The simple python code below seems to return the wrong parametric coordinates (if I understand correctly what they mean). This is with python 2.7 and VTK 6.3. <br><br></div><div>I'm creating a hex cell representing a unit cube [0, 1]^3. Then I create a ray with start/end points pA and pB respectively. The code finds the intersection between the ray and the cell, and the intersection point (0, 0.4, 0.3) looks right. However, I'm getting <br><br>[0.30000000000000004, 0.0, -1.0] <br><br></div><div>for the parametric coordinates -- I expected [0., 0.4, 0.3]. Shouldn't the pcoords be between 0 and 1? Why is the last pcoords not set?<br></div><div><br></div><div>Thanks in advance for any help.<br></div><div><br></div>--Alex<br><div><div><br>import vtk<br><br>cell = vtk.vtkHexahedron()<br><br>pts = cell.GetPoints()<br>pts.InsertPoint(0, 0., 0., 0.)<br>pts.InsertPoint(1, 1., 0., 0.)<br>pts.InsertPoint(2, 1., 1., 0.)<br>pts.InsertPoint(3, 0., 1., 0.)<br>pts.InsertPoint(4, 0., 0., 1.)<br>pts.InsertPoint(5, 1., 0., 1.)<br>pts.InsertPoint(6, 1., 1., 1.)<br>pts.InsertPoint(7, 0., 1., 1.)<br><br>pA = [-0.5, 0.4, 0.3]<br>pB = [ 0.5, 0.4, 0.3]<br><br>t = vtk.mutable(0.0)<br>intersectPt = [-1.0, -1.0, -1.0]<br>pcoords = [-1.0, -1.0, -1.0]<br>subId = vtk.mutable(-1)<br>tol = 1.e-10<br><br>res = cell.IntersectWithLine(pA, pB, tol, t, intersectPt, pcoords, subId)<br><br>if res:<br>    print 'found intersection at ', intersectPt<br>    print 'line parametric coord: ', t, ' cell parametric coords: ', pcoords, ' expected: ', [0., 0.4, 0.3], ' subId = ', subId<br><br clear="all"><div><div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Alexander Pletzer</div><div dir="ltr"><span style="font-size:12.8px">HPC Scientific Programmer for </span><span style="font-size:12.8px">New Zealand eScience Infrastructure (NeSI)</span></div><div dir="ltr"><span style="font-size:12.8px">National Institute of Water and Atmospheric Research (NIWA)</span><div>301 Evans Bay Parade, <span style="font-size:12.8px">Hataitai, Wellington 6021, </span><span style="font-size:12.8px">New Zealand</span></div><div>mobile: +64 21 085 79661</div><div><a href="http://www.niwa.co.nz" target="_blank">http://www.</a><a href="http://nesi.org.nz" target="_blank">nesi.org.nz</a><br></div></div></div></div></div></div></div></div></div>
</div></div></div></div></div>