The CrossPoints function is not calculating intersections correctly for vertical line segments. That is, in one of the lines being tested for intersection the x values are the same.
I have resolved the issue to Drawing.Graphics3D.CrossingLines() function. The x and y parameters are being set to NaN because of the calculation method.
I resolved the issue using the following replacement function:
Code: Select all
private bool CrossingLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, out double x, out double y)
{
double ua_t = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
double ub_t = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
double u_b = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
x = double.NaN;
y = double.NaN;
if ( u_b != 0 )
{
double ua = ua_t / u_b;
double ub = ub_t / u_b;
if ( 0 <= ua && ua <= 1 && 0 <= ub && ub <= 1 )
{
x = x1 + ua * (x2 - x1);
y = y1 + ua * (y2 - y1);
if (x == 0 && y == 0)
return false;
return true;
}
}
return false;
}
Cheers,
NojaPower