Commit e04f7da4 authored by T.J. Corona's avatar T.J. Corona
Browse files

in vtkLine, Assign parametric return values for colinear lines.

parent 4f679659
...@@ -126,6 +126,25 @@ int vtkLine::Intersection (double a1[3], double a2[3], ...@@ -126,6 +126,25 @@ int vtkLine::Intersection (double a1[3], double a2[3],
// Solve the system of equations // Solve the system of equations
if ( vtkMath::SolveLinearSystem(A,c,2) == 0 ) if ( vtkMath::SolveLinearSystem(A,c,2) == 0 )
{ {
// The lines are colinear. Therefore, one of the four endpoints is the
// point of closest approach
double minDist = VTK_DOUBLE_MAX;
double* p[4] = {a1,a2,b1,b2};
double* l1[4] = {b1,b1,a1,a1};
double* l2[4] = {b2,b2,a2,a2};
double* uv1[4] = {&v,&v,&u,&u};
double* uv2[4] = {&u,&u,&v,&v};
double dist,t;
for (unsigned i=0;i<4;i++)
{
dist = vtkLine::DistanceToLine(p[i],l1[i],l2[i],t);
if (dist < minDist)
{
minDist = dist;
*(uv1[i]) = t;
*(uv2[i]) = static_cast<double>(i%2);
}
}
return VTK_ON_LINE; return VTK_ON_LINE;
} }
else else
...@@ -875,4 +894,3 @@ void vtkLine::PrintSelf(ostream& os, vtkIndent indent) ...@@ -875,4 +894,3 @@ void vtkLine::PrintSelf(ostream& os, vtkIndent indent)
{ {
this->Superclass::PrintSelf(os,indent); this->Superclass::PrintSelf(os,indent);
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment