Rhino C++ API  8.14
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_Interval Class Reference

#include <opennurbs_point.h>

Public Member Functions

 ON_Interval ()
 The default constructor creates ON_Interval::EmptyInterval (ON_UNSET_VALUE,ON_UNSET_VALUE) More...
 
 ON_Interval (const ON_Interval &)=default
 
 ON_Interval (double t0, double t1)
 
 ~ON_Interval ()=default
 
int Clamp (double &value) const
 
double ClampedNormalizedParameterAt (double interval_parameter) const
 Returns a clamped normalized parameter from an interval value. This interval may be increasing, decreasing, or a singleton. More...
 
double ClampedParameterAt (double normalized_parameter) const
 Returns the interval's value at a clamped normalized parameter. This interval may be increasing, decreasing, or a singleton. More...
 
void Destroy ()
 
bool Expand (double delta)
 
bool Includes (const ON_Interval &other, bool bProperSubSet=false) const
 
bool Includes (double t, bool bTestOpenInterval=false) const
 
bool Intersection (const ON_Interval &)
 
bool Intersection (const ON_Interval &, const ON_Interval &)
 
bool IsDecreasing () const
 returns true if m_t[0] > m_t[0]; More...
 
bool IsEmptyInterval () const
 returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE More...
 
bool IsEmptySet () const
 returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE More...
 
bool IsIncreasing () const
 returns true if m_t[0] < m_t[1] More...
 
bool IsInterval () const
 returns truc if m_t[0] != m_t[1] More...
 
bool IsSingleton () const
 returns true if m_t[0] == m_t[1] != ON_UNSET_VALUE More...
 
bool IsValid () const
 returns ON_IsValid(m_t[0]) && ON_IsValid(m_t[1]) More...
 
double Length () const
 returns signed length, m_t[1]-m_t[0] More...
 
bool MakeIncreasing ()
 returns true if resulting interval IsIncreasing() More...
 
double Max () const
 returns larger of m_t[0] and m_t[1] More...
 
double Mid () const
 returns 0.5*(m_t[0] + m_t[1]) More...
 
double Min () const
 returns smaller of m_t[0] and m_t[1] More...
 
double NormalizedParameterAt (double interval_parameter) const
 
ON_Interval NormalizedParameterAt (ON_Interval interval_parameter) const
 
bool operator!= (const ON_Interval &rhs) const
 
ON_Intervaloperator= (const ON_Interval &)=default
 
bool operator== (const ON_Interval &rhs) const
 
double & operator[] (int)
 returns (index<=0) ? m_t[0] : m_t[1] More...
 
double operator[] (int) const
 returns (index<=0) ? m_t[0] : m_t[1] More...
 
double & operator[] (unsigned int)
 returns (index<=0) ? m_t[0] : m_t[1] More...
 
double operator[] (unsigned int) const
 returns (index<=0) ? m_t[0] : m_t[1] More...
 
double ParameterAt (double normalized_parameter) const
 Convert a normalized parameter to an interval value. The interval can be increasing, decreasing, or a singleton. More...
 
ON_Interval ParameterAt (ON_Interval normalized_interval) const
 Convert a a pair of normalized parameter values to a pair of interval values. This interval can be increasing, decreasing, or a singleton. More...
 
void Reverse ()
 
void Set (double t0, double t1)
 
void Swap ()
 
bool Union (const ON_Interval &)
 
bool Union (const ON_Interval &, const ON_Interval &)
 
bool Union (double t)
 
bool Union (int count, const double *t)
 

Static Public Member Functions

static int Compare (const ON_Interval &lhs, const ON_Interval &rhs)
 
static bool IntervalsOverlap (const ON_Interval &A, const ON_Interval &B)
 
static const ON_Interval Singleton (double t)
 

Public Attributes

double m_t [2]
 Interval = (m_t[0], m_t[1]) More...
 

Static Public Attributes

static const ON_Interval EmptyInterval
 (ON_UNSET_VALUE,ON_UNSET_VALUE) More...
 
