[vtk-developers] Bug or feature in vtkPlane::IntersectWithLine ?

Philippe Pebay philippe.pebay at kitware.com
Sun Nov 27 11:28:35 EST 2011


Hello all,

The IntersectWithLine()  routine in vtkPlane returns 0, i.e., no
intersection, whenever the plane and line are parallel.
Specifically, this occurs in lines 171-20, copied below:

  num = vtkMath::Dot(n,p0) - ( n[0]*p1[0] + n[1]*p1[1] + n[2]*p1[2] ) ;
  den = n[0]*p21[0] + n[1]*p21[1] + n[2]*p21[2];
  //
  // If denominator with respect to numerator is "zero", then the line and
  // plane are considered parallel.
  //

  // trying to avoid an expensive call to fabs()
  if (den < 0.0)
    {
    fabsden = -den;
    }
  else
    {
    fabsden = den;
    }
  if (num < 0.0)
    {
    fabstolerance = -num*VTK_PLANE_TOL;
    }
  else
    {
    fabstolerance = num*VTK_PLANE_TOL;
    }
  if ( fabsden <= fabstolerance )
    {
    t = VTK_DOUBLE_MAX;
    return 0;
    }

Nevertheless, a line may be parallel to a plane and yet be contained inside
said plane. In this case, the routine will return 0 just as if the line was
parallel and outside of the plane, as the calculation does not consider the
plane-to-line distance.

It might have been intended to be like this. However, this becomes a
problem in the implementation of vtkTriangle's implementation of
IntersectWithLine(), which first calls vtkPlane::IntersectWithLine(): as a
result, a line which goes through a vtkTriangle, while being contained in
the plane of this triangle, will be considered as NOT intersecting the
triangle, which is clearly an error.

I am therefore wondering whether this behavior of
vtkPlane::IntersectWithLine is a feature, or a bug.

If it is not a bug, then I would submit that the implementation of
vtkTriangle::IntersectWithLine() should be modified, by checking, for lines
that ARE parallel to the triangle, whether they are contained in the same
plane.

Please let me know what you think. Thank you,
Philippe




-- 
Philippe Pébay
Directeur de la Visualisation et du Calcul Haute Performance
Kitware SAS
20 rue de la Villette
69328 Lyon cedex 03, France
+33 (0)4.26.68.50.03
http://www.kitware.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20111127/1244de38/attachment.html>


More information about the vtk-developers mailing list