wuzp
Wrong Unit? Zero Points! Compile-time checks for units, coordinate systems and points vs. vectors.
Loading...
Searching...
No Matches
SpatialAcceleration.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4#include <utility>
5
14
15namespace wuzp {
16
31template <template <typename, int, int> typename ValuesT_, typename ValueT_, EuclideanCoordinateSystem MeasuredInT_,
34class SpatialAcceleration : public SpatialVector<SpatialAcceleration<ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointT_, ExpressedInT_>,
35 AngularAccelerationVector3<ValuesT_, ValueT_, ExpressedInT_>,
36 AccelerationVector3<ValuesT_, ValueT_, ExpressedInT_>> {
39
40 public:
42 using MeasuredInT = MeasuredInT_;
44 using FrameT = FrameT_;
46 using PointT = PointT_;
48 using ExpressedInT = ExpressedInT_;
51
53
56 template <typename AngularAccelerationOtherT_, typename AccelerationOtherT_>
58 SpatialAcceleration(AngularAccelerationOtherT_&& angularAcceleration, AccelerationOtherT_&& acceleration)
59 : BaseT(std::forward<AngularAccelerationOtherT_>(angularAcceleration), std::forward<AccelerationOtherT_>(acceleration)) {}
60
68 template <EuclideanCoordinateSystem PointOtherT_, AnyTensor OffsetOtherT_, typename MeasuredInVelocityT_, typename FrameVelocityT_,
69 typename PointVelocityT_, typename ExpressedInVelocityT_>
71 const OffsetOtherT_& offset,
73 const {
74 static_assert(internal::SameSpatialTagsExceptPoint<SpatialAcceleration, std::remove_cvref_t<decltype(velocity)>>::value);
75 return {this->getRotational(),
76 accelerationOfBodyFixedPoint(this->getTranslational(), this->getRotational(), velocity.getRotational(), offset)};
77 }
78
91 template <AnyTensor OffsetOtherT_, typename MeasuredInVelocityT_, typename FrameVelocityT_, typename PointVelocityT_,
92 typename ExpressedInVelocityT_, typename MeasuredInRelativeT_, typename FrameRelativeT_, typename PointRelativeT_,
93 typename ExpressedInRelativeT_, typename MeasuredInAccelerationT_, typename FrameAccelerationT_, typename PointAccelerationT_,
94 typename ExpressedInAccelerationT_>
96 const OffsetOtherT_& offset,
98 velocityOfThisFrame,
100 const SpatialAcceleration<ValuesT_, ValueT_, MeasuredInAccelerationT_, FrameAccelerationT_, PointAccelerationT_,
101 ExpressedInAccelerationT_>& acceleration) const {
102 static_assert(internal::SameSpatialTags<std::remove_cvref_t<decltype(velocity)>, std::remove_cvref_t<decltype(acceleration)>>::value);
103 static_assert(std::is_same_v<MeasuredInRelativeT_, FrameT_>, "Adjacent frames do not match.");
104 static_assert(std::is_same_v<ExpressedInRelativeT_, ExpressedInT_>, "Coordinate systems do not match.");
105 const auto shifted = shift<PointRelativeT_>(offset, velocityOfThisFrame);
106 // Not named angularVelocity: MSVC checks the names of locals against the globals at the point of instantiation, and warns if
107 // they hide one, e.g. a global angularVelocity of the user (C4459, #84).
108 const auto& angularVelocityOfThisFrame = velocityOfThisFrame.getRotational();
109 return {shifted.getRotational() + acceleration.getRotational() + angularVelocityOfThisFrame.crossProduct(velocity.getRotational()),
110 shifted.getTranslational() + angularVelocityOfThisFrame.crossProduct(velocity.getTranslational()) * ValueT_{2} +
111 acceleration.getTranslational()};
112 }
113};
114
121template <typename FromT_, typename ToT_, typename RotationT_, typename TranslationT_, template <typename, int, int> typename ValuesT_,
122 typename ValueT_, typename MeasuredInT_, typename FrameT_, typename PointT_, typename ExpressedInT_>
126 "The adjoint map of a rigid transformation maps spatial velocities and spatial forces. Shifting a spatial acceleration "
127 "needs the angular velocity: re-express it with transform() and shift() it.");
128}
129
130namespace internal {
131
132template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename MeasuredInT_, typename FrameT_, typename PointT_,
133 typename ExpressedInT_, typename NewExpressedInT_>
134struct WithExpressedIn<SpatialAcceleration<ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointT_, ExpressedInT_>, NewExpressedInT_> {
135 using type = SpatialAcceleration<ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointT_, NewExpressedInT_>;
136};
137
138} // namespace internal
139
140template <template <typename, int, int> typename ValuesT_, typename ValueT_, typename MeasuredInT_, typename FrameT_, typename PointT_,
141 typename ExpressedInT_>
142struct GetCoordinateSystem<SpatialAcceleration<ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointT_, ExpressedInT_>> {
143 using type = ExpressedInT_;
144};
145
146} // namespace wuzp
A passive proper rigid transformation from From to To, which first rotates, then translates: p -> R p...
The spatial acceleration A_MBp_E of the frame B, measured in the frame M, about the point Bp,...
FrameT_ FrameT
The frame B whose motion it is.
SpatialAcceleration(AngularAccelerationOtherT_ &&angularAcceleration, AccelerationOtherT_ &&acceleration)
The spatial acceleration with the angular acceleration alpha_MB and the acceleration a_MBp,...
SpatialAcceleration< ValuesT_, ValueT_, MeasuredInT_, FrameRelativeT_, PointRelativeT_, ExpressedInT_ > composeWithMovingFrameAcceleration(const OffsetOtherT_ &offset, const SpatialVelocity< ValuesT_, ValueT_, MeasuredInVelocityT_, FrameVelocityT_, PointVelocityT_, ExpressedInVelocityT_ > &velocityOfThisFrame, const SpatialVelocity< ValuesT_, ValueT_, MeasuredInRelativeT_, FrameRelativeT_, PointRelativeT_, ExpressedInRelativeT_ > &velocity, const SpatialAcceleration< ValuesT_, ValueT_, MeasuredInAccelerationT_, FrameAccelerationT_, PointAccelerationT_, ExpressedInAccelerationT_ > &acceleration) const
The spatial acceleration A_MCq of the frame C, which moves relative to B, measured in M,...
PointT_ PointT
The point Bp the spatial acceleration is about, which is fixed to B.
MeasuredInT_ MeasuredInT
The frame M the motion is measured in.
ExpressedInT_ ExpressedInT
The coordinate system E both parts are expressed in.
PositionVector3< ValuesT_, ValueT_, ExpressedInT_ > OffsetT
The position vector from one point to another, expressed in E, by which shift() shifts.
SpatialAcceleration< ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointOtherT_, ExpressedInT_ > shift(const OffsetOtherT_ &offset, const SpatialVelocity< ValuesT_, ValueT_, MeasuredInVelocityT_, FrameVelocityT_, PointVelocityT_, ExpressedInVelocityT_ > &velocity) const
The spatial acceleration A_MBq about another point Bq fixed to B, PointOtherT_, given the position ve...
The spatial velocity (twist) V_MBp_E of the frame B, measured in the frame M, about the point Bp,...
Any tensor: a specialization of Tensor, including points, vectors and their aliases.
Definition concepts.hpp:118
The alias template ValueMatrix<ValueT_, RowsV_, ColsV_> of any value matrix backend,...
Definition concepts.hpp:89
A coordinate system with the Euclidean metric, the default, e.g. CoordinateSystem<World>: the coordin...
Definition concepts.hpp:35
AccelerationVector< 3, ValuesT_, ValueT_, CoordinateSystemT_ > AccelerationVector3
Definition Tensor.hpp:1013
auto accelerationOfBodyFixedPoint(const AccelerationT_ &acceleration, const AngularAccelerationT_ &angularAcceleration, const AngularVelocityT_ &angularVelocity, const OffsetT_ &offset)
The acceleration a_Q = a_P + alpha x p_PQ + w x (w x p_PQ) of a point Q fixed to a rigid body,...
PositionVector< 3, ValuesT_, ValueT_, CoordinateSystemT_ > PositionVector3
Definition Tensor.hpp:997
auto adjoint(const PassiveProperRigidTransformationTemplate< FromT_, ToT_, RotationT_, TranslationT_ > &, const SpatialAcceleration< ValuesT_, ValueT_, MeasuredInT_, FrameT_, PointT_, ExpressedInT_ > &)
Rejected with a message: the adjoint map of a rigid transformation maps spatial velocities and spatia...
False for every type, so that a static_assert on it fails only when the template that names it is ins...
Definition helpers.hpp:21