wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
PassiveProperRigidTransformationTemplate.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/intermediate_coordinate_system.hpp"
11#include "wuzp/trafo/internal/rigid.hpp"
12#include "wuzp/trafo/traits.hpp"
13
14namespace wuzp {
15
16template <EuclideanCoordinateSystem FromT_, EuclideanCoordinateSystem ToT_, AnyRotation RotationT_, typename TranslationT_>
18
19namespace internal {
20
24template <typename RotationT_, typename TranslationT_, typename NewFromT_, typename NewToT_>
25using PassiveRigidOf =
26 PassiveProperRigidTransformationTemplate<NewFromT_, NewToT_,
27 typename WithFrames<RotationT_, NewFromT_, Intermediate<NewFromT_, NewToT_>>::type,
28 typename WithFrames<TranslationT_, Intermediate<NewFromT_, NewToT_>, NewToT_>::type>;
29
32template <typename RigidT_, typename NewFromT_, typename NewToT_>
33using PassiveRigidWithFrames = PassiveRigidOf<typename RigidT_::Rotation, typename RigidT_::Translation, NewFromT_, NewToT_>;
34
35} // namespace internal
36
53template <EuclideanCoordinateSystem FromT_, EuclideanCoordinateSystem ToT_, AnyRotation RotationT_, typename TranslationT_>
55 : public PassiveTransformation<PassiveProperRigidTransformationTemplate<FromT_, ToT_, RotationT_, TranslationT_>, FromT_, ToT_> {
56 public:
57 using Rotation = RotationT_;
58 using Translation = TranslationT_;
59 using ValueT = typename Rotation::ValueT;
60
63 : rotation_{std::move(rotation)}, translation_{std::move(translation)} {}
64
65 void setRotation(const Rotation& rotation) { rotation_ = rotation; }
66 const Rotation& getRotation() const { return rotation_; }
67
68 void setTranslation(const Translation& translation) { translation_ = translation; }
69 const Translation& getTranslation() const { return translation_; }
70
76 auto inverse() const {
77 return internal::invertRigid<internal::PassiveRigidWithFrames<PassiveProperRigidTransformationTemplate, ToT_, FromT_>>(*this);
78 }
79
82 template <typename FromOtherT_, typename ToOtherT_, typename RotationOtherT_, typename TranslationOtherT_>
84 const ValueT precision = Precision<ValueT>::value()) const {
85 static_assert(internal::SameFrames<PassiveProperRigidTransformationTemplate, std::remove_cvref_t<decltype(other)>>::value);
86 return rotation_.isApprox(other.getRotation(), precision) && translation_.isApprox(other.getTranslation(), precision);
87 }
88
89 private:
90 Rotation rotation_;
91 Translation translation_;
92};
93
94template <typename FromT_, typename ToT_, typename RotationT_, typename TranslationT_, typename Object>
95struct TransformationTraits<PassiveProperRigidTransformationTemplate<FromT_, ToT_, RotationT_, TranslationT_>, Object> {
97 const Object& object) {
98 return transformation.getTranslation().transform(transformation.getRotation().transform(object));
99 }
100};
101
102// The compositions X_AB * X_BC = X_AC of proper rigid transformations with each other and with translations are proper rigid
103// transformations with a rotation and a translation of the kinds of those of the proper rigid operand (see internal/rigid.hpp).
104
105template <typename FromLhsT_, typename ToLhsT_, typename RotationLhsT_, typename TranslationLhsT_, typename FromRhsT_, typename ToRhsT_,
106 typename RotationRhsT_, typename TranslationRhsT_>
107struct CompositionTraits<PassiveProperRigidTransformationTemplate<FromLhsT_, ToLhsT_, RotationLhsT_, TranslationLhsT_>,
108 PassiveProperRigidTransformationTemplate<FromRhsT_, ToRhsT_, RotationRhsT_, TranslationRhsT_>> {
110 static auto compose(const LhsT& lhs,
112 return internal::composeRigid<internal::PassiveRigidWithFrames<LhsT, FromRhsT_, ToLhsT_>>(lhs, rhs);
113 }
114};
115
116template <typename FromLhsT_, typename ToLhsT_, typename RotationLhsT_, typename TranslationLhsT_,
117 template <typename, int, int> typename ValuesRhsT_, int DimensionRhsV_, typename ValueRhsT_, typename FromRhsT_, typename ToRhsT_,
118 typename... UnitsRhsT_>
119struct CompositionTraits<PassiveProperRigidTransformationTemplate<FromLhsT_, ToLhsT_, RotationLhsT_, TranslationLhsT_>,
120 PassiveTranslation<ValuesRhsT_, DimensionRhsV_, ValueRhsT_, FromRhsT_, ToRhsT_, UnitsRhsT_...>> {
122 static auto compose(const LhsT& lhs,
124 return internal::composeRigidAndTranslation<internal::PassiveRigidWithFrames<LhsT, FromRhsT_, ToLhsT_>>(lhs, rhs);
125 }
126};
127
128template <template <typename, int, int> typename ValuesLhsT_, int DimensionLhsV_, typename ValueLhsT_, typename FromLhsT_, typename ToLhsT_,
129 typename... UnitsLhsT_, typename FromRhsT_, typename ToRhsT_, typename RotationRhsT_, typename TranslationRhsT_>
130struct CompositionTraits<PassiveTranslation<ValuesLhsT_, DimensionLhsV_, ValueLhsT_, FromLhsT_, ToLhsT_, UnitsLhsT_...>,
131 PassiveProperRigidTransformationTemplate<FromRhsT_, ToRhsT_, RotationRhsT_, TranslationRhsT_>> {
134 const RhsT& rhs) {
135 return internal::composeTranslationAndRigid<internal::PassiveRigidWithFrames<RhsT, FromRhsT_, ToLhsT_>>(lhs, rhs);
136 }
137};
138
139} // namespace wuzp
A passive proper rigid transformation from From to To, which first rotates, then translates: p -> R p...
bool isApprox(const PassiveProperRigidTransformationTemplate< FromOtherT_, ToOtherT_, RotationOtherT_, TranslationOtherT_ > &other, const ValueT precision=Precision< ValueT >::value()) const
Whether both transformations, which must transform between the same coordinate systems,...
PassiveProperRigidTransformationTemplate(Rotation rotation, Translation translation)
auto inverse() const
The inverse transformation, from To to From, (R^T, -R^T t), which only needs the transpose of the rot...
A passive transformation, which expresses the objects of the coordinate system From in the coordinate...
A passive translation from the coordinate system From to the coordinate system To,...
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 PassiveProperRigidTransformationTemplate< FromT_, ToT_, RotationT_, TranslationT_ > &transformation, const Object &object)
How a transformation transforms an object: static auto transform(const TransformationT_&,...
Definition traits.hpp:19