I just encountered a problem with LineLine intersection method with two nearly parallel lines.
Rhino.Geometry.Intersect.Intersection.LineLine(edge1, edge2, out double t1, out double t2)
I was expecting the method return false or the parameters t1 and t2 are out of bounds, But this is not happening. I managed to solve this by a parallel check before computing the intersection.
Just so that you know!
the line-line intersection is supposed to find the closest points (shortest distance) between two infinite lines which are not perfectly parallel.
There is another overload of this method that lets you choose if you want to treat your lines as finite segments or not:
Thank you both! the second overload worked for me without a double check. however the documentation remarks that I must filter the “nearly parallel” lines !
bool rc = Intersect.LineLine(lineA, lineB, out a, out b, tolerance, segments);
double angle_tol = RhinoMath.ToRadians(1.0); // or whatever
double parallel_tol = Math.Cos(angle_tol);
if ( Math.Abs(lineA.UnitTangent * lineB.UnitTangent) >= parallel_tol )
... do whatever you think is appropriate