static const ON_Interval Nan
 (ON_DBL_QNAN,ON_DBL_QNAN) More...
 
static const ON_Interval ZeroToOne
 (0.0, 1.0) More...
 
static const ON_Interval ZeroToTwoPi
 (0.0, 2.0*ON_PI) More...
 

Detailed Description

ON_Interval

Constructor & Destructor Documentation

◆ ON_Interval() [1/3]

ON_Interval::ON_Interval ( )

The default constructor creates ON_Interval::EmptyInterval (ON_UNSET_VALUE,ON_UNSET_VALUE)

◆ ~ON_Interval()

ON_Interval::~ON_Interval ( )
default

◆ ON_Interval() [2/3]

ON_Interval::ON_Interval ( const ON_Interval )
default

◆ ON_Interval() [3/3]

ON_Interval::ON_Interval ( double  t0,
double  t1 
)

Member Function Documentation

◆ Clamp()

int ON_Interval::Clamp ( double &  value) const

Description: value is clamped to the range of this interval.
Assumes this interval is not Decreasing(). Parameters: value -[in/out] value is set to x in interval such that |x - value|<= |x - y| for all y in this interval Returns: -1 if value<Min() 0 if value in interval +1 if value>Max()

◆ ClampedNormalizedParameterAt()

double ON_Interval::ClampedNormalizedParameterAt ( double  interval_parameter) const

Returns a clamped normalized parameter from an interval value. This interval may be increasing, decreasing, or a singleton.

Parameters
interval_parameterinterval_parameter may have any value but it is clamped to be in the interval before the normalized parameter is evaluated.
Returns
Set a = the value at the beginning of this interval and b = the value at the end of this interval. If a, b or interval_parameter is unset or nan, ON_DBL_QNAN is returned. If interval_parameter is in this interval, the corresponding normalized parameter is returned. If interval_parameter is outside the interval, the normalized parameter for the end closest to interval_parameter is returned.

◆ ClampedParameterAt()

double ON_Interval::ClampedParameterAt ( double  normalized_parameter) const

Returns the interval's value at a clamped normalized parameter. This interval may be increasing, decreasing, or a singleton.

Parameters
normalized_parameternormalized_parameter may have any value but it is clamped to be between 0 and 1 before the corresponding interval value is evaluated.
Returns
Set a = the value at the beginning of this interval and b = the value at the end of this interval. If a, b or normalized_parameter is unset or nan, ON_DBL_QNAN is returned. If normalized_parameter <= 0.0, a is returned. If normalized_parameter >= 1.0, b is returned. Otherwise (1.0-normalized_parameter)*a + normalized_parameter*b is returned.

◆ Compare()

static int ON_Interval::Compare ( const ON_Interval lhs,
const ON_Interval rhs 
)
static

Description: A well ordered dictionary compare function that is nan aware and can be used for robust sorting.

◆ Destroy()

void ON_Interval::Destroy ( )

◆ Expand()

bool ON_Interval::Expand ( double  delta)

Expand the interval by adding delta to m_t[1] and subtracting it from m_t[0]. So, when delta is positive and the interval is increasing this function expands the interval on each side. returns true if the result is increasing.

◆ Includes() [1/2]

bool ON_Interval::Includes ( const ON_Interval other,
bool  bProperSubSet = false 
) const

Description: Test an interval to see if it is contained in this interval. Parameters: other - [in] interval to test bProperSubSet - [in] if true, then the test is for a proper subinterval. Returns: If bProperSubSet is false, then the result is true when this->Min() <= other.Min() and other.Max() <= this->Max(). If bProperSubSet is true, then the result is true when this->Min() <= other.Min() and other.Max() <= this->Max() and at least one of the inequalities is strict.

◆ Includes() [2/2]

bool ON_Interval::Includes ( double  t,
bool  bTestOpenInterval = false 
) const

