41#ifndef UFO_NUMERIC_TRANSFORM_HPP
42#define UFO_NUMERIC_TRANSFORM_HPP
45#include <ufo/numeric/mat.hpp>
46#include <ufo/numeric/quat.hpp>
47#include <ufo/numeric/vec.hpp>
79template <std::
size_t Dim, std::
floating_po
int T =
float>
80 requires(Dim == 2 || Dim == 3)
83 using size_type = std::size_t;
117 : rotation(rotation), translation(translation)
135 template <std::
floating_po
int T1, std::
floating_po
int T2>
137 : rotation(rotation), translation(translation)
147 template <std::
floating_po
int U>
159 template <std::
floating_po
int T1, std::
floating_po
int T2>
162 : translation(translation)
164 auto const s = std::sin(
angle);
165 auto const c = std::cos(
angle);
174 template <std::
floating_po
int U>
178 auto const s = std::sin(
angle);
179 auto const c = std::cos(
angle);
190 template <std::
floating_po
int T1, std::
floating_po
int T2>
202 template <std::
floating_po
int U>
216 template <std::
floating_po
int U>
220 for (std::size_t i = 0; i < Dim; ++i) {
221 translation[i] = m[i][Dim];
231 template <std::
floating_po
int U>
233 : rotation(other.rotation), translation(other.translation)
255 template <std::
floating_po
int U>
258 rotation = rhs.rotation;
259 translation = rhs.translation;
274 template <std::
floating_po
int U>
287 template <std::
floating_po
int U>
291 for (std::size_t i = 0; i < Dim; ++i) {
292 m[i][Dim] =
static_cast<U
>(translation[i]);
303 template <std::
floating_po
int U>
322 template <std::
floating_po
int U>
335 template <std::
floating_po
int U>
346 [[nodiscard]]
constexpr T
theta() const
349 return std::atan2(rotation[1][0], rotation[0][0]);
381template <std::
floating_po
int T =
float>
383template <std::
floating_po
int T =
float>
405template <std::
size_t Dim, std::
floating_po
int T>
421template <std::
size_t Dim, std::
floating_po
int T>
435template <std::
floating_po
int T>
450template <std::
size_t Dim, std::
floating_po
int T>
454 if constexpr (Dim == 2) {
455 out <<
"Theta: " << t.
theta();
457 out <<
"Rotation: " <<
Quat<T>(t);
477template <std::
size_t Dim, std::
floating_po
int T>
491template <std::
size_t Dim, std::
floating_po
int T>
492 requires(std::formattable<T, char>)
494 constexpr auto parse(std::format_parse_context& ctx) {
return ctx.begin(); }
498 if constexpr (Dim == 2) {
499 return std::format_to(ctx.out(),
"translation: {} Theta: {}", t.
translation,
502 return std::format_to(ctx.out(),
"translation: {} Rotation: {}", t.
translation,
constexpr Transform & operator=(Transform const &) noexcept=default
Default copy assignment operator.
constexpr Transform() noexcept=default
Default constructor; initializes to the identity transform (zero translation and identity rotation).
T angle(Quat< T > const &q) noexcept
Extracts the rotation angle (in radians) from a unit quaternion.
constexpr Vec< Dim, U > operator()(Vec< Dim, U > const &v) const
Applies the transform to a vector: result = R * v + t.
All vision-related classes and functions.
constexpr Mat< Rows, Cols, T > operator*(Mat< Rows, Cols, T > lhs, T rhs) noexcept
Multiplies every element of lhs by scalar rhs.
constexpr Mat< Cols, Rows, T > transpose(Mat< Rows, Cols, T > const &m) noexcept
Returns the transpose of a matrix.
constexpr M inverse(M const &m) noexcept
Computes the inverse of a square floating-point matrix.
A fixed-size matrix with Rows rows and Cols columns.
static consteval Mat identity() noexcept
Returns the identity matrix (square matrices only).
Unit quaternion representing an orientation or rotation in 3-D space.
A fixed-size arithmetic vector of up to 4 dimensions.