OpenMD 3.1
Molecular Dynamics in the Open
|
Quaternion is a sort of a higher-level complex number. More...
#include "math/Quaternion.hpp"
Public Member Functions | |
Quaternion (Real w, Real x, Real y, Real z) | |
Constructs and initializes a Quaternion from w, x, y, z values. | |
Quaternion (const Vector< Real, 4 > &v) | |
Constructs and initializes a Quaternion from a Vector<Real,4> | |
Quaternion & | operator= (const Vector< Real, 4 > &v) |
copy assignment | |
Real | w () const |
Returns the value of the first element of this quaternion. | |
Real & | w () |
Returns the reference of the first element of this quaternion. | |
Real | x () const |
Returns the value of the first element of this quaternion. | |
Real & | x () |
Returns the reference of the second element of this quaternion. | |
Real | y () const |
Returns the value of the thirf element of this quaternion. | |
Real & | y () |
Returns the reference of the third element of this quaternion. | |
Real | z () const |
Returns the value of the fourth element of this quaternion. | |
Real & | z () |
Returns the reference of the fourth element of this quaternion. | |
bool | operator== (const Quaternion< Real > &q) |
Tests if this quaternion is equal to other quaternion. | |
Quaternion< Real > | inverse () |
Returns the inverse of this quaternion. | |
void | mul (const Quaternion< Real > &q) |
Sets the value to the multiplication of itself and another quaternion. | |
void | mul (const Real &s) |
void | div (Quaternion< Real > &q) |
Set the value of this quaternion to the division of itself by another quaternion. | |
void | div (const Real &s) |
Quaternion< Real > & | operator*= (const Quaternion< Real > &q) |
Quaternion< Real > & | operator*= (const Real &s) |
Quaternion< Real > & | operator/= (Quaternion< Real > &q) |
Quaternion< Real > & | operator/= (const Real &s) |
Quaternion< Real > | conjugate () const |
Returns the conjugate quaternion of this quaternion. | |
Real | get_rotation_angle () const |
return rotation angle from -PI to PI | |
Quaternion< Real > | fromAxisAngle (const Vector3< Real > &axis, const Real &angle) |
create a unit quaternion from axis angle representation | |
void | toAxisAngle (Vector3< Real > &axis, Real &angle) const |
convert a quaternion to axis angle representation, preserve the axis direction and angle from -PI to +PI | |
Quaternion< Real > | fromShortestArc (const Vector3d &from, const Vector3d &to) |
shortest arc quaternion rotate one vector to another by shortest path. | |
Real | ComputeTwist (const Quaternion &q) |
void | RemoveTwist (Quaternion &q) |
void | getTwistSwingAxisAngle (Real &twistAngle, Real &swingAngle, Vector3< Real > &swingAxis) |
Vector3< Real > | rotate (const Vector3< Real > &v) |
Quaternion< Real > & | align (const Vector3< Real > &V1, const Vector3< Real > &V2) |
void | toTwistSwing (Real &tw, Real &sx, Real &sy) |
void | toSwingTwist (Real &sx, Real &sy, Real &tw) |
SquareMatrix< Real, 3 > | toRotationMatrix3 () |
Returns the corresponding rotation matrix (3x3) | |
Public Member Functions inherited from OpenMD::Vector< Real, 4 > | |
Vector () | |
default constructor | |
Vector (const Vector< Real, Dim > &v) | |
Constructs and initializes a Vector from a vector. | |
Vector (const Real &s) | |
Vector (Real *v) | |
Constructs and initializes a Vector from an array. | |
Vector< Real, Dim > & | operator= (const Vector< Real, Dim > &v) |
copy assignment operator | |
Vector< Real, Dim > & | operator= (const Real *v) |
array assignment operator | |
Real & | operator[] (unsigned int i) |
Returns reference of ith element. | |
const Real & | operator[] (unsigned int i) const |
Returns constant reference of ith element. | |
Real & | operator() (unsigned int i) |
Returns reference of ith element. | |
const Real & | operator() (unsigned int i) const |
Returns constant reference of ith element. | |
void | getArray (Real *array) |
Copy the internal data to an array. | |
Real * | getArrayPointer () |
Returns the pointer of internal array. | |
bool | operator== (const Vector< Real, Dim > &v) |
Tests if this vetor is equal to other vector. | |
bool | operator!= (const Vector< Real, Dim > &v) |
Tests if this vetor is not equal to other vector. | |
void | zero () |
Zeros out the values in this vector in place. | |
void | negate () |
Negates the value of this vector in place. | |
void | negate (const Vector< Real, Dim > &v1) |
Sets the value of this vector to the negation of vector v1. | |
void | add (const Vector< Real, Dim > &v1) |
Sets the value of this vector to the sum of itself and v1 (*this += v1). | |
void | add (const Vector< Real, Dim > &v1, const Vector< Real, Dim > &v2) |
Sets the value of this vector to the sum of v1 and v2 (*this = v1 + v2). | |
void | sub (const Vector< Real, Dim > &v1) |
Sets the value of this vector to the difference of itself and v1 (*this -= v1). | |
void | sub (const Vector< Real, Dim > &v1, const Vector &v2) |
Sets the value of this vector to the difference of vector v1 and v2 (*this = v1 - v2). | |
void | mul (Real s) |
Sets the value of this vector to the scalar multiplication of itself (*this *= s). | |
void | mul (const Vector< Real, Dim > &v1, Real s) |
Sets the value of this vector to the scalar multiplication of vector v1 (*this = s * v1). | |
void | Vmul (const Vector< Real, Dim > &v1, const Vector< Real, Dim > &v2) |
Sets the elements of this vector to the multiplication of elements of two other vectors. | |
Vector< Real, Dim > & | abs () |
Real | max () |
void | div (Real s) |
Sets the value of this vector to the scalar division of itself (*this /= s ). | |
void | div (const Vector< Real, Dim > &v1, Real s) |
Sets the value of this vector to the scalar division of vector v1 (*this = v1 / s ). | |
void | Vdiv (const Vector< Real, Dim > &v1, const Vector< Real, Dim > &v2) |
Sets the elements of this vector to the division of elements of two other vectors. | |
Vector< Real, Dim > & | operator+= (const Vector< Real, Dim > &v1) |
Vector< Real, Dim > & | operator-= (const Vector< Real, Dim > &v1) |
Vector< Real, Dim > & | operator*= (Real s) |
Vector< Real, Dim > & | operator/= (Real s) |
Real | sum () |
Returns the sum of all elements of this vector. | |
Real | componentProduct () |
Returns the product of all elements of this vector. | |
Real | length () |
Returns the length of this vector. | |
Real | lengthSquare () |
Returns the squared length of this vector. | |
void | normalize () |
Normalizes this vector in place. | |
bool | isNormalized () |
Tests if this vector is normalized. | |
unsigned int | size () const |
Additional Inherited Members | |
Public Types inherited from OpenMD::Vector< Real, 4 > | |
using | ElemType |
using | ElemPoinerType |
Protected Attributes inherited from OpenMD::Vector< Real, 4 > | |
Real | data_ [Dim] |
Quaternion is a sort of a higher-level complex number.
It is defined as \(Q = w + x*i + y*j + z*k\), where w, x, y, and z are numbers of type T (e.g. RealType), and \(i*i = -1\); \(j*j = -1\); \(k*k = -1\); \(i*j = k\); \(j*k = i\); \(k*i = j\);
Definition at line 76 of file Quaternion.hpp.
|
inline |
Definition at line 78 of file Quaternion.hpp.
|
inline |
Constructs and initializes a Quaternion from w, x, y, z values.
Definition at line 81 of file Quaternion.hpp.
References OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Quaternion< Real >::y(), and OpenMD::Quaternion< Real >::z().
|
inline |
Constructs and initializes a Quaternion from a Vector<Real,4>
Definition at line 89 of file Quaternion.hpp.
|
inline |
Definition at line 360 of file Quaternion.hpp.
|
inline |
Definition at line 312 of file Quaternion.hpp.
|
inline |
Returns the conjugate quaternion of this quaternion.
Definition at line 236 of file Quaternion.hpp.
References OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Quaternion< Real >::y(), and OpenMD::Quaternion< Real >::z().
|
inline |
Definition at line 206 of file Quaternion.hpp.
|
inline |
Set the value of this quaternion to the division of itself by another quaternion.
Definition at line 204 of file Quaternion.hpp.
References OpenMD::Quaternion< Real >::inverse(), and OpenMD::Quaternion< Real >::mul().
|
inline |
create a unit quaternion from axis angle representation
Definition at line 253 of file Quaternion.hpp.
References OpenMD::Vector< Real, Dim >::normalize(), OpenMD::Vector3< Real >::x(), OpenMD::Vector3< Real >::y(), and OpenMD::Vector3< Real >::z().
|
inline |
shortest arc quaternion rotate one vector to another by shortest path.
create rotation from -> to, for any length vectors.
Definition at line 290 of file Quaternion.hpp.
References OpenMD::cross(), OpenMD::dot(), OpenMD::Vector< Real, 4 >::normalize(), OpenMD::Quaternion< Real >::w(), OpenMD::Vector3< Real >::x(), OpenMD::Vector3< Real >::y(), and OpenMD::Vector3< Real >::z().
|
inline |
return rotation angle from -PI to PI
Definition at line 243 of file Quaternion.hpp.
References OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Quaternion< Real >::y(), and OpenMD::Quaternion< Real >::z().
|
inline |
Definition at line 323 of file Quaternion.hpp.
|
inline |
Returns the inverse of this quaternion.
Definition at line 166 of file Quaternion.hpp.
References OpenMD::Vector< Real, 4 >::lengthSquare(), OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Quaternion< Real >::y(), and OpenMD::Quaternion< Real >::z().
Referenced by OpenMD::Quaternion< Real >::div(), OpenMD::operator/(), and OpenMD::operator/().
|
inline |
Sets the value to the multiplication of itself and another quaternion.
q | the other quaternion |
Definition at line 182 of file Quaternion.hpp.
Referenced by OpenMD::Quaternion< Real >::div(), OpenMD::operator*(), and OpenMD::operator*().
|
inline |
Definition at line 195 of file Quaternion.hpp.
|
inline |
Definition at line 213 of file Quaternion.hpp.
|
inline |
Definition at line 218 of file Quaternion.hpp.
|
inline |
Definition at line 228 of file Quaternion.hpp.
|
inline |
Definition at line 223 of file Quaternion.hpp.
|
inline |
copy assignment
Definition at line 92 of file Quaternion.hpp.
References OpenMD::Vector< Real, Dim >::operator=().
|
inline |
Tests if this quaternion is equal to other quaternion.
q | quaternion to be compared |
Definition at line 152 of file Quaternion.hpp.
References OpenMD::equal().
|
inline |
Definition at line 316 of file Quaternion.hpp.
|
inline |
Definition at line 347 of file Quaternion.hpp.
|
inline |
convert a quaternion to axis angle representation, preserve the axis direction and angle from -PI to +PI
Definition at line 268 of file Quaternion.hpp.
References OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Vector3< Real >::x(), OpenMD::Quaternion< Real >::y(), OpenMD::Vector3< Real >::y(), OpenMD::Quaternion< Real >::z(), and OpenMD::Vector3< Real >::z().
|
inline |
Returns the corresponding rotation matrix (3x3)
Definition at line 522 of file Quaternion.hpp.
References OpenMD::Vector< Real, 4 >::isNormalized(), OpenMD::Vector< Real, 4 >::normalize(), OpenMD::Quaternion< Real >::w(), OpenMD::Quaternion< Real >::x(), OpenMD::Quaternion< Real >::y(), and OpenMD::Quaternion< Real >::z().
Referenced by OpenMD::SquareMatrix3< Real >::setupRotMat().
|
inline |
Definition at line 482 of file Quaternion.hpp.
|
inline |
Definition at line 418 of file Quaternion.hpp.
|
inline |
Returns the reference of the first element of this quaternion.
Definition at line 110 of file Quaternion.hpp.
|
inline |
Returns the value of the first element of this quaternion.
Definition at line 104 of file Quaternion.hpp.
Referenced by OpenMD::Quaternion< Real >::conjugate(), OpenMD::Quaternion< Real >::fromShortestArc(), OpenMD::Quaternion< Real >::get_rotation_angle(), OpenMD::Quaternion< Real >::inverse(), OpenMD::Quaternion< Real >::Quaternion(), OpenMD::SquareMatrix3< Real >::setupRotMat(), OpenMD::Quaternion< Real >::toAxisAngle(), and OpenMD::Quaternion< Real >::toRotationMatrix3().
|
inline |
Returns the reference of the second element of this quaternion.
Definition at line 122 of file Quaternion.hpp.
|
inline |
Returns the value of the first element of this quaternion.
Definition at line 116 of file Quaternion.hpp.
Referenced by OpenMD::Quaternion< Real >::conjugate(), OpenMD::Quaternion< Real >::get_rotation_angle(), OpenMD::Quaternion< Real >::inverse(), OpenMD::Quaternion< Real >::Quaternion(), OpenMD::SquareMatrix3< Real >::setupRotMat(), OpenMD::Quaternion< Real >::toAxisAngle(), and OpenMD::Quaternion< Real >::toRotationMatrix3().
|
inline |
Returns the reference of the third element of this quaternion.
Definition at line 134 of file Quaternion.hpp.
|
inline |
Returns the value of the thirf element of this quaternion.
Definition at line 128 of file Quaternion.hpp.
Referenced by OpenMD::Quaternion< Real >::conjugate(), OpenMD::Quaternion< Real >::get_rotation_angle(), OpenMD::Quaternion< Real >::inverse(), OpenMD::Quaternion< Real >::Quaternion(), OpenMD::SquareMatrix3< Real >::setupRotMat(), OpenMD::Quaternion< Real >::toAxisAngle(), and OpenMD::Quaternion< Real >::toRotationMatrix3().
|
inline |
Returns the reference of the fourth element of this quaternion.
Definition at line 145 of file Quaternion.hpp.
|
inline |
Returns the value of the fourth element of this quaternion.
Definition at line 140 of file Quaternion.hpp.
Referenced by OpenMD::Quaternion< Real >::conjugate(), OpenMD::Quaternion< Real >::get_rotation_angle(), OpenMD::Quaternion< Real >::inverse(), OpenMD::Quaternion< Real >::Quaternion(), OpenMD::SquareMatrix3< Real >::setupRotMat(), OpenMD::Quaternion< Real >::toAxisAngle(), and OpenMD::Quaternion< Real >::toRotationMatrix3().