6#include "utils/mardyn_assert.h"
12 Quaternion(
double qw = 1.,
double qx = 1.,
double qy = 0.,
double qz = 0.)
13 : m_qw(qw), m_qx(qx), m_qy(qy), m_qz(qz) {
20 Quaternion(
const double& alpha_rad,
const std::array<double,3>& n);
22 double qw()
const {
return m_qw; }
23 double qx()
const {
return m_qx; }
24 double qy()
const {
return m_qy; }
25 double qz()
const {
return m_qz; }
26 double magnitude2()
const {
27 return m_qw * m_qw + m_qx * m_qx + m_qy * m_qy + m_qz * m_qz;
29 void scale(
double s) {
36 void scaleinv(
double s) {
37 mardyn_assert(s != 0.);
41 scaleinv(sqrt(magnitude2()));
50 scaleinv(magnitude2());
68 std::array<double, 3>
rotate(
const std::array<double, 3>& d)
const;
76 std::array<double, 3> dcopy = d;
79 std::array<double, 3> rotateinv(
const std::array<double, 3>& d)
const;
80 void rotateinvInPlace(std::array<double, 3>& d)
const {
81 std::array<double, 3> dcopy = d;
85 void differentiate(
const std::array<double, 3>& w,
Quaternion& dqdt)
const;
87 void getRotMatrix(
double R[3][3])
const;
88 void getRotinvMatrix(
double R[3][3])
const;
90 bool isNormalized()
const {
91 return fabs(magnitude2() - 1.0) <= 1e-15;
95 mardyn_assert(std::isfinite(m_qw));
96 mardyn_assert(std::isfinite(m_qx));
97 mardyn_assert(std::isfinite(m_qy));
98 mardyn_assert(std::isfinite(m_qz));
102 double m_qw, m_qx, m_qy, m_qz;
Definition: Quaternion.h:10
std::array< double, 3 > rotate(const std::array< double, 3 > &d) const
Definition: Quaternion.cpp:43
void rotateInPlace(std::array< double, 3 > &d) const
Definition: Quaternion.h:75