UFO 1.0.0
An Efficient Probabilistic 3D Mapping Framework That Embraces the Unknown
Loading...
Searching...
No Matches
ufo::Transform< Dim, T > Struct Template Reference

Rigid-body transform: a rotation matrix plus a translation vector. More...

#include <lib/numeric/include/ufo/numeric/transform.hpp>

Public Types

using size_type = std::size_t
 
using value_type = T
 

Public Member Functions

constexpr Transform () noexcept=default
 Default constructor; initializes to the identity transform (zero translation and identity rotation).
 
template<std::floating_point U>
constexpr Transform (Mat< Dim+1, Dim+1, U > const &m)
 Constructs from a (Dim+1) × (Dim+1) homogeneous matrix.
 
constexpr Transform (Mat< Dim, Dim, T > const &rotation)
 Constructs a pure-rotation transform (zero translation).
 
constexpr Transform (Mat< Dim, Dim, T > const &rotation, Vec< Dim, T > const &translation)
 Constructs from a rotation matrix and a translation vector (same scalar type).
 
template<std::floating_point T1, std::floating_point T2>
constexpr Transform (Mat< Dim, Dim, T1 > const &rotation, Vec< Dim, T2 > const &translation)
 Constructs from rotation and translation with potentially different scalar types.
 
template<std::floating_point U>
constexpr Transform (Mat< Dim, Dim, U > const &rotation)
 Constructs a pure-rotation transform from a rotation matrix of a different type.
 
template<std::floating_point T1, std::floating_point T2>
requires (Dim == 3)
constexpr Transform (Quat< T1 > const &rotation, Vec< 3, T2 > const &translation)
 (3D only) Constructs from a quaternion and a translation vector.
 
template<std::floating_point U>
requires (Dim == 3)
constexpr Transform (Quat< U > const &rotation)
 (3D only) Constructs a pure-rotation transform from a quaternion.
 
template<std::floating_point T1, std::floating_point T2>
requires (Dim == 2)
constexpr Transform (T1 const &angle, Vec< 2, T2 > const &translation)
 (2D only) Constructs from a rotation angle and a translation vector.
 
constexpr Transform (Transform const &) noexcept=default
 Copy constructor.
 
template<std::floating_point U>
constexpr Transform (Transform< Dim, U > const &other) noexcept
 Converting constructor from a Transform<Dim, U> with a different scalar type.
 
template<std::floating_point U>
requires (Dim == 2)
constexpr Transform (U const &angle)
 (2D only) Constructs a pure-rotation transform from an angle.
 
template<std::floating_point U>
constexpr operator Mat< Dim+1, Dim+1, U > () const
 Converts to a (Dim+1) × (Dim+1) row-major homogeneous matrix.
 
template<std::floating_point U>
constexpr operator Mat< Dim, Dim, U > () const
 Extracts the rotation component as a Dim × Dim matrix.
 
template<std::floating_point U>
requires (Dim == 3)
constexpr operator Quat< U > () const
 (3D only) Converts the rotation component to a quaternion.
 
template<std::floating_point U>
requires (Dim == 3)
constexpr Quat< U > operator() (Quat< U > const &q) const
 (3D only) Applies the rotation component to a quaternion.
 
template<std::floating_point U>
constexpr Vec< Dim, U > operator() (Vec< Dim, U > const &v) const
 Applies the transform to a vector: result = R * v + t.
 
constexpr Transformoperator*= (Transform const &t)
 Composes this transform with t in place: *this = *this * t.
 
constexpr Transformoperator= (Transform const &) noexcept=default
 Default copy assignment operator.
 
template<std::floating_point U>
constexpr Transformoperator= (Transform< Dim, U > const &rhs) noexcept
 Converting assignment from a Transform<Dim, U> with a different scalar type.
 
constexpr bool operator== (Transform const &other) const noexcept=default
 Equality comparison; two transforms are equal if their rotation and translation components are equal.
 
constexpr T theta () const
 (2D only) Returns the rotation angle θ in [-π, π].
 

Public Attributes

Mat< Dim, Dim, T > rotation = Mat<Dim, Dim, T>::identity()
 Rotation component of the transform, represented as a Dim × Dim matrix.
 
Vec< Dim, T > translation {}
 Translation component of the transform.
 

Detailed Description

template<std::size_t Dim, std::floating_point T = float>
requires (Dim == 2 || Dim == 3)
struct ufo::Transform< Dim, T >

Rigid-body transform: a rotation matrix plus a translation vector.