Description: Test a value t to see if it is inside the interval. Parameters: t - [in] value to test bTestOpenInterval - [in] If false, t is tested to see if it satisfies min <= t <= max. If true, t is tested to see if it satisfies min < t < max. Returns: true if t is in the interval and false if t is not in the interval.

◆ Intersection() [1/2]

bool ON_Interval::Intersection ( const ON_Interval )

If the intersection is not empty, then intersection = [max(this.Min(),arg.Min()), min(this.Max(),arg.Max())] Intersection() returns true if the intersection is not empty. The interval [ON_UNSET_VALUE,ON_UNSET_VALUE] is considered to be the empty set interval. The result of any intersection involving an empty set interval or disjoint intervals is the empty set interval.

◆ Intersection() [2/2]

bool ON_Interval::Intersection ( const ON_Interval ,
const ON_Interval  
)

If the intersection is not empty, then intersection = [max(argA.Min(),argB.Min()), min(argA.Max(),argB.Max())] Intersection() returns true if the intersection is not empty. The interval [ON_UNSET_VALUE,ON_UNSET_VALUE] is considered to be the empty set interval. The result of any intersection involving an empty set interval or disjoint intervals is the empty set interval.

◆ IntervalsOverlap()

static bool ON_Interval::IntervalsOverlap ( const ON_Interval A,
const ON_Interval B 
)
static

Description: Test a pair of interval to see if they have a non-empty intersection. Parameters: A - [in] interval to test B - [in] interval to test Returns: true if the intersection is non-empty, including if the intersection is a single point. false otherwise.

◆ IsDecreasing()

bool ON_Interval::IsDecreasing ( ) const

returns true if m_t[0] > m_t[0];

◆ IsEmptyInterval()

bool ON_Interval::IsEmptyInterval ( ) const

returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE

◆ IsEmptySet()

bool ON_Interval::IsEmptySet ( ) const

returns true if m_t[0] == m_t[1] == ON_UNSET_VALUE

◆ IsIncreasing()

bool ON_Interval::IsIncreasing ( ) const

returns true if m_t[0] < m_t[1]

◆ IsInterval()

bool ON_Interval::IsInterval ( ) const

returns truc if m_t[0] != m_t[1]

◆ IsSingleton()

bool ON_Interval::IsSingleton ( ) const

returns true if m_t[0] == m_t[1] != ON_UNSET_VALUE

◆ IsValid()

bool ON_Interval::IsValid ( ) const

returns ON_IsValid(m_t[0]) && ON_IsValid(m_t[1])

◆ Length()

double ON_Interval::Length ( ) const

returns signed length, m_t[1]-m_t[0]

◆ MakeIncreasing()

bool ON_Interval::MakeIncreasing ( )

returns true if resulting interval IsIncreasing()

◆ Max()

double ON_Interval::Max ( ) const

returns larger of m_t[0] and m_t[1]

◆ Mid()

double ON_Interval::Mid ( ) const

returns 0.5*(m_t[0] + m_t[1])

◆ Min()

double ON_Interval::Min ( ) const

returns smaller of m_t[0] and m_t[1]

◆ NormalizedParameterAt() [1/2]

double ON_Interval::NormalizedParameterAt ( double  interval_parameter) const

Description: Convert interval value, or pair of values, to normalized parameter. Parameters: interval_parameter - [in] value in interval Returns: Normalized parameter x so that min*(1.0-x) + max*x = interval_parameter. See Also: ON_Interval::ParameterAt

◆ NormalizedParameterAt() [2/2]

ON_Interval ON_Interval::NormalizedParameterAt ( ON_Interval  interval_parameter) const

◆ operator!=()

bool ON_Interval::operator!= ( const ON_Interval rhs) const

Returns: True if (lhs.m_t[0] != rhs.m_t[0]) or (lhs.m_t[1] != rhs.m_t[1]) and no values are nans.

◆ operator=()

ON_Interval& ON_Interval::operator= ( const ON_Interval )
default

◆ operator==()

bool ON_Interval::operator== ( const ON_Interval rhs) const

