UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
reflection.hpp
1
42#ifndef UFO_MAP_REFLECTION_HPP
43#define UFO_MAP_REFLECTION_HPP
44
45// UFO
46#include <ufo/map/types.hpp>
47
48// STL
49#include <algorithm>
50#include <ostream>
51
52namespace ufo
53{
54struct Reflection {
55 count_t hits{};
56 count_t misses{};
57
58 constexpr Reflection() = default;
59
60 constexpr Reflection(count_t hits, count_t misses) : hits(hits), misses(misses) {}
61
62 friend void swap(Reflection& lhs, Reflection& rhs) noexcept
63 {
64 std::swap(lhs.hits, rhs.hits);
65 std::swap(lhs.misses, rhs.misses);
66 }
67
68 friend bool operator==(Reflection lhs, Reflection rhs)
69 {
70 return lhs.hits == rhs.hits && lhs.misses == rhs.misses;
71 }
72
73 friend bool operator!=(Reflection lhs, Reflection rhs) { return !(lhs == rhs); }
74
75 [[nodiscard]] constexpr reflection_t reflectiveness() const
76 {
77 return hits / static_cast<double>(hits + misses);
78 }
79
80 constexpr void reset()
81 {
82 hits = 0;
83 misses = 0;
84 }
85};
86} // namespace ufo
87
88namespace std
89{
90inline ostream& operator<<(ostream& out, ufo::Reflection reflection)
91{
92 return out << "Hits: " << +reflection.hits << " Misses: " << +reflection.misses;
93}
94} // namespace std
95
96#endif // UFO_MAP_REFLECTION_HPP
STL namespace.
All vision-related classes and functions.
Definition cloud.hpp:49