AGX Dynamics 2.37.3.4
Loading...
Searching...
No Matches
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.
 
 Range (const Range &rhs)
 Copy constructor.
 
 Range (const Range &rhs, const T &value, size_t i)
 
 Range (const T &Min, const T &Max)
 Standard creation: set min and max.
 
 Range (const T &x)
 Set min=-x and max=x.
 
 Range (const Vec2 &vec)
 Cast operator from Vec2.
 
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.
 
bool hasInfinite () const
 
bool inside (const T &x) const
 
bool isInfinite () const
 
T & lower ()
 
lower () const
 
template<typename T2 >
Range operator* (const T2 &rhs) const
 
template<typename T2 >
Range< T > operator* (const T2 &rhs) const
 
Rangeoperator= (const Range &rhs)
 Assignment operator.
 
int outside (const T &x) const
 
bool overlap (const Range< T > &r) const
 
void setLower (T lower)
 Set the lower bound for the range.
 
void setUpper (T upper)
 Set the upper bound for the range.
 
span () const
 
T & upper ()
 
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 243 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 249 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 255 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 259 of file Range.h.

◆ Range() [5/6]

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

Copy constructor.

Definition at line 266 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 272 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 361 of file Range.h.

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

◆ hasInfinite()

template<class T >
bool agx::Range< T >::hasInfinite
Returns
True if at least one of the range sides is infinite, including both at the same infinity.

Definition at line 330 of file Range.h.

◆ 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 389 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 in both directions

Definition at line 324 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 286 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 292 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 355 of file Range.h.

◆ operator=()

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

Assignment operator.

Definition at line 342 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 376 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 396 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 ( lower)

Set the lower bound for the range.

Parameters
lower- the new lower bound

Definition at line 310 of file Range.h.

◆ setUpper()

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

Set the upper bound for the range.

Parameters
upper- the new upper bound

Definition at line 317 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 336 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 298 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 304 of file Range.h.


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