AGX Dynamics  2.35.0.1
agx::Range< T > Class Template Reference

A range object has a min and max value of a given type and provides services to tell whether a value is in that range or not. More...

#include <Range.h>

Public Member Functions

 Range ()
 Default constructor. Set min/max to -/+ infinity. More...
 
 Range (const Range &rhs)
 Copy constructor. More...
 
 Range (const Range &rhs, const T &value, size_t i)
 
 Range (const T &Min, const T &Max)
 Standard creation: set min and max. More...
 
 Range (const T &x)
 Set min=-x and max=x. More...
 
 Range (const Vec2 &vec)
 Cast operator from Vec2. More...
 
RangeViolation< T > excess (const T &x) const
 Compute all the details of range violation: parity is +1 when violating the upper limit, -1 when violating the lower limit, and 0 otherwise. More...
 
bool inside (const T &x) const
 
bool isInfinite () const
 
T & lower ()
 
T lower () const
 
template<typename T2 >
Range operator* (const T2 &rhs) const
 
template<typename T2 >
Range< T > operator* (const T2 &rhs) const
 
Range & operator= (const Range &rhs)
 Assignment operator. More...
 
int outside (const T &x) const
 
bool overlap (const Range< T > &r) const
 
void setLower (T lower)
 Set the lower bound for the range. More...
 
void setUpper (T upper)
 Set the upper bound for the range. More...
 
T span () const
 
T & upper ()
 
T upper () const
 

Detailed Description

template<class T>
class agx::Range< T >

A range object has a min and max value of a given type and provides services to tell whether a value is in that range or not.

A range object is setup with upper and lower limits, either or both of which may be infinite as defined in numeric_limits<Real>::infinity()

Definition at line 79 of file Range.h.

Constructor & Destructor Documentation

◆ Range() [1/6]

template<class T >
agx::Range< T >::Range ( const T &  Min,
const T &  Max 
)

Standard creation: set min and max.

Definition at line 238 of file Range.h.

◆ Range() [2/6]

template<class T >
agx::Range< T >::Range ( const Vec2 &  vec)
inlineexplicit

Cast operator from Vec2.

Definition at line 244 of file Range.h.

◆ Range() [3/6]

template<class T >
agx::Range< T >::Range
inline

Default constructor. Set min/max to -/+ infinity.

Definition at line 250 of file Range.h.

◆ Range() [4/6]

template<class T >
agx::Range< T >::Range ( const T &  x)
inlineexplicit

Set min=-x and max=x.

Definition at line 254 of file Range.h.

◆ Range() [5/6]

template<class T >
agx::Range< T >::Range ( const Range< T > &  rhs)
inline

Copy constructor.

Definition at line 261 of file Range.h.

◆ Range() [6/6]

template<class T >
agx::Range< T >::Range ( const Range< T > &  rhs,
const T &  value,
size_t  i 
)
inline

Definition at line 267 of file Range.h.

Member Function Documentation

◆ excess()

template<class T >
RangeViolation< T > agx::Range< T >::excess ( const T &  x) const
inline

Compute all the details of range violation: parity is +1 when violating the upper limit, -1 when violating the lower limit, and 0 otherwise.

The excess is either 0 if the argument is in range, or the (positive) distance to the nearest bound otherwise.

Definition at line 350 of file Range.h.

References agx::RangeViolation< T >::excess(), and agx::RangeViolation< T >::sign().

◆ inside()

template<class T >
bool agx::Range< T >::inside ( const T &  x) const
Returns
true if the value x is within range, including boundary.

Definition at line 378 of file Range.h.

Referenced by agx::Range< T >::overlap().

◆ isInfinite()

template<class T >
bool agx::Range< T >::isInfinite
Returns
true if the range spans an infinite range

Definition at line 319 of file Range.h.

◆ lower() [1/2]

template<class T >
T & agx::Range< T >::lower
Returns
a reference to the lower value

Definition at line 281 of file Range.h.

Referenced by agx::Range< T >::overlap(), and agx::WireContactConstraint::setBounds().

◆ lower() [2/2]

template<class T >
T agx::Range< T >::lower
Returns
the lower value

Definition at line 287 of file Range.h.

◆ operator*() [1/2]

template<class T >
template<typename T2 >
Range agx::Range< T >::operator* ( const T2 &  rhs) const

◆ operator*() [2/2]

template<class T >
template<typename T2 >
Range<T> agx::Range< T >::operator* ( const T2 &  rhs) const

Definition at line 344 of file Range.h.

◆ operator=()

template<class T >
Range< T > & agx::Range< T >::operator= ( const Range< T > &  rhs)
inline

Assignment operator.

Definition at line 331 of file Range.h.

◆ outside()

template<class T >
int agx::Range< T >::outside ( const T &  x) const
inline
Returns
-1 if the argument x is less than the lower limit, +1 if it is greater than the upper limit, and 0 otherwise.

Definition at line 365 of file Range.h.

◆ overlap()

template<class T >
bool agx::Range< T >::overlap ( const Range< T > &  r) const
Returns
true if the two interval overlap, including the case where they touch at the boundary.

Definition at line 385 of file Range.h.

References agx::Range< T >::inside(), agx::Range< T >::lower(), and agx::Range< T >::upper().

◆ setLower()

template<class T >
void agx::Range< T >::setLower ( T  lower)

Set the lower bound for the range.

Parameters
lower- the new lower bound

Definition at line 305 of file Range.h.

◆ setUpper()

template<class T >
void agx::Range< T >::setUpper ( T  upper)

Set the upper bound for the range.

Parameters
upper- the new upper bound

Definition at line 312 of file Range.h.

◆ span()

template<class T >
T agx::Range< T >::span
Returns
the span of this range (i.e., max - min)

Definition at line 325 of file Range.h.

◆ upper() [1/2]

template<class T >
T & agx::Range< T >::upper
Returns
a reference to the upper value

Definition at line 293 of file Range.h.

Referenced by agx::Range< T >::overlap(), and agx::WireContactConstraint::setBounds().

◆ upper() [2/2]

template<class T >
T agx::Range< T >::upper
Returns
the upper value

Definition at line 299 of file Range.h.


The documentation for this class was generated from the following file: