Autoware.Auto
autoware::common::geometry::Interval< T > Class Template Reference

Data structure to contain scalar interval bounds. More...

#include <interval.hpp>

Public Member Functions

 Interval ()
 Constructor: initialize an empty interval with members set to NaN. More...
 
 Interval (const T &min, const T &max)
 Constructor: specify exact interval bounds. More...
 

Static Public Member Functions

static bool abs_eq (const Interval &i1, const Interval &i2, const T &eps)
 Test whether the two intervals have bounds within epsilon of each other. More...
 
static T min (const Interval &i)
 The minimum bound of the interval. More...
 
static T max (const Interval &i)
 The maximum bound of the interval. More...
 
static T measure (const Interval &i)
 Return the measure (length) of the interval. More...
 
static bool zero_measure (const Interval &i)
 Utility for checking whether an interval has zero measure. More...
 
static bool empty (const Interval &i)
 Whether the interval is empty or not. More...
 
static bool contains (const Interval &i, const T &value)
 Test for whether a given interval contains a given value. More...
 
static bool is_subset_eq (const Interval &i1, const Interval &i2)
 Test for whether 'i1' subseteq 'i2'. More...
 
static Interval intersect (const Interval &i1, const Interval &i2)
 Compute the intersection of two intervals as a new interval. More...
 
static T clamp_to (const Interval &i, T val)
 Clamp a scalar 'val' onto 'interval'. More...
 

Friends

bool operator== (const Interval &i1, const Interval &i2)
 Compute equality. More...
 
bool operator!= (const Interval &i1, const Interval &i2)
 Compute inequality and the logical negation of equality. More...
 
std::ostream & operator<< (std::ostream &os, const Interval &i)
 Stream overload for Interval types. More...
 

Detailed Description

template<typename T>
class autoware::common::geometry::Interval< T >

Data structure to contain scalar interval bounds.

Postcondition
The interval is guaranteed to be valid upon successful construction. An interval [min, max] is "valid" if it is empty (min/max = NaN) or its bounds are ordered (min <= max).

Constructor & Destructor Documentation

◆ Interval() [1/2]

template<typename T >
autoware::common::geometry::Interval< T >::Interval

Constructor: initialize an empty interval with members set to NaN.

◆ Interval() [2/2]

template<typename T >
autoware::common::geometry::Interval< T >::Interval ( const T &  min,
const T &  max 
)

Constructor: specify exact interval bounds.

Note
An empty interval is specified by setting both bounds to NaN.
An exception is thrown if the specified bounds are invalid.
Postcondition
Construction is successful iff the interval is valid.

Member Function Documentation

◆ abs_eq()

template<typename T >
bool autoware::common::geometry::Interval< T >::abs_eq ( const Interval< T > &  i1,
const Interval< T > &  i2,
const T &  eps 
)
static

Test whether the two intervals have bounds within epsilon of each other.

Note
If both intervals are empty, this returns true. If only one is empty, this returns false.

◆ clamp_to()

template<typename T >
T autoware::common::geometry::Interval< T >::clamp_to ( const Interval< T > &  i,
val 
)
static

Clamp a scalar 'val' onto 'interval'.

Returns
If 'val' in 'interval', return 'val'; otherwise return the nearer interval bound.

◆ contains()

template<typename T >
bool autoware::common::geometry::Interval< T >::contains ( const Interval< T > &  i,
const T &  value 
)
static

Test for whether a given interval contains a given value.

Returns
True iff 'interval' contains 'value'.

◆ empty()

template<typename T >
bool autoware::common::geometry::Interval< T >::empty ( const Interval< T > &  i)
static

Whether the interval is empty or not.

Note
Emptiness refers to whether the interval contains any points and is thus a distinct property from measure: an interval is non-empty if contains only a single point even though its measure in that case is zero.
Returns
True iff the interval is empty.

◆ intersect()

template<typename T >
Interval< T > autoware::common::geometry::Interval< T >::intersect ( const Interval< T > &  i1,
const Interval< T > &  i2 
)
static

Compute the intersection of two intervals as a new interval.

◆ is_subset_eq()

template<typename T >
bool autoware::common::geometry::Interval< T >::is_subset_eq ( const Interval< T > &  i1,
const Interval< T > &  i2 
)
static

Test for whether 'i1' subseteq 'i2'.

Returns
True iff i1 subseteq i2.

◆ max()

template<typename T >
static T autoware::common::geometry::Interval< T >::max ( const Interval< T > &  i)
inlinestatic

The maximum bound of the interval.

◆ measure()

template<typename T >
T autoware::common::geometry::Interval< T >::measure ( const Interval< T > &  i)
static

Return the measure (length) of the interval.

Note
For empty or invalid intervals, NaN is returned. See Interval::empty for note on distinction between measure zero and the emptiness property.

◆ min()

template<typename T >
static T autoware::common::geometry::Interval< T >::min ( const Interval< T > &  i)
inlinestatic

The minimum bound of the interval.

◆ zero_measure()

template<typename T >
bool autoware::common::geometry::Interval< T >::zero_measure ( const Interval< T > &  i)
static

Utility for checking whether an interval has zero measure.

Note
For empty or invalid intervals, false is returned. See Interval::empty for note on distinction between measure zero and the emptiness property.
Returns
True iff the interval has zero measure.

Friends And Related Function Documentation

◆ operator!=

template<typename T >
bool operator!= ( const Interval< T > &  i1,
const Interval< T > &  i2 
)
friend

Compute inequality and the logical negation of equality.

Note
This is defined inline because the class is templated.

◆ operator<<

template<typename T >
std::ostream& operator<< ( std::ostream &  os,
const Interval< T > &  i 
)
friend

Stream overload for Interval types.

Note
Output precision is fixed inside the function definition, and the serialization is JSON compatible.
The serialization is lossy. It is used for debugging and for generating exception strings.

◆ operator==

template<typename T >
bool operator== ( const Interval< T > &  i1,
const Interval< T > &  i2 
)
friend

Compute equality.

Two intervals compare equal iff they are both valid and they are both either empty or have equal bounds.

Note
This is defined inline because the class is templated.
Returns
True iff the intervals compare equal.

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