Template Parameters
DimSpatial dimension; must be 2 or 3.
TFloating-point scalar type (default: float).

Applying the transform to a vector v computes R * v + t where R is the rotation matrix and t is the translation. Composition (*) follows the convention (t1 * t2)(v) = t1(t2(v)).

Definition at line 81 of file transform.hpp.

Member Typedef Documentation

◆ size_type

template<std::size_t Dim, std::floating_point T = float>
using ufo::Transform< Dim, T >::size_type = std::size_t

Definition at line 83 of file transform.hpp.

◆ value_type

template<std::size_t Dim, std::floating_point T = float>
using ufo::Transform< Dim, T >::value_type = T

Definition at line 82 of file transform.hpp.

Constructor & Destructor Documentation

◆ Transform() [1/10]

template<std::size_t Dim, std::floating_point T = float>
constexpr ufo::Transform< Dim, T >::Transform ( Mat< Dim, Dim, T > const &  rotation,
Vec< Dim, T > const &  translation 
)
inlineconstexpr

Constructs from a rotation matrix and a translation vector (same scalar type).

Parameters
[in]rotationRotation component.
[in]translationTranslation component.

Definition at line 116 of file transform.hpp.

◆ Transform() [2/10]

template<std::size_t Dim, std::floating_point T = float>
constexpr ufo::Transform< Dim, T >::Transform ( Mat< Dim, Dim, T > const &  rotation)
inlineexplicitconstexpr

Constructs a pure-rotation transform (zero translation).

Parameters
[in]rotationRotation matrix.

Definition at line 125 of file transform.hpp.

