UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
normal.hpp
1
41#ifndef UFO_CORE_NORMAL_HPP
42#define UFO_CORE_NORMAL_HPP
43
44// UFO
45#include <ufo/numeric/vec.hpp>
46
47// STL
48#include <concepts>
49#include <cstddef>
50#include <format>
51#include <ostream>
52
53namespace ufo
54{
78template <std::size_t Dim = 3, std::floating_point T = float>
79struct Normal : Vec<Dim, T> {
83 constexpr Normal() noexcept = default;
84
90 constexpr Normal(Vec<Dim, T> const& normal) noexcept : Vec<Dim, T>(normal) {}
91
97 template <std::convertible_to<T>... Args>
98 requires(sizeof...(Args) == Dim)
99 constexpr Normal(Args... args) noexcept : Vec<Dim, T>{static_cast<T>(args)...}
100 {
101 }
102};
103
133
142} // namespace ufo
143
144template <std::size_t Dim, std::formattable<char> T>
145struct std::formatter<ufo::Normal<Dim, T>> : std::formatter<ufo::Vec<Dim, T>> {
146 auto format(ufo::Normal<Dim, T> const& n, std::format_context& ctx) const
147 {
148 // Explicitly qualify to avoid unqualified lookup resolving back to this
149 // overload via the Normal(Vec const&) converting constructor.
150 return std::formatter<ufo::Vec<Dim, T>>::format(n, ctx);
151 }
152};
153
154namespace ufo
155{
164template <std::size_t Dim, class T>
165std::ostream& operator<<(std::ostream& out, Normal<Dim, T> const& n)
166{
167 return out << std::format("{}", n);
168}
169} // namespace ufo
170
171#endif // UFO_CORE_NORMAL_HPP
All vision-related classes and functions.
Definition cloud.hpp:49
Represents an N-dimensional unit surface normal vector as a fixed-size array.
Definition normal.hpp:79
constexpr Normal(Args... args) noexcept
Constructs from exactly Dim scalar components.
Definition normal.hpp:99
constexpr Normal() noexcept=default
Default-constructs with indeterminate component values.
A fixed-size arithmetic vector of up to 4 dimensions.
Definition vec.hpp:76