wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
ActiveSpatialRotation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ostream>
4#include <type_traits>
5#include <utility>
6
10#include "wuzp/core/helpers.hpp"
11#include "wuzp/core/traits.hpp"
16#include "wuzp/trafo/internal/rigid.hpp"
17#include "wuzp/trafo/internal/rotation.hpp"
18#include "wuzp/trafo/internal/rotation_parameterizations.hpp"
19#include "wuzp/trafo/internal/validity.hpp"
20#include "wuzp/trafo/traits.hpp"
21
22namespace wuzp {
23
43template <template <typename, int, int> typename ValuesT_, typename ValueT_, EuclideanCoordinateSystem CoordinateSystemT_, int DimensionV_>
45class ActiveSpatialRotation : public ActiveTransformation<ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>> {
46 using ParameterizationsT = internal::RotationParameterizationTypes<ValuesT_, ValueT_>;
47 using RequireParameterizableT = internal::RequireParameterizable<DimensionV_, ValueT_>;
48
49 public:
51 using LinearTransformationT = ActiveLinearTransformation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_, DimensionV_,
52 typename AccessUnits<AccessImplementation<ValueT_>>::Dimensionless>;
53 using ValueT = ValueT_;
57 using CoordinateSystemT = CoordinateSystemT_;
59
64 using QuaternionT = typename ParameterizationsT::QuaternionT;
66 using QuaternionDerivativeT = typename ParameterizationsT::QuaternionDerivativeT;
68 using AngleT = typename ParameterizationsT::AngleT;
70 using AxisT = typename ParameterizationsT::template AxisT<CoordinateSystemT_>;
72 using AngleAxisT = std::pair<AngleT, AxisT>;
75 using RotationVectorT = typename ParameterizationsT::template RotationVectorT<CoordinateSystemT_>;
78 using EulerAnglesT = typename ParameterizationsT::EulerAnglesT;
80 using EulerAnglesDerivativeT = typename ParameterizationsT::EulerAnglesDerivativeT;
82 using AngularVelocityT = typename ParameterizationsT::template AngularVelocityT<CoordinateSystemT_>;
84 using MatrixDerivativeT = typename ParameterizationsT::MatrixDerivativeT;
85
87 ActiveSpatialRotation() : quantities_{internal::identity<ValuesT>()} {}
88
92 template <typename... Args>
93 requires(sizeof...(Args) > 0 && !CopiesOrMoves<ActiveSpatialRotation, Args...>)
94 explicit ActiveSpatialRotation(Args&&... args) : quantities_{std::forward<Args>(args)...} {
95 internal::checkValidity(*this, "The matrix of a rotation must be orthogonal with determinant 1.");
96 }
97
100 template <typename... Args>
101 static ActiveSpatialRotation makeUnchecked(Args&&... args) {
102 return ActiveSpatialRotation{Unchecked{}, QuantitiesT{std::forward<Args>(args)...}};
103 }
104
109 template <typename... Args>
111 return makeUnchecked(internal::projectToRotation(QuantitiesT{std::forward<Args>(args)...}.getValues()));
112 }
113
115 const QuantitiesT& getQuantities() const { return quantities_; }
117 TensorT getTensor() const { return TensorT{quantities_}; }
118
120 ActiveSpatialRotation inverse() const { return makeUnchecked(quantities_.transpose()); }
121
124 bool isValid(const ValueT tolerance = ValidityTolerance<ValueT>::value()) const {
125 return internal::isRotation(quantities_.getValues(), tolerance);
126 }
127
130 template <template <typename, int, int> typename ValuesOtherT_, typename ValueOtherT_, typename CoordinateSystemOtherT_,
131 int DimensionOtherV_>
133 const ValueT precision = Precision<ValueT>::value()) const {
134 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>, "Coordinate systems do not match.");
135 return quantities_.isApprox(other.getQuantities(), precision);
136 }
137
138 // The parameterizations of three-dimensional rotations (see "Parameterizations of rotations" in DESIGN.md). The arguments are
139 // converted into the types of the parameterizations, so that e.g. Euler angles with another unit fail with "Units do not
140 // match.", and a rotation vector in another coordinate system with "Coordinate systems do not match.".
141
146 template <AnyQuantities QuaternionOtherT_>
147 static ActiveSpatialRotation fromQuaternion(const QuaternionOtherT_& quaternion) {
148 static_assert(RequireParameterizableT::value);
149 const auto elements = internal::checkedUnitQuaternion(internal::quaternionElements(QuaternionT{quaternion}),
150 "The quaternion of a rotation must have unit length.");
151 return makeUnchecked(internal::matrixFromQuaternion<ValuesT>(elements));
152 }
153
159 static_assert(RequireParameterizableT::value);
160 return internal::fromElements<QuaternionT>(internal::quaternionFromMatrix(quantities_.getValues()));
161 }
162
167 template <AnyQuantities AngleOtherT_, AnyTensor AxisOtherT_>
168 static ActiveSpatialRotation fromAngleAxis(const AngleOtherT_& angle, const AxisOtherT_& axis) {
169 static_assert(RequireParameterizableT::value);
170 const auto elements =
171 internal::checkedUnitQuaternion(internal::quaternionFromAngleAxis(AngleT{angle}.getValue(), internal::elements3(AxisT{axis})),
172 "The axis of a rotation must have unit length.");
173 return makeUnchecked(internal::matrixFromQuaternion<ValuesT>(elements));
174 }
175
179 static_assert(RequireParameterizableT::value);
180 const auto [angle, axis] = internal::angleAxisFromQuaternion(internal::quaternionFromMatrix(quantities_.getValues()));
181 return {AngleT{angle}, internal::fromElements<AxisT>(axis)};
182 }
183
186 template <AnyTensor RotationVectorOtherT_>
187 static ActiveSpatialRotation fromRotationVector(const RotationVectorOtherT_& rotationVector) {
188 static_assert(RequireParameterizableT::value);
189 return makeUnchecked(internal::matrixFromRotationVector<ValuesT>(internal::elements3(RotationVectorT{rotationVector})));
190 }
191
195 static_assert(RequireParameterizableT::value);
196 return internal::fromElements<RotationVectorT>(internal::rotationVectorFromMatrix(quantities_.getValues()));
197 }
198
202 template <AnyQuantities EulerAnglesOtherT_>
203 static ActiveSpatialRotation fromEulerAnglesZyx(const EulerAnglesOtherT_& angles) {
204 static_assert(RequireParameterizableT::value);
205 return makeUnchecked(internal::matrixFromEulerAngles<2, 1, 0, ValuesT>(internal::elements3(EulerAnglesT{angles})));
206 }
207
212 static_assert(RequireParameterizableT::value);
213 return internal::fromElements<EulerAnglesT>(internal::eulerAnglesZyxFromMatrix(quantities_.getValues()));
214 }
215
218 template <AnyQuantities EulerAnglesOtherT_>
219 static ActiveSpatialRotation fromEulerAnglesXyz(const EulerAnglesOtherT_& angles) {
220 static_assert(RequireParameterizableT::value);
221 return makeUnchecked(internal::matrixFromEulerAngles<0, 1, 2, ValuesT>(internal::elements3(EulerAnglesT{angles})));
222 }
223
227 static_assert(RequireParameterizableT::value);
228 return internal::fromElements<EulerAnglesT>(internal::eulerAnglesXyzFromMatrix(quantities_.getValues()));
229 }
230
239 template <AnyTensor FromVectorT_, AnyTensor ToVectorT_>
240 static ActiveSpatialRotation fromTwoVectors(const FromVectorT_& from, const ToVectorT_& to) {
241 static_assert(RequireParameterizableT::value);
242 return ActiveSpatialRotation{internal::matrixFromQuaternion<ValuesT>(
243 internal::quaternionFromTwoVectors(internal::directionElements<AxisT>(from), internal::directionElements<AxisT>(to)))};
244 }
245
246 // The rotations as a manifold, in the conventions of SolĂ , Deray and Atchuthan, "A micro Lie theory for state estimation in
247 // robotics" (https://arxiv.org/abs/1812.01537), with the perturbations on the left, expressed in the coordinate system, like
248 // kindr's boxPlus() and boxMinus().
249
252 template <AnyTensor RotationVectorOtherT_>
253 ActiveSpatialRotation boxPlus(const RotationVectorOtherT_& rotationVector) const {
254 static_assert(RequireParameterizableT::value);
255 return makeUnchecked(internal::boxPlus(quantities_.getValues(), internal::elements3(RotationVectorT{rotationVector})));
256 }
257
260 template <typename CoordinateSystemOtherT_>
262 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>, "Coordinate systems do not match.");
263 static_assert(RequireParameterizableT::value);
264 return internal::fromElements<RotationVectorT>(internal::boxMinus(quantities_.getValues(), other.getQuantities().getValues()));
265 }
266
269 template <typename CoordinateSystemOtherT_>
271 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>, "Coordinate systems do not match.");
272 static_assert(RequireParameterizableT::value);
273 return AngleT{internal::norm(internal::boxMinus(quantities_.getValues(), other.getQuantities().getValues()))};
274 }
275
279 template <AnyTensor RotationVectorOtherT_>
280 static TensorT exponentialMapJacobian(const RotationVectorOtherT_& rotationVector) {
281 static_assert(RequireParameterizableT::value);
282 return TensorT{internal::exponentialMapJacobian<ValuesT>(internal::elements3(RotationVectorT{rotationVector}))};
283 }
284
285 // The time derivatives of rotations and their angular velocity w, dR/dt = [w]x R, which is expressed in the coordinate system,
286 // like kindr's GlobalAngularVelocity.
287
289 template <AnyTensor AngularVelocityOtherT_>
290 MatrixDerivativeT matrixDerivative(const AngularVelocityOtherT_& angularVelocity) const {
291 static_assert(RequireParameterizableT::value);
292 return MatrixDerivativeT{internal::matrixDerivative(quantities_.getValues(), internal::elements3(AngularVelocityT{angularVelocity}))};
293 }
294
297 template <AnyQuantities MatrixDerivativeOtherT_>
298 AngularVelocityT angularVelocityFromMatrixDerivative(const MatrixDerivativeOtherT_& derivative) const {
299 static_assert(RequireParameterizableT::value);
300 return internal::fromElements<AngularVelocityT>(
301 internal::angularVelocityFromMatrixDerivative(quantities_.getValues(), MatrixDerivativeT{derivative}.getValues()));
302 }
303
306 template <AnyQuantities QuaternionOtherT_, AnyTensor AngularVelocityOtherT_>
307 static QuaternionDerivativeT quaternionDerivative(const QuaternionOtherT_& quaternion, const AngularVelocityOtherT_& angularVelocity) {
308 static_assert(RequireParameterizableT::value);
309 return internal::fromElements<QuaternionDerivativeT>(internal::quaternionDerivative(
310 internal::quaternionElements(QuaternionT{quaternion}), internal::elements3(AngularVelocityT{angularVelocity})));
311 }
312
315 template <AnyQuantities QuaternionOtherT_, AnyQuantities QuaternionDerivativeOtherT_>
316 static AngularVelocityT angularVelocityFromQuaternionDerivative(const QuaternionOtherT_& quaternion,
317 const QuaternionDerivativeOtherT_& derivative) {
318 static_assert(RequireParameterizableT::value);
319 return internal::fromElements<AngularVelocityT>(internal::angularVelocityFromQuaternionDerivative(
320 internal::quaternionElements(QuaternionT{quaternion}), internal::quaternionElements(QuaternionDerivativeT{derivative})));
321 }
322
326 template <AnyQuantities EulerAnglesOtherT_, AnyTensor AngularVelocityOtherT_>
327 static EulerAnglesDerivativeT eulerAnglesZyxDerivative(const EulerAnglesOtherT_& angles, const AngularVelocityOtherT_& angularVelocity) {
328 static_assert(RequireParameterizableT::value);
329 return internal::fromElements<EulerAnglesDerivativeT>(internal::eulerAnglesZyxDerivative(
330 internal::elements3(EulerAnglesT{angles}), internal::elements3(AngularVelocityT{angularVelocity})));
331 }
332
335 template <AnyQuantities EulerAnglesOtherT_, AnyQuantities EulerAnglesDerivativeOtherT_>
336 static AngularVelocityT angularVelocityFromEulerAnglesZyxDerivative(const EulerAnglesOtherT_& angles,
337 const EulerAnglesDerivativeOtherT_& derivative) {
338 static_assert(RequireParameterizableT::value);
339 return internal::fromElements<AngularVelocityT>(internal::angularVelocityFromEulerAnglesZyxDerivative(
340 internal::elements3(EulerAnglesT{angles}), internal::elements3(EulerAnglesDerivativeT{derivative})));
341 }
342
345 template <AnyQuantities EulerAnglesOtherT_, AnyTensor AngularVelocityOtherT_>
346 static EulerAnglesDerivativeT eulerAnglesXyzDerivative(const EulerAnglesOtherT_& angles, const AngularVelocityOtherT_& angularVelocity) {
347 static_assert(RequireParameterizableT::value);
348 return internal::fromElements<EulerAnglesDerivativeT>(internal::eulerAnglesXyzDerivative(
349 internal::elements3(EulerAnglesT{angles}), internal::elements3(AngularVelocityT{angularVelocity})));
350 }
351
354 template <AnyQuantities EulerAnglesOtherT_, AnyQuantities EulerAnglesDerivativeOtherT_>
355 static AngularVelocityT angularVelocityFromEulerAnglesXyzDerivative(const EulerAnglesOtherT_& angles,
356 const EulerAnglesDerivativeOtherT_& derivative) {
357 static_assert(RequireParameterizableT::value);
358 return internal::fromElements<AngularVelocityT>(internal::angularVelocityFromEulerAnglesXyzDerivative(
359 internal::elements3(EulerAnglesT{angles}), internal::elements3(EulerAnglesDerivativeT{derivative})));
360 }
361
362 private:
363 struct Unchecked {};
364 ActiveSpatialRotation(Unchecked /*tag*/, QuantitiesT quantities) : quantities_{std::move(quantities)} {}
365
367 QuantitiesT quantities_;
368};
369
370template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_>
372template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_>
374
375namespace internal {
376
377template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_, int DimensionV_>
378struct IsRotation<ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>> : std::true_type {};
379
380} // namespace internal
381
382template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_, int DimensionV_>
383struct GetCoordinateSystem<ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>> {
384 using type = CoordinateSystemT_;
385};
386
387// A rotation transforms tensors, and conjugates translations and linear transformations, like the active linear transformation
388// with its matrix, but with its transpose as the inverse, e.g. for covectors.
389template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_, int DimensionV_, typename Object>
390struct TransformationTraits<ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>, Object>
391 : TransformationTraits<typename ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>::LinearTransformationT,
392 Object> {};
393
394// The conjugation R Q R^T of a rotation Q by a rotation R is a rotation.
395template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_, int DimensionV_,
396 template <typename, int, int> typename ValuesOtherT_, typename ValueOtherT_, typename CoordinateSystemOtherT_,
397 int DimensionOtherV_>
398struct TransformationTraits<ActiveSpatialRotation<ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_>,
399 ActiveSpatialRotation<ValuesOtherT_, ValueOtherT_, CoordinateSystemOtherT_, DimensionOtherV_>> {
402 const ObjectT& object) {
403 static_assert(std::is_same_v<CoordinateSystemT_, CoordinateSystemOtherT_>, "Coordinate systems do not match.");
404 const auto& rotation = transformation.getQuantities();
405 return ObjectT::makeUnchecked(innerProduct(rotation, innerProduct(object.getQuantities(), rotation.transpose())));
406 }
407};
408
409// The composition of two rotations is the rotation R_lhs R_rhs.
410template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
411 template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_, typename CoordinateSystemRhsT_, int DimensionRhsV_>
412struct CompositionTraits<ActiveSpatialRotation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionLhsV_>,
413 ActiveSpatialRotation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionRhsV_>> {
419};
420
421// A rotation is a linear transformation: its compositions with linear transformations are those of the linear transformation with
422// its matrix, the products of the matrices.
423template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
424 template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_, typename CoordinateSystemRhsT_, int DimensionFromRhsV_,
425 int DimensionToRhsV_, typename... UnitsRhsT_>
427 ActiveSpatialRotation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionLhsV_>,
428 ActiveLinearTransformation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionFromRhsV_, DimensionToRhsV_, UnitsRhsT_...>>
430 typename ActiveSpatialRotation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionLhsV_>::LinearTransformationT,
431 ActiveLinearTransformation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionFromRhsV_, DimensionToRhsV_, UnitsRhsT_...>> {
432};
433
434template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionFromLhsV_,
435 int DimensionToLhsV_, typename... UnitsLhsT_, template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_,
436 typename CoordinateSystemRhsT_, int DimensionRhsV_>
438 ActiveLinearTransformation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionFromLhsV_, DimensionToLhsV_, UnitsLhsT_...>,
439 ActiveSpatialRotation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionRhsV_>>
441 ActiveLinearTransformation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionFromLhsV_, DimensionToLhsV_, UnitsLhsT_...>,
442 typename ActiveSpatialRotation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionRhsV_>::LinearTransformationT> {};
443
444// The compositions of a rotation with a translation or a proper rigid transformation are proper rigid transformations: of the
445// rotation and the translation, or of the type of the proper rigid operand (see internal/rigid.hpp).
446
447template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
448 template <typename, int, int> typename ValuesRhsT_, int DimensionRhsV_, typename ValueRhsT_, typename CoordinateSystemRhsT_,
449 typename... UnitsRhsT_>
450struct CompositionTraits<ActiveSpatialRotation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionLhsV_>,
451 ActiveTranslation<ValuesRhsT_, DimensionRhsV_, ValueRhsT_, CoordinateSystemRhsT_, UnitsRhsT_...>> {
453 using RhsT = ActiveTranslation<ValuesRhsT_, DimensionRhsV_, ValueRhsT_, CoordinateSystemRhsT_, UnitsRhsT_...>;
455 static ResultT compose(const LhsT& lhs, const RhsT& rhs) { return internal::composeRotationAndTranslation<ResultT>(lhs, rhs); }
456};
457
458template <template <typename, int, int> typename ValuesLhsT_, int DimensionLhsV_, typename ValueLhsT_, typename CoordinateSystemLhsT_,
459 typename... UnitsLhsT_, template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_, typename CoordinateSystemRhsT_,
460 int DimensionRhsV_>
461struct CompositionTraits<ActiveTranslation<ValuesLhsT_, DimensionLhsV_, ValueLhsT_, CoordinateSystemLhsT_, UnitsLhsT_...>,
462 ActiveSpatialRotation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionRhsV_>> {
463 using LhsT = ActiveTranslation<ValuesLhsT_, DimensionLhsV_, ValueLhsT_, CoordinateSystemLhsT_, UnitsLhsT_...>;
466 static ResultT compose(const LhsT& lhs, const RhsT& rhs) { return internal::composeTranslationAndRotation<ResultT>(lhs, rhs); }
467};
468
469template <typename CoordinateSystemT_, typename RotationT_, typename TranslationT_, template <typename, int, int> typename ValuesRhsT_,
470 typename ValueRhsT_, typename CoordinateSystemRhsT_, int DimensionRhsV_>
471struct CompositionTraits<ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>,
472 ActiveSpatialRotation<ValuesRhsT_, ValueRhsT_, CoordinateSystemRhsT_, DimensionRhsV_>> {
474 static ResultT compose(const ResultT& lhs,
476 return internal::composeRigidAndRotation<ResultT>(lhs, rhs);
477 }
478};
479
480template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
481 typename CoordinateSystemT_, typename RotationT_, typename TranslationT_>
482struct CompositionTraits<ActiveSpatialRotation<ValuesLhsT_, ValueLhsT_, CoordinateSystemLhsT_, DimensionLhsV_>,
483 ActiveProperRigidTransformationTemplate<CoordinateSystemT_, RotationT_, TranslationT_>> {
486 const ResultT& rhs) {
487 return internal::composeRotationAndRigid<ResultT>(lhs, rhs);
488 }
489};
490
491template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
492 template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_, typename CoordinateSystemRhsT_, int DimensionRhsV_>
495 static_assert(std::is_same_v<CoordinateSystemLhsT_, CoordinateSystemRhsT_>, "Coordinate systems do not match.");
496 return lhs.getQuantities() == rhs.getQuantities();
497}
498
499template <template <typename, int, int> typename ValuesLhsT_, typename ValueLhsT_, typename CoordinateSystemLhsT_, int DimensionLhsV_,
500 template <typename, int, int> typename ValuesRhsT_, typename ValueRhsT_, typename CoordinateSystemRhsT_, int DimensionRhsV_>
505
506template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename CoordinateSystemT_, int DimensionV_>
508 lhs << rhs.getQuantities();
509 return lhs;
510}
511
512} // namespace wuzp
ValuesT_< ValueT_, DimensionToV_, DimensionFromV_ > ValuesT
Quantities< ValuesT, UnitsT > QuantitiesT
Tensor< Indices< Up, Down >, QuantitiesT, CoordinateSystemT, Relative > TensorT
TypeMatrix< DimensionToV_, DimensionFromV_, UnitsT_... > UnitsT
An active proper rigid transformation, which first rotates, then translates: x -> R x + t,...
An active rotation in its coordinate system: the dimensionless linear transformation x -> R x whose m...
static QuaternionDerivativeT quaternionDerivative(const QuaternionOtherT_ &quaternion, const AngularVelocityOtherT_ &angularVelocity)
The derivative dq/dt = (0, w) q / 2 of the unit quaternion q for the angular velocity w,...
EulerAnglesT toEulerAnglesZyx() const
The Euler angles ZYX (yaw, pitch, roll) of the rotation (see fromEulerAnglesZyx()),...
AngularVelocityT angularVelocityFromMatrixDerivative(const MatrixDerivativeOtherT_ &derivative) const
The angular velocity w of the derivative dR/dt of the matrix, [w]x = dR/dt R^T, the inverse of matrix...
typename ParameterizationsT::EulerAnglesT EulerAnglesT
Three Euler angles, in the order of the axes in their name, e.g. (yaw, pitch, roll) for ZYX.
typename ParameterizationsT::QuaternionDerivativeT QuaternionDerivativeT
The derivative dq/dt of a quaternion with respect to time, in the unit of an angular velocity.
static ActiveSpatialRotation fromEulerAnglesXyz(const EulerAnglesOtherT_ &angles)
The rotation of the Euler angles XYZ (a0, a1, a2), intrinsic: by a0 around x, then by a1 around the n...
typename LinearTransformationT::QuantitiesT QuantitiesT
QuaternionT toQuaternion() const
The unique unit quaternion of the rotation, whose first element that is not zero is positive,...
typename ParameterizationsT::template AngularVelocityT< CoordinateSystemT_ > AngularVelocityT
The angular velocity w of a rotation R, dR/dt = [w]x R, expressed in the coordinate system.
static AngularVelocityT angularVelocityFromEulerAnglesZyxDerivative(const EulerAnglesOtherT_ &angles, const EulerAnglesDerivativeOtherT_ &derivative)
The angular velocity w of the derivatives of the Euler angles ZYX, w = dyaw/dt e_z + dpitch/dt R_z(ya...
static ActiveSpatialRotation makeUnchecked(Args &&... args)
The rotation whose matrix is constructed from the arguments, without checking it, like Drake's Rotati...
static TensorT exponentialMapJacobian(const RotationVectorOtherT_ &rotationVector)
The Jacobian J of the exponential map at the rotation vector v, a linear map in the coordinate system...
std::pair< AngleT, AxisT > AngleAxisT
The angle and the unit axis of a rotation.
RotationVectorT boxMinus(const ActiveSpatialRotation< ValuesT_, ValueT_, CoordinateSystemOtherT_, DimensionV_ > &other) const
The rotation vector R (-) S = Log(R S^T), expressed in the coordinate system, which rotates the other...
static EulerAnglesDerivativeT eulerAnglesZyxDerivative(const EulerAnglesOtherT_ &angles, const AngularVelocityOtherT_ &angularVelocity)
The derivatives of the Euler angles ZYX (yaw, pitch, roll) for the angular velocity w,...
typename ParameterizationsT::template RotationVectorT< CoordinateSystemT_ > RotationVectorT
A rotation vector angle * axis, expressed in the coordinate system, e.g. the logarithm of a rotation ...
static ActiveSpatialRotation fromQuaternion(const QuaternionOtherT_ &quaternion)
The rotation of a unit quaternion q (see QuaternionT), whose matrix is that of Eigen's Quaternion::to...
static ActiveSpatialRotation fromRotationVector(const RotationVectorOtherT_ &rotationVector)
The exponential map Exp(v) of a rotation vector v, which is expressed in the coordinate system: the r...
static AngularVelocityT angularVelocityFromQuaternionDerivative(const QuaternionOtherT_ &quaternion, const QuaternionDerivativeOtherT_ &derivative)
The angular velocity w of the derivative dq/dt of the unit quaternion q, the vector part of 2 (dq/dt)...
AngleAxisT toAngleAxis() const
The angle in [0, pi] and the unit axis of the rotation.
ActiveLinearTransformation< ValuesT_, ValueT_, CoordinateSystemT_, DimensionV_, DimensionV_, typename AccessUnits< AccessImplementation< ValueT_ > >::Dimensionless > LinearTransformationT
The active linear transformation with the matrix of the rotation, whose transformations the rotation ...
static ActiveSpatialRotation projectToRotation(Args &&... args)
The rotation nearest to the matrix constructed from the arguments, e.g. to a rotation whose rounding ...
const QuantitiesT & getQuantities() const
The matrix R, which transforms a vector v into R v.
typename ParameterizationsT::EulerAnglesDerivativeT EulerAnglesDerivativeT
The derivatives of three Euler angles with respect to time.
MatrixDerivativeT matrixDerivative(const AngularVelocityOtherT_ &angularVelocity) const
The derivative dR/dt = [w]x R of the matrix for the angular velocity w, like kindr's RotationMatrixDi...
typename ParameterizationsT::template AxisT< CoordinateSystemT_ > AxisT
The unit axis of a rotation, expressed in the coordinate system.
typename ParameterizationsT::MatrixDerivativeT MatrixDerivativeT
The derivative dR/dt of the matrix of a rotation with respect to time.
static EulerAnglesDerivativeT eulerAnglesXyzDerivative(const EulerAnglesOtherT_ &angles, const AngularVelocityOtherT_ &angularVelocity)
The derivatives of the Euler angles XYZ for the angular velocity w, like kindr's EulerAnglesXyzDiff.
typename LinearTransformationT::ValuesT ValuesT
typename LinearTransformationT::UnitsT UnitsT
RotationVectorT toRotationVector() const
The logarithmic map Log(R), the rotation vector of the rotation, whose norm, the angle,...
typename ParameterizationsT::AngleT AngleT
An angle, e.g. of a rotation around its axis, or between two rotations.
static ActiveSpatialRotation fromEulerAnglesZyx(const EulerAnglesOtherT_ &angles)
The rotation of the Euler angles ZYX (yaw, pitch, roll), intrinsic: by yaw around z,...
TensorT getTensor() const
The matrix as a linear map, a tensor with an upper and a lower index.
static ActiveSpatialRotation fromTwoVectors(const FromVectorT_ &from, const ToVectorT_ &to)
The rotation with the smallest angle that rotates the direction of the vector from into the direction...
bool isValid(const ValueT tolerance=ValidityTolerance< ValueT >::value()) const
Whether the matrix is a rotation: max_ij |(R R^T - I)_ij| <= tolerance, and det(R) > 0 (see internal:...
bool isApprox(const ActiveSpatialRotation< ValuesOtherT_, ValueOtherT_, CoordinateSystemOtherT_, DimensionOtherV_ > &other, const ValueT precision=Precision< ValueT >::value()) const
Whether both rotations, which must be expressed in the same coordinate system, are approximately equa...
static AngularVelocityT angularVelocityFromEulerAnglesXyzDerivative(const EulerAnglesOtherT_ &angles, const EulerAnglesDerivativeOtherT_ &derivative)
The angular velocity w of the derivatives of the Euler angles XYZ, w = da0/dt e_x + da1/dt R_x(a0) e_...
ActiveSpatialRotation(Args &&... args)
The rotation whose matrix is constructed from the arguments, e.g. its elements row by row,...
AngleT angularDistance(const ActiveSpatialRotation< ValuesT_, ValueT_, CoordinateSystemOtherT_, DimensionV_ > &other) const
The angle in [0, pi] of the rotation between this and the other rotation, the norm of boxMinus(other)...
ActiveSpatialRotation boxPlus(const RotationVectorOtherT_ &rotationVector) const
The rotation R (+) v = Exp(v) R, rotated further by the rotation vector v, which is expressed in the ...
typename LinearTransformationT::TensorT TensorT
typename ParameterizationsT::QuaternionT QuaternionT
A unit quaternion (w, x, y, z) = (cos(angle / 2), sin(angle / 2) n) of the rotation by an angle aroun...
static ActiveSpatialRotation fromAngleAxis(const AngleOtherT_ &angle, const AxisOtherT_ &axis)
The right-handed rotation by an angle around a unit axis, which is expressed in the coordinate system...
EulerAnglesT toEulerAnglesXyz() const
The Euler angles XYZ (a0, a1, a2) of the rotation (see fromEulerAnglesXyz()), with a0 and a2 in [-pi,...
ActiveSpatialRotation inverse() const
The inverse rotation, whose matrix is the transpose R^T = R^-1: it needs no matrix inverse.
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,...
const ValuesT & getValues() const &
Get the values of the quantities.
The alias template ValueMatrix<ValueT_, RowsV_, ColsV_> of any value matrix backend,...
Definition concepts.hpp:89
Whether constructing a Class from the arguments copies or moves it, i.e. whether they are a single Cl...
Definition helpers.hpp:69
A coordinate system with the Euclidean metric, the default, e.g. CoordinateSystem<World>: the coordin...
Definition concepts.hpp:35
ActiveSpatialRotation< ValuesT_, ValueT_, CoordinateSystemT_, 3 > ActiveSpatialRotation3
bool operator!=(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
std::ostream & operator<<(std::ostream &lhs, const Quantities< ValuesT_, UnitsT_ > &rhs)
auto innerProduct(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
ActiveSpatialRotation< ValuesT_, ValueT_, CoordinateSystemT_, 2 > ActiveSpatialRotation2
bool operator==(const Quantities< ValuesLhsT_, UnitsLhsT_ > &lhs, const Quantities< ValuesRhsT_, UnitsRhsT_ > &rhs)
The units for values of the arithmetic type ValueT_, e.g. double, specialized for AccessImplementatio...
Definition traits.hpp:338
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
How a transformation transforms an object: static auto transform(const TransformationT_&,...
Definition traits.hpp:19
static constexpr ValueT_ value()
Definition traits.hpp:58