10 double length =
sqrt(
dot(vec, vec));
15 "length of vector less than 1e-12");
25 (*this)(0) =
sqrt(
std::max(0.0, 1 + M(0, 0) + M(1, 1) + M(2, 2))) / 2;
26 (*this)(1) =
sqrt(
std::max(0.0, 1 + M(0, 0) - M(1, 1) - M(2, 2))) / 2;
27 (*this)(2) =
sqrt(
std::max(0.0, 1 - M(0, 0) + M(1, 1) - M(2, 2))) / 2;
28 (*this)(3) =
sqrt(
std::max(0.0, 1 - M(0, 0) - M(1, 1) + M(2, 2))) / 2;
29 (*this)(1) =
std::abs(M(2, 1) - M(1, 2)) > 0?
copysign((*
this)(1), M(2, 1) - M(1, 2)): 0.0;
30 (*this)(2) =
std::abs(M(0, 2) - M(2, 0)) > 0?
copysign((*
this)(2), M(0, 2) - M(2, 0)): 0.0;
31 (*this)(3) =
std::abs(M(1, 0) - M(0, 1)) > 0?
copysign((*
this)(3), M(1, 0) - M(0, 1)): 0.0;
36 const double tol = 1
e-12;
42 double normAxis =
sqrt(
dot(axis,axis));
52 axis(0) =
sqrt(1 - u*u) *
cos(v);
53 axis(1) =
sqrt(1 - u*u) *
sin(v);
57 axis -=
dot(axis, ref) *
ref;
58 axis = normalize(axis);
65 double cosAngle =
sqrt(0.5 * (1 +
dot(u, ref)));
66 double sinAngle =
sqrt(1 - cosAngle * cosAngle);
81 return result *= other;
89 *
this =
Quaternion((*
this)(0) * other(0) -
dot(imagThis, imagOther),
90 (*
this)(0) * imagOther + other(0) * imagThis +
cross(imagThis, imagOther));
105 if (this->
Norm() < 1
e-12)
107 "length of quaternion less than 1e-12");
110 (*this) /= this->
length();
127 "quaternion isn't unit quaternion. Norm: " + std::to_string(this->
Norm()));
132 return ((*
this) * (quat * (*this).
conjugate())).imag();
140 2 * (-rot(0) * rot(3) + rot(1) * rot(2)),
141 2 * (rot(0) * rot(2) + rot(1) * rot(3)),
142 2 * (rot(0) * rot(3) + rot(1) * rot(2)),
143 1 - 2 * (rot(1) * rot(1) + rot(3) * rot(3)),
144 2 * (-rot(0) * rot(1) + rot(2) * rot(3)),
145 2 * (-rot(0) * rot(2) + rot(1) * rot(3)),
146 2 * (rot(0) * rot(1) + rot(2) * rot(3)),
147 1 - 2 * (rot(1) * rot(1) + rot(2) * rot(2)));
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
Tenzor< double, 3 > getRotationMatrix() const
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TBTree< FnCopysign, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > copysign(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Quaternion getQuaternion(Vector_t u, Vector_t ref)
RandomNumberGen IpplRandom
Quaternion & operator*=(const Quaternion &)
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
constexpr double pi
The value of .
Quaternion operator*(const double &) const
Vector3D cross(const Vector3D &lhs, const Vector3D &rhs)
Vector cross product.
Quaternion inverse() const
Vektor< double, 3 > Vector_t
Quaternion operator/(const double &) const
Tps< T > sqrt(const Tps< T > &x)
Square root.
Tps< T > cos(const Tps< T > &x)
Cosine.
Vector_t rotate(const Vector_t &) const
Quaternion conjugate() const