示例#1
0
bool Interval::intersect_soft (Interval tmp)
{
    if ((product(tmp.s).sign() == product(tmp.e).sign() && (product(tmp.s)).sign() != 0) ||
		(tmp.product(s).sign() == (tmp.product(e)).sign() && (tmp.product(s)).sign() != 0))
		return false;
	if (product(tmp.s).sign() == product(tmp.e).sign() && (product(tmp.s)).sign() == 0)
	{
		Fraction max1;
		Fraction max2;
		Fraction min1;
		Fraction min2;
		if(s.getX() != e.getX())
		{
			max1 = (s.getX() <= e.getX() ? e.getX() : s.getX());
			max2 = (s.getX() <= e.getX() ? e.getX() : s.getX());
			min1 = (s.getX() <= e.getX() ? s.getX() : e.getX());
			min2 = (s.getX() <= e.getX() ? e.getX() : s.getX());
		}
		else
		{
			max1 = (s.getY() <= e.getY() ? e.getY() : s.getY());
			max2 = (s.getY() <= e.getY() ? e.getY() : s.getY());
			min1 = (s.getY() <= e.getY() ? s.getY() : e.getY());
			min2 = (s.getY() <= e.getY() ? e.getY() : s.getY());
		}
		return (max1 >= min2 && max2 >= min1);
	}
	if(product(tmp.s).sign() != product(tmp.e).sign() && tmp.product(s).sign() != (tmp.product(e)).sign())
		return true;
	return false;
}
示例#2
0
bool Interval::intersect_strong (Interval tmp)
{
	int sign1 = product(tmp.s).sign();
	int sign2 = product(tmp.e).sign();
	
	if (sign1 == -sign2 && sign1 != 0)
    {
		sign1 = tmp.product(s).sign();
		sign2 = (tmp.product(e)).sign();
        if (sign1 == -sign2 && sign1 != 0)
            return true;
        else
            return false;
    }
    else
        return false;
}