wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
ActiveProperRigidTransformationTemplate.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4#include <utility>
5
10#include "wuzp/trafo/internal/rigid.hpp"
11#include "wuzp/trafo/traits.hpp"
12
13namespace wuzp {
14
25template <EuclideanCoordinateSystem CoordinateSystemT_, AnyRotation RotationT_, typename TranslationT_>
27 : public ActiveTransformation<ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>> {
28 public:
29 using Rotation = RotationT_;
30 using Translation = TranslationT_;
31 using ValueT = typename Rotation::ValueT;
32
35 : rotation_{std::move(rotation)}, translation_{std::move(translation)} {}
36
37 void setRotation(const Rotation& rotation) { rotation_ = rotation; }
38 const Rotation& getRotation() const { return rotation_; }
39
40 void setTranslation(const Translation& translation) { translation_ = translation; }
41 const Translation& getTranslation() const { return translation_; }
42
44 ActiveProperRigidTransformationTemplate inverse() const { return internal::invertRigid<ActiveProperRigidTransformationTemplate>(*this); }
45
48 template <typename CoordinateSystemOtherT_, typename RotationOtherT_, typename TranslationOtherT_>
50 const ValueT precision = Precision<ValueT>::value()) const {
51 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>, "Coordinate systems do not match.");
52 return rotation_.isApprox(other.getRotation(), precision) && translation_.isApprox(other.getTranslation(), precision);
53 }
54
55 private:
56 Rotation rotation_;
57 Translation translation_;
58};
59
60template <typename CoordinateSystemT_, typename RotationT_, typename TranslationT_>
61struct GetCoordinateSystem<ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>> {
62 using type = CoordinateSystemT_;
63};
64
65template <typename CoordinateSystemT_, typename RotationT_, typename TranslationT_, typename Object>
66struct TransformationTraits<ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>, Object> {
68 const Object& object) {
69 return transformation.getTranslation().transform(transformation.getRotation().transform(object));
70 }
71};
72
73// The compositions of proper rigid transformations with each other and with translations are proper rigid transformations of the
74// type of the proper rigid operand (see internal/rigid.hpp).
75
76template <typename CoordinateSystemLhsT_, typename RotationLhsT_, typename TranslationLhsT_, typename CoordinateSystemRhsT_,
77 typename RotationRhsT_, typename TranslationRhsT_>
78struct CompositionTraits<ActiveProperRigidTransformationTemplate<CoordinateSystemLhsT_, RotationLhsT_, TranslationLhsT_>,
79 ActiveProperRigidTransformationTemplate<CoordinateSystemRhsT_, RotationRhsT_, TranslationRhsT_>> {
81 static ResultT compose(const ResultT& lhs,
83 return internal::composeRigid<ResultT>(lhs, rhs);
84 }
85};
86
87template <typename CoordinateSystemT_, typename RotationT_, typename TranslationT_, template <typename, int, int> typename ValuesRhsT_,
88 int DimensionRhsV_, typename ValueRhsT_, typename CoordinateSystemRhsT_, typename... UnitsRhsT_>
89struct CompositionTraits<ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>,
90 ActiveTranslation<ValuesRhsT_, DimensionRhsV_, ValueRhsT_, CoordinateSystemRhsT_, UnitsRhsT_...>> {
92 static ResultT compose(const ResultT& lhs,
94 return internal::composeRigidAndTranslation<ResultT>(lhs, rhs);
95 }
96};
97
98template <template <typename, int, int> typename ValuesLhsT_, int DimensionLhsV_, typename ValueLhsT_, typename CoordinateSystemLhsT_,
99 typename... UnitsLhsT_, typename CoordinateSystemT_, typename RotationT_, typename TranslationT_>
100struct CompositionTraits<ActiveTranslation<ValuesLhsT_, DimensionLhsV_, ValueLhsT_, CoordinateSystemLhsT_, UnitsLhsT_...>,
101 ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>> {
104 const ResultT& rhs) {
105 return internal::composeTranslationAndRigid<ResultT>(lhs, rhs);
106 }
107};
108
109} // namespace wuzp
An active proper rigid transformation, which first rotates, then translates: x -> R x + t,...
bool isApprox(const ActiveProperRigidTransformationTemplate< CoordinateSystemOtherT_, RotationOtherT_, TranslationOtherT_ > &other, const ValueT precision=Precision< ValueT >::value()) const
An active transformation, which moves objects within its coordinate system (see Transformation).
An active translation, which moves points by a vector t, p' = p + t, and leaves vectors,...
The composition lhs * rhs of two transformations, which applies rhs first, then lhs: (lhs * rhs)....
Definition traits.hpp:39
static constexpr ValueT_ value()
Definition traits.hpp:356
static auto transform(const ActiveProperRigidTransformationTemplate< CoordinateSystemT_, RotationT_, TranslationT_ > &transformation, const Object &object)
How a transformation transforms an object: static auto transform(const TransformationT_&,...
Definition traits.hpp:19