fuzzyContains added

This commit is contained in:
Uwe Rathmann 2020-07-31 07:40:04 +02:00
parent 8a8bfc4124
commit 97b1c7167d
2 changed files with 16 additions and 0 deletions

View File

@ -4,6 +4,7 @@
*****************************************************************************/
#include "QskIntervalF.h"
#include "QskFunctions.h"
#include <algorithm>
void QskIntervalF::unite( const QskIntervalF& other ) noexcept
@ -118,6 +119,20 @@ QskIntervalF QskIntervalF::extended( qreal value ) const noexcept
return QskIntervalF( lower, upper );
}
bool QskIntervalF::fuzzyContains( qreal value ) const
{
if ( !isValid() )
return false;
if ( ( value < m_lowerBound ) && !qskFuzzyCompare( value, m_lowerBound ) )
return false;
if ( ( value > m_upperBound ) && !qskFuzzyCompare( value, m_upperBound ) )
return false;
return true;
}
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>

View File

@ -37,6 +37,7 @@ class QSK_EXPORT QskIntervalF
void setWidth( qreal ) noexcept;
constexpr bool contains( qreal value ) const noexcept;
bool fuzzyContains( qreal value ) const;
static constexpr QskIntervalF normalized( qreal value1, qreal value2 ) noexcept;