Returns: True if (lhs.m_t[0] == rhs.m_t[0]) and (lhs.m_t[1] === rhs.m_t[1]).

◆ operator[]() [1/4]

double& ON_Interval::operator[] ( int  )

returns (index<=0) ? m_t[0] : m_t[1]

◆ operator[]() [2/4]

double ON_Interval::operator[] ( int  ) const

returns (index<=0) ? m_t[0] : m_t[1]

◆ operator[]() [3/4]

double& ON_Interval::operator[] ( unsigned int  )

returns (index<=0) ? m_t[0] : m_t[1]

◆ operator[]() [4/4]

double ON_Interval::operator[] ( unsigned int  ) const

returns (index<=0) ? m_t[0] : m_t[1]

◆ ParameterAt() [1/2]

double ON_Interval::ParameterAt ( double  normalized_parameter) const

Convert a normalized parameter to an interval value. The interval can be increasing, decreasing, or a singleton.

Parameters
normalized_parameterThe normalized parameter can have any value.
Returns
a*(1.0-normalized_parameter) + b*normalized_parameter where a = the value at the beginning of this interval and b = the value at the end of this interval.

◆ ParameterAt() [2/2]

ON_Interval ON_Interval::ParameterAt ( ON_Interval  normalized_interval) const

Convert a a pair of normalized parameter values to a pair of interval values. This interval can be increasing, decreasing, or a singleton.

Parameters
normalized_intervalThe normalized parameters can have any value.
Returns
a*(1.0-normalized_parameter) + b*normalized_parameter where a = the value at the beginning of this interval and b = the value at the end of this interval.

◆ Reverse()

void ON_Interval::Reverse ( )

Description: Changes interval to [-m_t[1],-m_t[0]].

◆ Set()

void ON_Interval::Set ( double  t0,
double  t1 
)

Description: Sets interval to [t0,t1] Parameters: t0 - [in] t1 - [in] See Also: ON_Interval::ON_Interval( double, double )

◆ Singleton()

static const ON_Interval ON_Interval::Singleton ( double  t)
static

Returns: ON_Interval(t,t).

◆ Swap()

void ON_Interval::Swap ( )

Description: Swaps m_t[0] and m_t[1].

◆ Union() [1/4]

bool ON_Interval::Union ( const ON_Interval )

The union of an empty set and an increasing interval is the increasing interval. The union of two empty sets is empty. The union of an empty set an a non-empty interval is the non-empty interval. The union of two non-empty intervals is union = [min(this.Min(),arg.Min()), max(this.Max(),arg.Max()),] Union() returns true if the union is not empty.

◆ Union() [2/4]

bool ON_Interval::Union ( const ON_Interval ,
const ON_Interval  
)

The union of an empty set and an increasing interval is the increasing interval. The union of two empty sets is empty. The union of an empty set an a non-empty interval is the non-empty interval. The union of two non-empty intervals is union = [min(argA.Min(),argB.Min()), max(argA.Max(),argB.Max()),] Union() returns true if the union is not empty.

◆ Union() [3/4]

bool ON_Interval::Union ( double  t)
Parameters
tthis = this union arg

◆ Union() [4/4]

bool ON_Interval::Union ( int  count,
const double *  t 
)
Parameters
countthis = this union arg

Member Data Documentation

◆ EmptyInterval

const ON_Interval ON_Interval::EmptyInterval
static

(ON_UNSET_VALUE,ON_UNSET_VALUE)

◆ m_t

double ON_Interval::m_t[2]

Interval = (m_t[0], m_t[1])

◆ Nan

const ON_Interval ON_Interval::Nan
static

(ON_DBL_QNAN,ON_DBL_QNAN)

◆ ZeroToOne

const ON_Interval ON_Interval::ZeroToOne
static

(0.0, 1.0)

◆ ZeroToTwoPi

const ON_Interval ON_Interval::ZeroToTwoPi
static

(0.0, 2.0*ON_PI)