Go to the documentation of this file.
21 #ifndef GEOMETRY__INTERVAL_HPP_
22 #define GEOMETRY__INTERVAL_HPP_
31 #include <type_traits>
55 std::is_floating_point<T>::value,
56 "Intervals only support floating point types.");
73 const auto bounds_equal = (min_eq && max_eq);
75 return both_empty || bounds_equal;
98 constexpr
auto PRECISION = 5;
101 const auto readable_extremum = [](
const T & val) {
102 if (val == std::numeric_limits<T>::lowest()) {
103 return std::string(
"REAL_MIN");
105 if (val == std::numeric_limits<T>::max()) {
106 return std::string(
"REAL_MAX");
109 std::stringstream ss;
110 ss.setf(std::ios::fixed, std::ios::floatfield);
111 ss.precision(PRECISION);
120 return os <<
"{\"min\": " << readable_extremum(
Interval::min(i)) <<
209 static constexpr
T NaN = std::numeric_limits<T>::quiet_NaN();
220 static bool bounds_valid(
const Interval & i);
243 : min_(min), max_(max)
245 if (!Interval::bounds_valid(*
this)) {
246 std::stringstream ss;
247 ss <<
"Attempted to construct an invalid interval: " << *
this;
248 throw std::runtime_error(ss.str());
258 namespace comp = helper_functions::comparisons;
265 const auto both_non_empty_equal = both_non_empty && mins_equal && maxs_equal;
267 return both_empty || both_non_empty_equal;
305 return lower_contained && upper_contained;
362 #endif // GEOMETRY__INTERVAL_HPP_
Interval< autoware::common::types::float64_t > Interval_d
Definition: interval.hpp:225
friend std::ostream & operator<<(std::ostream &os, const Interval &i)
Stream overload for Interval types.
Definition: interval.hpp:96
static bool empty(const Interval &i)
Whether the interval is empty or not.
Definition: interval.hpp:282
T
Definition: catr_diff.py:22
This file includes common type definition.
Interval< autoware::common::types::float32_t > Interval_f
Definition: interval.hpp:226
static Interval intersect(const Interval &i1, const Interval &i2)
Compute the intersection of two intervals as a new interval.
Definition: interval.hpp:327
static T clamp_to(const Interval &i, T val)
Clamp a scalar 'val' onto 'interval'.
Definition: interval.hpp:345
static bool contains(const Interval &i, const T &value)
Test for whether a given interval contains a given value.
Definition: interval.hpp:311
static bool zero_measure(const Interval &i)
Utility for checking whether an interval has zero measure.
Definition: interval.hpp:273
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
static T min(const Interval &i)
The minimum bound of the interval.
Definition: interval.hpp:134
friend bool operator==(const Interval &i1, const Interval &i2)
Compute equality.
Definition: interval.hpp:69
Definition: bool_comparisons.hpp:32
Interval()
Constructor: initialize an empty interval with members set to NaN.
Definition: interval.hpp:236
bool abs_eq(const T &a, const T &b, const T &eps)
Check for approximate equality in absolute terms.
Definition: float_comparisons.hpp:43
static T max(const Interval &i)
The maximum bound of the interval.
Definition: interval.hpp:137
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.
Definition: interval.hpp:255
friend bool operator!=(const Interval &i1, const Interval &i2)
Compute inequality and the logical negation of equality.
Definition: interval.hpp:82
static bool is_subset_eq(const Interval &i1, const Interval &i2)
Test for whether 'i1' subseteq 'i2'.
Definition: interval.hpp:301
Data structure to contain scalar interval bounds.
Definition: interval.hpp:52
static T measure(const Interval &i)
Return the measure (length) of the interval.
Definition: interval.hpp:319