31 #ifndef MECURYDPM_QUATERNION_H
32 #define MECURYDPM_QUATERNION_H
115 return q0 == 1.0 &&
q1 == 0.0 &&
q2 == 0.0 &&
q3 == 0.0;
double Mdouble
Definition: GeneralDefine.h:34
@ A
Definition: StatisticsVector.h:42
Implementation of a 3D symmetric matrix.
Definition: MatrixSymmetric.h:37
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
Quaternion operator/(Mdouble a) const
Divides by a scalar.
Definition: Quaternion.cc:96
void setEuler(const Vec3D &e)
Convert Euler angles to a quaternion. See Wikipedia for details.
Definition: Quaternion.cc:473
void setLength(Mdouble length)
Make this Quaternion a certain length |q|=length.
Definition: Quaternion.cc:176
Quaternion & operator*=(Mdouble a)
Multiplies *this by a scalar.
Definition: Quaternion.cc:134
Mdouble getLength() const
Calculates the length of this Quaternion: .
Definition: Quaternion.cc:299
void setUnity()
Sets quaternion value to (1,0,0,0)
Definition: Quaternion.cc:53
Quaternion & operator/=(Mdouble a)
Divides by a scalar.
Definition: Quaternion.cc:148
Mdouble getAngleZ() const
Converts a quaternion to the rotation angle in the XY plane (for Mercury2D). See Wikipedia for detail...
Definition: Quaternion.cc:487
friend std::ostream & operator<<(std::ostream &os, const Quaternion &a)
Adds elements to an output stream.
Definition: Quaternion.cc:340
bool isEqualTo(const Quaternion &other, double tol) const
Checks if the length this Quaternion is equal the length of other with a certain tolerance.
Definition: Quaternion.cc:290
void rotate(Vec3D &position) const
Definition: Quaternion.cc:563
Quaternion & operator+=(const Quaternion &a)
Adds another quaternion.
Definition: Quaternion.cc:106
Quaternion operator+(const Quaternion &a) const
Adds another quaternion and returns the result.
Definition: Quaternion.cc:66
Vec3D getEuler() const
Convert a quaternion to Euler angles. See Wikipedia for details.
Definition: Quaternion.cc:452
static Quaternion getUnitQuaternion(const Quaternion &a)
Returns a unit Quaternion based on a.
Definition: Quaternion.cc:324
static Mdouble getDistanceSquared(const Quaternion &a, const Quaternion &b)
Calculates the squared distance between two Quaternion: .
Definition: Quaternion.cc:201
Quaternion operator-(const Quaternion &a) const
Subtracts another quaternion and returns the result.
Definition: Quaternion.cc:76
Vec3D getAxis() const
Converts the quaternions into a normal vector by rotating the vector x=(1,0,0); see See Wiki for deta...
Definition: Quaternion.cc:501
Quaternion & operator-=(const Quaternion &a)
Subtracts another quaternion.
Definition: Quaternion.cc:120
Mdouble getComponent(int index) const
Returns the requested component of this Quaternion.
Definition: Quaternion.cc:232
Quaternion(Vec3D normal)
Definition: Quaternion.h:97
Mdouble q1
the first component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:73
Quaternion angularVelocityBodyFixedFrameToAngularDisplacement(Vec3D v) const
Definition: Quaternion.cc:411
void setAngleZ(Mdouble psi)
Converts the rotation angle in the XY plane into a quaternion (for Mercury2D). See Wikipedia for deta...
Definition: Quaternion.cc:492
Mdouble q3
the third component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:81
Mdouble q2
the second component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:77
void rotateTensor(SmallMatrix< 3, 3 > I) const
Definition: Quaternion.cc:690
MatrixSymmetric3D rotateInverseInertiaTensor(const MatrixSymmetric3D &invI) const
Converts the inverse inertia tensor from the reference frame to the lab frame; see See QuaternionsWou...
Definition: Quaternion.cc:662
void normalise()
Makes this Quaternion unit length |q|=1.
Definition: Quaternion.cc:161
Quaternion()
Constructor; sets quaternion value to (1,0,0,0)
Definition: Quaternion.cc:30
Quaternion operator*(Mdouble a) const
Multiplies by a scalar.
Definition: Quaternion.cc:86
void rotateBack(Vec3D &position) const
Definition: Quaternion.cc:610
void updateAngularDisplacement(Vec3D angularVelocityDt)
Definition: Quaternion.cc:431
void setOrientationViaNormal(Vec3D normal)
Definition: Quaternion.cc:536
Vec3D applyCInverse(Quaternion q) const
Converts quaternion rate of change into an angular momentum omega.
Definition: Quaternion.cc:441
friend std::istream & operator>>(std::istream &is, Quaternion &a)
Adds elements to an input stream.
Definition: Quaternion.cc:353
Quaternion angularDisplacementTimeDerivative(Vec3D v) const
Converts an angular momentum v=omega into a quaternion rate of change, q(t+dt)-q(t)/dt.
Definition: Quaternion.cc:422
void setComponent(int index, double val)
Sets the requested component of this Quaternion to the requested value.
Definition: Quaternion.cc:258
static Mdouble getDistance(const Quaternion &a, const Quaternion &b)
Calculates the distance between two Quaternion: .
Definition: Quaternion.cc:188
Mdouble q0
the zeroth component of the quaternion q = (q0,q1,q2,q3)
Definition: Quaternion.h:69
void getRotationMatrix(SmallMatrix< 3, 3 > &A) const
Definition: Quaternion.cc:508
Mdouble getLengthSquared() const
Calculates the squared length of this Quaternion: .
Definition: Quaternion.cc:222
bool isUnity() const
Checks if the quaternion value is (1,0,0,0)
Definition: Quaternion.h:113
Data type for small dense matrix.
Definition: SmallMatrix.h:68
Definition: SmallVector.h:62