Interval
 atan2(Interval yInterval, Interval xInterval) {
     if (yInterval.isEmpty() || xInterval.isEmpty()) {
         return Interval::EMPTY();
     } else if (xInterval.lowerBound() > 0.0) {
         return atan(yInterval / xInterval);
     } else if (yInterval.lowerBound() > 0.0) {
         return atan(-xInterval / yInterval) + M_PI / 2;
     } else if (yInterval.upperBound() < 0.0) {
         return atan(-xInterval / yInterval) - M_PI / 2;
     } else {
         return Interval(-M_PI, M_PI);
     }
 }
Exemple #2
0
Intervals Interval::unionize(Interval& other) {
	Intervals result;
	if (isEmpty()) {
		result.push_back(other);
		return result;
	}
	else if (other.isEmpty()) {
		result.push_back(*this);
		return result;
	}
	else if (intersects(*this, other)) {
		//std::cout << "intersecting" << std::endl;
		Interval newInt(std::min(_min, other._min), std::max(_max, other._max));
		result.push_back(newInt);
		return result;
	}
	else {
		if (_min < other._min) {
			result.push_back(*this);
			result.push_back(other);
			return result;
		}
		else {
			result.push_back(other);
			result.push_back(*this);
			return result;
		}
	}
	return result;
}
Exemple #3
0
bool Interval::operator == ( const Interval& other ) const
{
	if ( isEmpty() && other.isEmpty() )
		return true ;

	return _lower == other._lower && _upper == other._upper ;
}
Exemple #4
0
bool  Interval::intersects( const Interval & other ) const
{
	//empty intervals never intersects
	if ( isEmpty() || other.isEmpty() )
		return false ;

	return ! ( _lower > other._upper || _upper < other._lower ) ;
}
 Interval
 exp(Interval interval) {
     if (interval.isEmpty()) {
         return Interval::EMPTY();
     } else {
         return Interval(exp(interval.lowerBound()), exp(interval.upperBound()));
     }
 }
Exemple #6
0
Interval Interval::intersect(Interval& other) {
	Interval result;
	if (isEmpty() || other.isEmpty()) {
		return result;
	}
	if (intersects(*this, other)) {
		result = Interval(std::max(_min, other._min), std::min(_max, other._max));
	}
	return result;
}
 Interval
 acos(Interval interval) {
     if (interval.isEmpty() || interval.lowerBound() > 1.0 || interval.upperBound() < -1.0) {
         return Interval::EMPTY();
     } else {
         return Interval(
             acos(min(interval.upperBound(), 1.0)),
             acos(max(interval.lowerBound(), -1.0))
         );
     }
 }
 Interval
 log(Interval interval) {
     if (interval.isEmpty() || interval.upperBound() < 0.0) {
         return Interval::EMPTY();
     } else if (interval.lowerBound() > 0.0) {
         return Interval(log(interval.lowerBound()), log(interval.upperBound()));
     } else if (interval.upperBound() > 0.0) {
         return Interval(-std::numeric_limits<double>::infinity(), log(interval.upperBound()));
     } else {
         return -std::numeric_limits<double>::infinity();
     }
 }
Exemple #9
0
void  Interval::expandToInclude( const Interval & other )
{
	//ignore empty interval
	if ( other.isEmpty() )
		return ;

	if ( isEmpty() ){
		(*this) = other ;
	}else{
		_lower = std::min( _lower, other._lower );
		_upper = std::max( _upper, other._upper );
	}
}
Exemple #10
0
Intervals Interval::difference(Interval& diff) {
	Intervals result;
	if (isEmpty()) {
		return result;
	}
	else if (diff.isEmpty()) {
		result.push_back(*this);
		return result;
	}
	if (intersects(*this, diff)) {
		if (_min < diff._min) {
			Interval temp(_min, diff._min);
			result.push_back(temp);
		}
		if (_max > diff._max) {
			Interval temp(diff._max, _max);
			result.push_back(temp);
		}
	}
	else {
		result.push_back(*this);
	}
	return result;
}