13#include "libmesh/vector_value.h"
14#include "libmesh/tensor_value.h"
22template <
bool is_ad = false>
27 using std::sqrt, std::abs;
29 vec /= sqrt(vec * vec);
38 if ((w(2) >= w(1) && w(1) >= w(0)) || (w(1) >= w(2) && w(2) >= w(0)))
41 else if ((w(2) >= w(0) && w(0) >= w(1)) || (w(0) >= w(2) && w(2) >= w(1)))
48 v1 -= (v1 * vec) * vec;
53 v0(0) = v1(1) * vec(2) - v1(2) * vec(1);
54 v0(1) = v1(2) * vec(0) - v1(0) * vec(2);
55 v0(2) = v1(0) * vec(1) - v1(1) * vec(0);
59 v0(0), v0(1), v0(2), v1(0), v1(1), v1(2), vec(0), vec(1), vec(2));
64template <
bool is_ad = false>
71 return rot2_to_z.transpose() * rot1_to_z;
75template <
bool is_ad = false>
80 using std::atan2, std::sin, std::cos;
94template <
bool is_ad = false>
114 mooseError(
"Rotation matrix cannot be generated for opposite-facing vectors at this time!");
118 k_vec /= k_vec.norm();
119 Real cos_theta = u * v;
120 Real theta = std::acos(cos_theta);
121 Real sin_theta = std::sin(theta);
124 0, -k_vec(2), k_vec(1), k_vec(2), 0, -k_vec(0), -k_vec(1), k_vec(0), 0);
129 rot_matrix = I + sin_theta * K_matrix + (1 - cos_theta) * K_matrix * K_matrix;
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Moose::GenericType< Real, is_ad > GenericReal
Moose::GenericType< RealTensorValue, is_ad > GenericRealTensorValue
Moose::GenericType< RealVectorValue, is_ad > GenericRealVectorValue
Utility functions to return rotations matrics.
GenericRealTensorValue< is_ad > rotVecToZ(GenericRealVectorValue< is_ad > vec)
provides a rotation matrix that will rotate the vector vec to the z axis (the "2" direction)
GenericRealTensorValue< is_ad > rotVec1ToVec2(GenericRealVectorValue< is_ad > vec1, GenericRealVectorValue< is_ad > vec2)
provides a rotation matrix that will rotate the vector vec1 to vec2
GenericRealTensorValue< is_ad > rodriguesRotationMatrix(GenericRealVectorValue< is_ad > vec1, GenericRealVectorValue< is_ad > vec2)
Provides rotatiom matrix for rotating from vec1 to vec2 using Rodrigues' rotation forumula.
GenericRealTensorValue< is_ad > rotVec2DToX(const GenericRealVectorValue< is_ad > &vec)
provides a rotation matrix that will rotate the vector vec1 to the [1,0,0], assuming vec1[2]==0
static constexpr Real TOLERANCE