wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Toggle main menu visibility
Loading...
Searching...
No Matches
PassiveTransformation.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <type_traits>
4
#include <utility>
5
6
#include "
wuzp/core/concepts.hpp
"
7
#include "
wuzp/core/helpers.hpp
"
8
#include "
wuzp/core/traits.hpp
"
9
#include "
wuzp/trafo/ActiveTransformation.hpp
"
10
#include "
wuzp/trafo/Transformation.hpp
"
11
#include "
wuzp/trafo/traits.hpp
"
12
13
namespace
wuzp
{
14
22
template
<
typename
DerivedT_, AnyCoordinateSystem FromT_, AnyCoordinateSystem ToT_>
23
class
PassiveTransformation
:
public
internal::Crtp<DerivedT_, Transformation<DerivedT_>> {
24
public
:
25
using
From
= FromT_;
26
using
To
= ToT_;
27
30
template
<
typename
ObjectT_>
31
auto
transform
(ObjectT_&&
object
)
const
{
32
using
ObjectT = std::remove_cvref_t<ObjectT_>;
33
// Checked before the coordinate system: passive transformations have none, which would fail with a message about a trait.
34
static_assert
(!
AnyTransformation<ObjectT>
,
35
"A passive transformation transforms tensors, not transformations. Compose transformations with operator*."
);
36
static_assert
(std::is_same<typename GetCoordinateSystem<ObjectT>::type,
From
>::value,
"Coordinate systems do not match."
);
37
return
TransformationTraits<DerivedT_, ObjectT>::transform
(this->derived(), std::forward<ObjectT_>(
object
));
38
}
39
};
40
48
template
<
typename
LhsT_,
typename
FromLhsT_,
typename
ToLhsT_,
typename
RhsT_,
typename
FromRhsT_,
typename
ToRhsT_>
49
auto
operator*
(
const
PassiveTransformation<LhsT_, FromLhsT_, ToLhsT_>
& lhs,
const
PassiveTransformation<RhsT_, FromRhsT_, ToRhsT_>
& rhs) {
50
static_assert
(std::is_same_v<FromLhsT_, ToRhsT_>,
"Adjacent frames do not match."
);
51
return
CompositionTraits<LhsT_, RhsT_>::compose
(
static_cast<
const
LhsT_&
>
(lhs),
static_cast<
const
RhsT_&
>
(rhs));
52
}
53
54
// An active and a passive transformation cannot be composed: CompositionTraits rejects them with a message.
55
template
<
typename
LhsT_,
typename
RhsT_,
typename
FromRhsT_,
typename
ToRhsT_>
56
auto
operator*
(
const
ActiveTransformation<LhsT_>
& lhs,
const
PassiveTransformation<RhsT_, FromRhsT_, ToRhsT_>
& rhs) {
57
return
CompositionTraits<LhsT_, RhsT_>::compose
(
static_cast<
const
LhsT_&
>
(lhs),
static_cast<
const
RhsT_&
>
(rhs));
58
}
59
template
<
typename
LhsT_,
typename
FromLhsT_,
typename
ToLhsT_,
typename
RhsT_>
60
auto
operator*
(
const
PassiveTransformation<LhsT_, FromLhsT_, ToLhsT_>
& lhs,
const
ActiveTransformation<RhsT_>
& rhs) {
61
return
CompositionTraits<LhsT_, RhsT_>::compose
(
static_cast<
const
LhsT_&
>
(lhs),
static_cast<
const
RhsT_&
>
(rhs));
62
}
63
64
namespace
internal {
65
69
template
<
typename
LhsT_,
typename
RhsT_>
70
struct
SameFrames {
71
static_assert
(std::is_same_v<typename LhsT_::From, typename RhsT_::From>,
"'From' coordinate systems do not match."
);
72
static_assert
(std::is_same_v<typename LhsT_::To, typename RhsT_::To>,
"'To' coordinate systems do not match."
);
73
static
constexpr
bool
value =
true
;
74
};
75
78
template
<
typename
PassiveT_,
typename
NewFromT_,
typename
NewToT_>
79
struct
WithFrames;
80
81
}
// namespace internal
82
83
}
// namespace wuzp
ActiveTransformation.hpp
Transformation.hpp
wuzp::ActiveTransformation
An active transformation, which moves objects within its coordinate system (see Transformation).
Definition
ActiveTransformation.hpp:15
wuzp::PassiveTransformation
A passive transformation, which expresses the objects of the coordinate system From in the coordinate...
Definition
PassiveTransformation.hpp:23
wuzp::PassiveTransformation::From
FromT_ From
Definition
PassiveTransformation.hpp:25
wuzp::PassiveTransformation::transform
auto transform(ObjectT_ &&object) const
The object in To.
Definition
PassiveTransformation.hpp:31
wuzp::PassiveTransformation::To
ToT_ To
Definition
PassiveTransformation.hpp:26
concepts.hpp
wuzp::AnyTransformation
A transformation of wuzp, i.e. a type that derives from Transformation, also through a class that der...
Definition
Transformation.hpp:42
traits.hpp
helpers.hpp
wuzp
Definition
Absolute.hpp:15
wuzp::operator*
auto operator*(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const ValueRhsT_ rhs)
Definition
Quantities.hpp:503
wuzp::CompositionTraits
The composition lhs * rhs of two transformations, which applies rhs first, then lhs: (lhs * rhs)....
Definition
traits.hpp:39
wuzp::TransformationTraits
How a transformation transforms an object: static auto transform(const TransformationT_&,...
Definition
traits.hpp:19
traits.hpp
wuzp
include
wuzp
trafo
PassiveTransformation.hpp
Generated by
1.18.0