kazmath icon indicating copy to clipboard operation
kazmath copied to clipboard

Bug in kmSegment2WithSegmentIntersection

Open ratanki opened this issue 10 years ago • 0 comments

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.

ratanki avatar Jan 07 '16 05:01 ratanki