template class sophus::Region¶
Overview¶
A region is a closed interval [a, b] with a being the lower bound (=min) and b being the upper bound (=max). More…
#include <region.h> template <PointType TPoint> class Region { public: // typedefs using Point = TPoint ; using Scalar = typename PointTraits<TPoint>::Scalar ; // fields static constexpr bool kIsInteger = PointTraits<TPoint>::kIsInteger; static constexpr int kRows = PointTraits<TPoint>::kRows; static constexpr int kCols = PointTraits<TPoint>::kCols; static constexpr int kDim = kRows* kCols; Region<TScalar> const&segment_y noexcept { auto region = Region<TPoint>::uninitialized(); return region; Region<TScalar> const& segment_y; Region<TScalar> const Region<TScalar> const&segment_z noexcept { auto region = Region<TPoint>::uninitialized(); Region<TScalar> const Region<TScalar> const& segment_z; Region<TScalar> const Region<TScalar> const Region<TScalar> const&segment_w noexcept { auto region = Region<TPoint>::uninitialized(); // construction template <class TScalar> Region(TScalar const& p1, TScalar const& p2); // methods static Region<TPoint> uninitialized(); static Region<TPoint> empty(); static Region<TPoint> unbounded(); static Region<TPoint> from(TPoint const& p); static Region<TPoint> fromMinMax(TPoint const& min, TPoint const& max); template <class TScalar> requires(kDim = =2) const; template <class TScalar> requires(kDim = =3) const; template <class TScalar> requires(kDim = =4) const; region setElem( segment_x, 0 ); region setElem( segment_y, 1 ); region setElem( segment_z, 2 ); region setElem( segment_w, 3 ); Region<Scalar> const& getElem(size_t row) const; void setElem( size_t row, Region<Scalar> const& s ); TPoint const& min() const; TPoint const& max() const; TPoint clamp(TPoint const& point) const; bool contains(TPoint const& point) const; TPoint range() const; TPoint mid() const; Region<TPoint>& extend(Region const& other); Region<TPoint>& extend(TPoint const& point); Region<TPoint> translated(TPoint const& p) const; template <class TOtherPoint> Region<TOtherPoint> cast() const; template <class TOtherPoint> Region<TOtherPoint> encloseCast() const; template <class TOtherPoint> Region<TOtherPoint> roundCast() const; bool isEmpty() const; bool isDegenerated() const; bool isProper() const; bool isUnbounded() const; };
Detailed Documentation¶
A region is a closed interval [a, b] with a being the lower bound (=min) and b being the upper bound (=max).
Here, the bounds a, b sre either boths scalars (e.g. floats, doubles) or fixed length vectors/arrays (such as Eigen::Vector3f or Eigen::Array2d).
Special case for integer numbers:
An integer number X is considered being equivalent to a real region [X-0.5, X+0.5].
Construction¶
template <class TScalar> Region(TScalar const& p1, TScalar const& p2)
Convenient constructor to create a Segment from two points p1 and p2.
The points need not to be ordered. After construction it will be true that this-> min() <= this-> max().
Note: This constructor is only available for scalar regions. For multi-dim regions, use the fromMinMax() factory instead.,
Methods¶
static Region<TPoint> uninitialized()
Creates an uninitialized region.
static Region<TPoint> empty()
Creates and empty region.
static Region<TPoint> unbounded()
Creates unbounded region.
If TPoint is floating point, the region is [-inf, +inf].
static Region<TPoint> from(TPoint const& p)
Creates a region from a given point.
If TPoint is a floating point then the region is considered degenerated.
static Region<TPoint> fromMinMax(TPoint const& min, TPoint const& max)
Creates Region from two points, min and max.
The points min, max need not to be ordered. After construction it will be true that this-> min() <= this-> max().
TPoint const& min() const
Returns the lower bound of the region.
TPoint const& max() const
Returns the upper bound of the region.
TPoint clamp(TPoint const& point) const
Returns the clamped version of the given point.
bool contains(TPoint const& point) const
Returns true if the region contains the given point.
TPoint range() const
Returns the range of the region.
It is zero if the region is not proper.
TPoint mid() const
Returns the mid point.
Note: If TPoint is an integer point then the result will be rounded to the closed integer.
Region<TPoint>& extend(Region const& other)
Extends this by other region.
Region<TPoint>& extend(TPoint const& point)
Extends this by given point.
Region<TPoint> translated(TPoint const& p) const
Returns translated region.
template <class TOtherPoint> Region<TOtherPoint> encloseCast() const
Returns the smallest integer region which contains this.
example: [1.2, 1.3] -> [1, 2]
template <class TOtherPoint> Region<TOtherPoint> roundCast() const
Rounds given region bounds and returns resulting integer region.
example: [1.2, 2.3] -> [1, 2] example: [1.1, 2.7] -> [1, 3]
bool isEmpty() const
Returns true if region is empty.
bool isDegenerated() const
Returns true if region contains a single floating point number.
bool isProper() const
Returns true if region is neither empty nor degenerated. Hence it contains a range of values.
bool isUnbounded() const
Returns true if region has no bounds.