Go to the documentation of this file.
18 template <concepts::Po
intType TPo
int>
25 template <concepts::ScalarType TScalar>
31 template <concepts::ScalarType TScalar>
37 template <concepts::ScalarType TScalar>
53 template <concepts::Po
intType TPo
int>
62 static_assert(
kRows >= 1);
63 static_assert(
kCols >= 1);
121 template <
class TScalar>
123 TScalar
const& p1, TScalar
const& p2)
124 noexcept : min_max_{p1, p1} {
130 template <
class TScalar>
132 Region<TScalar> const& segment_x,
135 region.setElem(segment_x, 0);
140 template <
class TScalar>
142 Region<TScalar> const& segment_x,
146 region.setElem(segment_x, 0);
152 template <
class TScalar>
154 Region<TScalar> const& segment_x,
159 region.setElem(segment_x, 0);
162 region.setElem(segment_w, 3);
182 [[nodiscard]]
auto min() const noexcept -> TPoint const& {
190 [[nodiscard]]
auto max() const noexcept -> TPoint const& {
196 [[nodiscard]]
auto tryMin() const noexcept -> std::optional<TPoint> {
204 [[nodiscard]]
auto tryMax() const noexcept -> std::optional<TPoint> {
214 [[nodiscard]]
auto clamp(TPoint
const& point)
const noexcept -> TPoint {
219 [[nodiscard]]
auto contains(TPoint
const& point)
const noexcept ->
bool {
229 [[nodiscard]]
auto range() const noexcept -> TPoint {
231 return zero<TPoint>();
247 [[nodiscard]]
auto mid() const noexcept -> TPoint {
253 if (other.isEmpty()) {
277 [[nodiscard]]
auto translated(TPoint
const& p)
const noexcept
282 template <
class TOtherPo
int>
290 sophus::cast<TOtherPoint>(
min()), sophus::cast<TOtherPoint>(
max()));
297 plus(sophus::cast<TOtherPoint>(
min()), -0.5),
298 plus(sophus::cast<TOtherPoint>(
max()), 0.5));
303 "For floating to integer: call encloseCast() or roundCast() "
310 template <
class TOtherPo
int>
325 template <
class TOtherPo
int>
337 [[nodiscard]]
auto isEmpty() const noexcept ->
bool {
349 [[nodiscard]]
auto isProper() const noexcept ->
bool {
363 std::array<TPoint, 2> min_max_;
368 return lhs.min() == rhs.min() && lhs.max() == rhs.max();
auto round(TPoint s)
Definition: vector_space.h:157
auto min() const noexcept -> TPoint const &
Returns the lower bound of the region.
Definition: region.h:182
requires(kDim==2) static auto createPerAxis(Region< TScalar > const &segment_x
#define SOPHUS_ASSERT(...)
Definition: common.h:40
auto extend(Region const &other) noexcept -> Region< TPoint > &
Extends this by other region.
Definition: region.h:252
auto clamp(TPoint const &val, TPoint const &lo, TPoint const &hi) -> TPoint
Definition: vector_space.h:124
static auto unbounded() noexcept -> Region< TPoint >
Creates unbounded region.
Definition: region.h:82
#define SOPHUS_UNWRAP(...)
Definition: common.h:52
Image MutImage, owning images types.
Definition: num_diff.h:20
auto min(TPoint const &a, TPoint const &b) -> TPoint
Definition: vector_space.h:104
auto allTrue(TPoint const &p) -> bool
Definition: vector_space.h:54
auto tryMin() const noexcept -> std::optional< TPoint >
Returns the lower bound of the region if it exit and nullopt otherwise.
Definition: region.h:196
auto roundCast() const noexcept -> Region< TOtherPoint >
Rounds given region bounds and returns resulting integer region.
Definition: region.h:326
auto translated(TPoint const &p) const noexcept -> Region< TPoint >
Returns translated region.
Definition: region.h:277
auto isNan(TPoint const &p) -> bool
Definition: vector_space.h:84
static auto fromMinMax(TPoint const &min, TPoint const &max) noexcept -> Region< TPoint >
Creates Region from two points, min and max.
Definition: region.h:104
static auto empty() noexcept -> Region< TPoint >
Creates and empty region.
Definition: region.h:72
auto isUnbounded() const noexcept -> bool
Returns true if region has no bounds.
Definition: region.h:354
return region
Definition: region.h:137
auto max() const noexcept -> TPoint const &
Returns the upper bound of the region.
Definition: region.h:190
auto extend(TPoint const &point) noexcept -> Region< TPoint > &
Extends this by given point.
Definition: region.h:266
auto isLessEqual(TPoint const &lhs, TPoint const &rhs) -> bool
Definition: vector_space.h:183
auto ceil(TPoint s)
Definition: vector_space.h:143
requires std::is_same_v< TPoint, TScalar > Region(TScalar const &p1, TScalar const &p2) noexcept
Convenient constructor to create a Segment from two points p1 and p2.
Definition: region.h:122
static constexpr int kRows
Definition: region.h:60
static constexpr bool kIsInteger
Definition: region.h:56
static auto from(TPoint const &p) noexcept -> Region< TPoint >
Creates a region from a given point.
Definition: region.h:92
auto tryMax() const noexcept -> std::optional< TPoint >
Returns the lower bound of the region if it exists and nullopt otherwise.
Definition: region.h:204
auto plus(TPoint p, TPoint s)
Definition: vector_space.h:171
TPoint Point
Definition: region.h:57
static constexpr int kDim
Definition: region.h:64
Region< TScalar > const Region< TScalar > const & segment_z
Definition: region.h:156
auto contains(TPoint const &point) const noexcept -> bool
Returns true if the region contains the given point.
Definition: region.h:219
auto isProper() const noexcept -> bool
Returns true if region is neither empty nor degenerated. Hence it contains a range of values.
Definition: region.h:349
auto trySetElem(TPoint &p, TPoint s, size_t row, size_t col=0) -> Expected< Success >
Definition: vector_space.h:212
auto cast() const noexcept -> Region< TOtherPoint >
Definition: region.h:283
auto operator==(Region< TT > const &lhs, Region< TT > const &rhs) -> bool
Definition: region.h:367
static constexpr int kCols
Definition: region.h:61
auto range() const noexcept -> TPoint
Returns the range of the region.
Definition: region.h:229
typename PointTraits< TPoint >::Scalar Scalar
Definition: region.h:58
auto encloseCast() const noexcept -> Region< TOtherPoint >
Returns the smallest integer region which contains this.
Definition: region.h:311
auto floor(TPoint s)
Definition: vector_space.h:129
static auto uninitialized() noexcept -> Region< TPoint >
Creates an uninitialized region.
Definition: region.h:67
auto tryGetElem(TPoint const &p, size_t row, size_t col=0) -> Expected< TPoint >
Definition: vector_space.h:193
Definition: point_traits.h:20
auto clamp(TPoint const &point) const noexcept -> TPoint
Returns the clamped version of the given point.
Definition: region.h:214
auto max(TPoint const &a, TPoint const &b) -> TPoint
Definition: vector_space.h:114
void setElem(size_t row, Region< Scalar > const &s)
Precondition: !this->isEmptpy()
Definition: region.h:174
auto eval(TPoint const &p)
Definition: vector_space.h:44
auto isEmpty() const noexcept -> bool
Returns true if region is empty.
Definition: region.h:337
auto mid() const noexcept -> TPoint
Returns the mid point.
Definition: region.h:247
Region< TScalar > const & segment_y
Definition: region.h:143
A region is a closed interval [a, b] with a being the lower bound (=min) and b being the upper bound ...
Definition: region.h:19
auto isDegenerated() const noexcept -> bool
Returns true if region contains a single floating point number.
Definition: region.h:343
auto getElem(size_t row) const -> Region< Scalar > const &
Precondition: !this->isEmptpy()
Definition: region.h:167