Skip to content

Commit

Permalink
Merge pull request #198 from brownd1978/rangefix
Browse files Browse the repository at this point in the history
Fix overlap calculation
  • Loading branch information
brownd1978 authored Dec 10, 2024
2 parents 348e945 + dd93caa commit 157924f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions General/TimeRange.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace KinKal {
bool inRange(double t) const {return t >= begin() && t < end(); }
bool null() const { return end() == begin(); }
bool overlaps(TimeRange const& other ) const {
return (end() > other.begin() || begin() < other.end()); }
return inRange(other.begin()) || inRange(other.end()) || contains(other) || other.contains(*this); }
bool contains(TimeRange const& other) const {
return (begin() <= other.begin() && end() >= other.end()); }
// force time to be in range
Expand All @@ -30,8 +30,8 @@ namespace KinKal {
range_[0] = std::min(begin(),other.begin());
range_[1] = std::max(end(),other.end());
}
// restrict the range to the overlap with another range. Note that a null range is illegal,
// so null overlap leaves the object unchanged and returns 'false'
// restrict the range to the overlap with another range. If there is no overlap
// leave the object unchanged and return 'false'
bool restrict(TimeRange const& other ) {
bool retval = overlaps(other);
if(retval){
Expand Down

0 comments on commit 157924f

Please sign in to comment.