mt
 All Classes Files Functions Enumerations Groups Pages
Public Member Functions | List of all members
mt::Interval Class Reference

One-dimensional closed interval class. More...

#include <interval.h>

Public Member Functions

 Interval ()
 Default constructor.
 Interval (const Scalar &s)
 Constructor for single point interval (degenerate case [s, s]).
 Interval (const Scalar &bound1, const Scalar &bound2)
 Constructor for lower and upper bounds input (order is irrelevant).
bool operator== (const Interval &in) const
bool operator!= (const Interval &in) const
Scalar center () const
 Interval center.
Scalar width () const
 Interval width.
Intervalwiden (const Scalar &s)
 Widen interval by 2 s (s at each endpoint).
Scalar getLowerBound () const
 Gets interval lower bound.
Scalar & getLowerBoundRef ()
const Scalar & getLowerBoundRef () const
Scalar getUpperBound () const
 Gets interval upper bound.
Scalar & getUpperBoundRef ()
const Scalar & getUpperBoundRef () const
void setValue (const Scalar &s)
 Sets interval.
void setValue (const Scalar &lb, const Scalar &ub)
 Sets interval.

Detailed Description

One-dimensional closed interval class.

This is an example of how to use the Interval class:

using namespace mt;
// Some interval declarations
Interval in1; // outputs as [0.0, 0.0]
Interval in2(1.0); // outputs as [1.0, 1.0]
Interval in3(0.0, 2.0); // outputs as [0.0, 2.0]
Interval in4(-1.0, 1.0); // outputs as [-1.0, 1.0]
Interval in5(-0.5, -0.25); // outputs as [-0.5, -0.25]
// Tests and operations using intervals
bool test;
Scalar s;
test = isOverlap(in3, in4) // true
test = isOverlap(in3, in5) // false
test = isContained(1.0, in3) // true
test = isContained(in5, in4) // true
test = isContained(in5, in3) // false
in = hull(in3, in5) // in = [-0.5, 2.0]
in = hull(in2, in5) // in = [-0.5, 1.0]
in4.widen(1.0) // in4 = [-2.0, 2.0]
s = in4.center() // s = 0.0
s = in4.width() // s = 4.0

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