kazmath
kazmath copied to clipboard
Bug in kmSegment2WithSegmentIntersection
In kmSegment2WithSegmentIntersection in ray2.c:
if( kmLine2WithLineIntersection( &(segmentA->start), &(segmentA->dir),
&(segmentB->start), &(segmentB->start),
&ua, &ub, &pt ) &&
(0.0 <= ua) && (ua <= 1.0) && (0.0 <= ub) && (ub <= 1.0)) {
intersection->x = pt.x;
intersection->y = pt.y;
return KM_TRUE;
}
Should be
if( kmLine2WithLineIntersection( &(segmentA->start), &(segmentA->dir),
&(segmentB->start), &(segmentB->dir),
&ua, &ub, &pt ) &&
(0.0 <= ua) && (ua <= 1.0) && (0.0 <= ub) && (ub <= 1.0)) {
intersection->x = pt.x;
intersection->y = pt.y;
return KM_TRUE;
}
Note the duplicated start in segmentB->start. The second one should be segmentB->dir
Not sure this is better than a PR?
Cheers.