28#ifndef GEOMETRIC_OPERATIONS_H
29#define GEOMETRIC_OPERATIONS_H
40template <
typename T,
unsigned D>
41decltype(Vector<decltype(util::sqrt(T())), D>())
45 return conversionFactor * angle;
54template <
typename T,
unsigned D>
59 return conversionFactor * angle;
68template <
typename T,
unsigned D>
74 if constexpr (D == 2) {
79 rotationMatrix[0] =
cos;
80 rotationMatrix[1] = -
sin;
82 rotationMatrix[2] =
sin;
83 rotationMatrix[3] =
cos;
96 rotationMatrix[0] =
cos[1] *
cos[2];
100 rotationMatrix[3] =
cos[1] *
sin[2];
104 rotationMatrix[6] = -
sin[1];
105 rotationMatrix[7] =
sin[0] *
cos[1];
106 rotationMatrix[8] =
cos[0] *
cos[1];
109 return rotationMatrix;
112template <
typename T,
unsigned D>
116 if constexpr (D == 2) {
117 return Vector<T, 4>(rotationMatrix[0], rotationMatrix[2], rotationMatrix[1],
127 return Vector<T, 9>(rotationMatrix[0], rotationMatrix[3], rotationMatrix[6],
128 rotationMatrix[1], rotationMatrix[4], rotationMatrix[7],
129 rotationMatrix[2], rotationMatrix[5],
132 __builtin_unreachable();
135template <
typename T,
unsigned D>
140 return invertRotationMatrix<T, D>(calculateRotationMatrix<T, D>(angle));
144template <
typename T,
unsigned D,
145 bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN =
false>
154 if constexpr (D == 2) {
156 Vector<T, 2>(dist[0] * rotationMatrix[0] + dist[1] * rotationMatrix[1],
157 dist[0] * rotationMatrix[2] + dist[1] * rotationMatrix[3]);
161 Vector<T, 3>(rotationMatrix[0] * dist[0] + rotationMatrix[1] * dist[1] +
162 rotationMatrix[2] * dist[2],
163 rotationMatrix[3] * dist[0] + rotationMatrix[4] * dist[1] +
164 rotationMatrix[5] * dist[2],
165 rotationMatrix[6] * dist[0] + rotationMatrix[7] * dist[1] +
166 rotationMatrix[8] * dist[2]);
169 if constexpr (!OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN) {
170 return rotationCenter + rotated;
176 __builtin_unreachable();
180template <
typename T,
unsigned D,
181 bool OUTPUT_USES_ROTATION_CENTER_AS_ORIGIN =
false>
188 invertRotationMatrix<T, D>(rotationMatrix);
193template <
typename T,
unsigned D>
200 if constexpr (D == 2) {
203 velocity[0] - angularVelocity[0] * (position[1] - rotationCenter[1]),
204 velocity[1] + angularVelocity[0] * (position[0] - rotationCenter[0]));
211 __builtin_unreachable();
222 {mofi[0], T {}, T {}},
223 { T {}, mofi[1], T {}},
224 { T {}, T {}, mofi[2]}
229 _rotationMatrix * inertiaTensor * (_rotationMatrix.
transpose());
231 return inertiaTensor;
Matrix with a defined number of ROWS and columns (COLS)
constexpr Matrix< T, COLS, ROWS > transpose() const
decltype(Vector< decltype(util::sqrt(T())), D >()) radianToDegree(const Vector< T, D > &angle)
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Vector< T, D > invertRotation(const Vector< T, D > &input, const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix, const Vector< T, D > &rotationCenter=Vector< T, D >(0.))
Rotates the input around the rotationCenter with a given rotationMatrix in the opposite direction.
constexpr Matrix< T, 3, 3 > rotateMofi(const Vector< T, 3 > &mofi, const Vector< T, 9 > &rotationMatrix)
Rotate moment of inertia (mofi)
ADf< T, DIM > sin(const ADf< T, DIM > &a)
Vector< T, utilities::dimensions::convert< D >::matrix > calculateRotationMatrix(const Vector< T, utilities::dimensions::convert< D >::rotation > &angle)
decltype(Vector< decltype(util::sqrt(T())), D >()) degreeToRadian(const Vector< T, D > &angle)
Vector< T, D > executeRotation(const Vector< T, D > &input, const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix, const Vector< T, D > &rotationCenter=Vector< T, D >(0.))
Rotates the input around the rotationCenter with a given rotationMatrix.
constexpr Vector< T, D > calculateLocalVelocity(const Vector< T, D > &rotationCenter, const Vector< T, D > &velocity, const Vector< T, utilities::dimensions::convert< D >::rotation > &angularVelocity, const Vector< T, D > &position)
Calculate local velocity.
Vector< T, utilities::dimensions::convert< D >::matrix > invertRotationMatrix(const Vector< T, utilities::dimensions::convert< D >::matrix > &rotationMatrix)
Vector< T, utilities::dimensions::convert< D >::matrix > calculateInverseRotationMatrix(const Vector< T, utilities::dimensions::convert< D >::rotation > &angle)
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
typename util::BaseTypeHelper< T >::type BaseType
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Converts dimensions by deriving from given cartesian dimension D.
efficient implementation of a vector class