10#if !defined(MiniTensor_Rotations_h)
11#define MiniTensor_Rotations_h
27template<
typename T, Index N>
37template<
typename T, Index N>
47template<
typename T, Index N>
58template<
typename T, Index N>
61vee(Tensor<T, N>
const & W);
68template<
typename T, Index N>
77 assert(
norm(
dot_t(R,R) - eye<T, N>(dimension)) <
78 std::max(1.0e-12 *
norm(R), 1.0e-12));
79 assert(std::abs(
det(R) - 1.0) <
80 std::max(1.0e-12 *
norm(R), 1.0e-12));
83 cosine = 0.5 * (
trace(R) - 1.0);
87 }
else if(cosine > 1.0) {
91 theta = std::acos(cosine);
99 MT_ERROR_EXIT(
"Logarithm of SO(N) N != 2,3 not implemented.");
107 }
else if (std::abs(cosine + 1.0) < 10.0 * machine_epsilon<T>()) {
113 r = theta / std::sin(theta) *
skew(R);
138template<
typename T, Index N>
147 assert(std::abs(
trace(R) + 1.0) < 10.0 * machine_epsilon<T>());
155 MT_ERROR_EXIT(
"Logarithm of SO(N) N != 2,3 not implemented.");
164 B = R - identity<T, N>(3);
182 MT_ERROR_EXIT(
"Cannot determine rotation vector of rotation.");
198 pi = std::acos(-1.0);
206 T theta = std::acos(-1.0);
226template<
typename T, Index N>
232 assert(
norm(
sym(r)) < std::max(1.0e-12 *
norm(r), 1.0e-12));
238 R = identity<T, N>(dimension);
250 theta = std::sqrt(r(2,1)*r(2,1)+r(0,2)*r(0,2)+r(1,0)*r(1,0));
253 if (theta >= machine_epsilon<T>()) {
254 R += sin(theta) / theta * r +
255 (1.0 - cos(theta)) / (theta * theta) * r * r;
289template<
typename T, Index N>
295 assert(
norm(
sym(W)) < std::max(1.0e-12 *
norm(W), 1.0e-12));
312 MT_ERROR_EXIT(
"Axial vector from tensor defined for 3D only");
#define KOKKOS_INLINE_FUNCTION
#define MT_ERROR_EXIT(...)
KOKKOS_INLINE_FUNCTION Vector< typename Promote< S, T >::type, N > cross(Vector< S, N > const &u, Vector< T, N > const &v)
KOKKOS_INLINE_FUNCTION Index get_dimension() const
KOKKOS_INLINE_FUNCTION Matrix< typename Promote< S, T >::type, M, N > dot_t(Matrix< S, M, P > const &A, Matrix< T, N, P > const &B)
KOKKOS_INLINE_FUNCTION void fill(Filler const value)
KOKKOS_INLINE_FUNCTION Tensor< T, N > sym(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION Tensor< T, N > skew(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION Vector< T, N > row(Matrix< T, M, N > const &A, Index const i)
KOKKOS_INLINE_FUNCTION Vector< T, N > normal(Vector< T, N > const &p0, Vector< T, N > const &p1, Vector< T, N > const &p2)
Tensor< T, N > exp(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION T norm(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION T det(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION T trace(Tensor< T, N > const &A)
KOKKOS_INLINE_FUNCTION Tensor< T, N > log_rotation_pi(Tensor< T, N > const &R)
KOKKOS_INLINE_FUNCTION Vector< T, N > vee(Tensor< T, N > const &W)
KOKKOS_INLINE_FUNCTION Tensor< T, N > log_rotation(Tensor< T, N > const &R)
KOKKOS_INLINE_FUNCTION Tensor< T, N > exp_skew_symmetric(Tensor< T, N > const &r)
KOKKOS_INLINE_FUNCTION Quaternion< T > unit(Quaternion< T > const &q)
uint32_t Index
Indexing type.