Beispiel #1
0
bool isBetween( const SbVec3f& p1, const SbVec3f& p2, const SbVec3f& p3 )
{
	if(! isCollinear( p1, p2, p3 ) )
		return false;

	if( !isZero( p1[0] - p2[0] ) ) 
		return ( p1[0] <= p3[0] && p3[0] <= p2[0] ) || ( p1[0] >= p3[0] && p3[0] >= p2[0] );
	else 
		return ( p1[1] <= p3[1] && p3[1] <= p2[1] ) || ( p1[1] >= p3[1] && p3[1] >= p2[1] );
}
Beispiel #2
0
/*public*/
string
LineIntersector::toString() const
{
	string str=inputLines[0][0]->toString()+"_"
			  +inputLines[0][1]->toString()+" "
			  +inputLines[1][0]->toString()+"_"
			  +inputLines[1][1]->toString()+" : ";
	if (isEndPoint()) {
		str+=" endpoint";
	}
	if (isProperVar) {
		str+=" proper";
	}
	if (isCollinear()) {
		str+=" collinear";
	}
	return str;
}
Beispiel #3
0
line immediateReachability(line I, vector a, vector b, line e) {
    double da = detVector(a, e);
    double db = detVector(b, e);
    if (da == 0 && db == 0) {return lineNotFound;}
    line ir = intervalRange(I, a, b, e);
    if ((a.x > 0 && b.x > 0 && MAX(ir.pt1.x, ir.pt2.x) <= MIN(I.pt1.x, I.pt2.x))
        || (a.x < 0 && b.x < 0 && MIN(ir.pt1.x, ir.pt2.x) >= MAX(I.pt1.x, I.pt2.x))
        || (a.y > 0 && b.y > 0 && MAX(ir.pt1.y, ir.pt2.y) <= MIN(I.pt1.y, I.pt2.y))
        || (a.y < 0 && b.y < 0 && MIN(ir.pt1.y, ir.pt2.y) >= MAX(I.pt1.y, I.pt2.y))) {
    return lineNotFound;
    }
    if (isCollinear(I, e) || ir.pt1.x > e.pt2.x || ir.pt2.x < e.pt1.x
        || (ir.pt1.x == ir.pt2.x && (ir.pt1.y > e.pt2.y || ir.pt2.y < e.pt1.y))) {
        return lineNotFound;
    }
    else{
        line r = collinearIntersection(ir, e);
        if (r.pt1.x == r.pt2.x && r.pt1.y == r.pt2.y) {return lineNotFound;}
        else {return r;}
    }
}