public double overlapRelative ( DoubleRange other ) { double lenThis = length ( ) ; double lenOther = other . length ( ) ; if ( lenThis == 0 && lenOther == 0 ) { // check for single points being compared, if it's the same point overlap is 1 // if points are different, overlap is 0 return this . equals ( other ) ? 1 : 0 ; } double overlapAbs = overlapAbsolute ( other ) ; return overlapAbs / Math . max ( lenThis , lenOther ) ; // one of the lengths is guaranteed to be non-zero }
Relative overlap that is the overlap divided by the length of the largest interval . If both intervals are single points and they re equal - returns 1