◆ Transform() [3/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point T1, std::floating_point T2>
constexpr ufo::Transform< Dim, T >::Transform ( Mat< Dim, Dim, T1 > const &  rotation,
Vec< Dim, T2 > const &  translation 
)
inlineconstexpr

Constructs from rotation and translation with potentially different scalar types.

Template Parameters
T1Scalar type of the rotation matrix.
T2Scalar type of the translation vector.
Parameters
[in]rotationRotation component (converted to T).
[in]translationTranslation component (converted to T).

Definition at line 136 of file transform.hpp.

◆ Transform() [4/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
constexpr ufo::Transform< Dim, T >::Transform ( Mat< Dim, Dim, U > const &  rotation)
inlineexplicitconstexpr

Constructs a pure-rotation transform from a rotation matrix of a different type.

Template Parameters
USource scalar type.
Parameters
[in]rotationRotation matrix (converted to T).

Definition at line 148 of file transform.hpp.

◆ Transform() [5/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point T1, std::floating_point T2>
requires (Dim == 2)
constexpr ufo::Transform< Dim, T >::Transform ( T1 const &  angle,
Vec< 2, T2 > const &  translation 
)
inlineconstexpr

(2D only) Constructs from a rotation angle and a translation vector.

Template Parameters
T1Scalar type of the angle.
T2Scalar type of the translation vector.
Parameters
[in]angleRotation angle in radians.
[in]translationTranslation vector.

Definition at line 161 of file transform.hpp.

◆ Transform() [6/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
requires (Dim == 2)
constexpr ufo::Transform< Dim, T >::Transform ( U const &  angle)
inlineexplicitconstexpr

(2D only) Constructs a pure-rotation transform from an angle.

Template Parameters
UScalar type of the angle.
Parameters
[in]angleRotation angle in radians.

Definition at line 176 of file transform.hpp.

◆ Transform() [7/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point T1, std::floating_point T2>
requires (Dim == 3)
constexpr ufo::Transform< Dim, T >::Transform ( Quat< T1 > const &  rotation,
Vec< 3, T2 > const &  translation 
)
inlineconstexpr

(3D only) Constructs from a quaternion and a translation vector.

Template Parameters
T1Scalar type of the quaternion.
T2Scalar type of the translation vector.
Parameters
[in]rotationUnit quaternion specifying the rotation.
[in]translationTranslation vector.

Definition at line 192 of file transform.hpp.

◆ Transform() [8/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
requires (Dim == 3)
constexpr ufo::Transform< Dim, T >::Transform ( Quat< U > const &  rotation)
inlineexplicitconstexpr

(3D only) Constructs a pure-rotation transform from a quaternion.

Template Parameters
UScalar type of the quaternion.
Parameters
[in]rotationUnit quaternion specifying the rotation.

Definition at line 204 of file transform.hpp.

◆ Transform() [9/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
constexpr ufo::Transform< Dim, T >::Transform ( Mat< Dim+1, Dim+1, U > const &  m)
inlineexplicitconstexpr

Constructs from a (Dim+1) × (Dim+1) homogeneous matrix.

Extracts the upper-left Dim × Dim block as the rotation and column Dim rows 0..Dim-1 as the translation.

Template Parameters
UScalar type of the source matrix.
Parameters
[in]mRow-major homogeneous transformation matrix.

Definition at line 217 of file transform.hpp.

◆ Transform() [10/10]

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
constexpr ufo::Transform< Dim, T >::Transform ( Transform< Dim, U > const &  other)
inlineexplicitconstexprnoexcept

Converting constructor from a Transform<Dim, U> with a different scalar type.

Template Parameters
USource scalar type.
Parameters
[in]otherSource transform; components are converted to T.

Definition at line 232 of file transform.hpp.

Member Function Documentation

◆ operator Mat< Dim+1, Dim+1, U >()

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
constexpr ufo::Transform< Dim, T >::operator Mat< Dim+1, Dim+1, U > ( ) const
inlineexplicitconstexpr

Converts to a (Dim+1) × (Dim+1) row-major homogeneous matrix.

The upper-left Dim × Dim block holds the rotation, column Dim rows 0..Dim-1 hold the translation, and m[Dim][Dim] = 1.

Template Parameters
UTarget scalar type.
Returns
Homogeneous transformation matrix.

Definition at line 288 of file transform.hpp.

◆ operator Quat< U >()

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
requires (Dim == 3)
constexpr ufo::Transform< Dim, T >::operator Quat< U > ( ) const
inlineexplicitconstexpr

(3D only) Converts the rotation component to a quaternion.

Template Parameters
UTarget scalar type.
Returns
Quat<U> representing the rotation matrix.

Definition at line 305 of file transform.hpp.

◆ operator()()

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
requires (Dim == 3)
constexpr Quat< U > ufo::Transform< Dim, T >::operator() ( Quat< U > const &  q) const
inlineconstexpr

(3D only) Applies the rotation component to a quaternion.

Computes Quat<U>(*this) * q, i.e., pre-multiplies q by the rotation.

Template Parameters
UScalar type of the quaternion.
Parameters
[in]qInput quaternion.
Returns
Rotated quaternion.

Definition at line 337 of file transform.hpp.

◆ operator*=()

template<std::size_t Dim, std::floating_point T = float>
constexpr Transform & ufo::Transform< Dim, T >::operator*= ( Transform< Dim, T > const &  t)
inlineconstexpr

Composes this transform with t in place: *this = *this * t.

Parameters
[in]tRight-hand transform to append.
Returns
Reference to *this.

Definition at line 357 of file transform.hpp.

◆ operator=()

template<std::size_t Dim, std::floating_point T = float>
template<std::floating_point U>
constexpr Transform & ufo::Transform< Dim, T >::operator= ( Transform< Dim, U > const &  rhs)
inlineconstexprnoexcept

Converting assignment from a Transform<Dim, U> with a different scalar type.

Template Parameters
USource scalar type.
Parameters
[in]rhsSource transform.
Returns
Reference to *this.

Definition at line 256 of file transform.hpp.

◆ operator==()

template<std::size_t Dim, std::floating_point T = float>
constexpr bool ufo::Transform< Dim, T >::operator== ( Transform< Dim, T > const &  other) const
constexprdefaultnoexcept

Equality comparison; two transforms are equal if their rotation and translation components are equal.

Parameters
[in]otherTransform to compare with.
Returns
true if the transforms are equal; false otherwise.

◆ theta()

template<std::size_t Dim, std::floating_point T = float>
constexpr T ufo::Transform< Dim, T >::theta ( ) const
inlineconstexpr

(2D only) Returns the rotation angle θ in [-π, π].

Returns
atan2(rotation[0][1], rotation[0][0]).

Definition at line 346 of file transform.hpp.

Member Data Documentation

◆ rotation

template<std::size_t Dim, std::floating_point T = float>
Mat<Dim, Dim, T> ufo::Transform< Dim, T >::rotation = Mat<Dim, Dim, T>::identity()

Rotation component of the transform, represented as a Dim × Dim matrix.

Definition at line 88 of file transform.hpp.

◆ translation

template<std::size_t Dim, std::floating_point T = float>
Vec<Dim, T> ufo::Transform< Dim, T >::translation {}

Translation component of the transform.

Definition at line 92 of file transform.hpp.


The documentation for this struct was generated from the following file: