Collective Variables Module - Developer Documentation
|
1-dimensional vector of real numbers with four components and a quaternion algebra More...
#include <colvartypes.h>
Public Member Functions | |
quaternion (cvm::real x, cvm::real y, cvm::real z) | |
Constructor from a 3-d vector. | |
quaternion (cvm::real const qv[4]) | |
Constructor component by component. | |
quaternion (cvm::real q0i, cvm::real q1i, cvm::real q2i, cvm::real q3i) | |
Constructor component by component. | |
quaternion (cvm::vector1d< cvm::real > const &v) | |
void | set_from_euler_angles (cvm::real phi_in, cvm::real theta_in, cvm::real psi_in) |
quaternion () | |
Default constructor. | |
void | set (cvm::real value) |
Set all components to a scalar. | |
void | reset () |
Set all components to zero (null quaternion) | |
void | reset_rotation () |
Set the q0 component to 1 and the others to 0 (quaternion representing no rotation) | |
std::string | to_simple_string () const |
int | from_simple_string (std::string const &s) |
cvm::real & | operator[] (int i) |
Access the quaternion as a 4-d array (return a reference) | |
cvm::real | operator[] (int i) const |
Access the quaternion as a 4-d array (return a value) | |
cvm::vector1d< cvm::real > const | as_vector () const |
cvm::real | norm2 () const |
Square norm of the quaternion. | |
cvm::real | norm () const |
Norm of the quaternion. | |
cvm::quaternion | conjugate () const |
Return the conjugate quaternion. | |
void | operator*= (cvm::real a) |
void | operator/= (cvm::real a) |
void | set_positive () |
void | operator+= (cvm::quaternion const &h) |
void | operator-= (cvm::quaternion const &h) |
cvm::rvector | get_vector () const |
Return the vector component. | |
cvm::rvector | rotate (cvm::rvector const &v) const |
Rotate v through this quaternion (put it in the rotated reference frame) | |
cvm::quaternion | rotate (cvm::quaternion const &Q2) const |
Rotate Q2 through this quaternion (put it in the rotated reference frame) | |
cvm::rmatrix | rotation_matrix () const |
Return the 3x3 matrix associated to this quaternion. | |
cvm::quaternion | position_derivative_inner (cvm::rvector const &pos, cvm::rvector const &vec) const |
Multiply the given vector by the derivative of the given (rotated) position with respect to the quaternion. More... | |
cvm::real | cosine (cvm::quaternion const &q) const |
Return the cosine between the orientation frame associated to this quaternion and another. | |
cvm::real | dist2 (cvm::quaternion const &Q2) const |
Square distance from another quaternion on the 4-dimensional unit sphere: returns the square of the angle along the shorter of the two geodesics. | |
cvm::quaternion | dist2_grad (cvm::quaternion const &Q2) const |
void | match (cvm::quaternion &Q2) const |
Choose the closest between Q2 and -Q2 and save it back. Not required for dist2() and dist2_grad() | |
cvm::real | inner (cvm::quaternion const &Q2) const |
Inner product (as a 4-d vector) with Q2; requires match() if the largest overlap is looked for. | |
Static Public Member Functions | |
static size_t | output_width (size_t real_width) |
Tell the number of characters required to print a quaternion, given that of a real number. | |
Public Attributes | |
cvm::real | q0 |
cvm::real | q1 |
cvm::real | q2 |
cvm::real | q3 |
Friends | |
std::ostream & | operator<< (std::ostream &os, cvm::quaternion const &q) |
Formatted output operator. | |
std::istream & | operator>> (std::istream &is, cvm::quaternion &q) |
Formatted input operator. | |
cvm::quaternion | operator+ (cvm::quaternion const &h, cvm::quaternion const &q) |
cvm::quaternion | operator- (cvm::quaternion const &h, cvm::quaternion const &q) |
cvm::quaternion | operator* (cvm::quaternion const &h, cvm::quaternion const &q) |
Provides the quaternion product. NOTE: for the inner product use: h.inner (q); | |
cvm::quaternion | operator* (cvm::real c, cvm::quaternion const &q) |
cvm::quaternion | operator* (cvm::quaternion const &q, cvm::real c) |
cvm::quaternion | operator/ (cvm::quaternion const &q, cvm::real c) |
1-dimensional vector of real numbers with four components and a quaternion algebra
|
inline |
Gradient of the square distance: returns a 4-vector equivalent to that provided by slerp
|
inline |
Multiply the given vector by the derivative of the given (rotated) position with respect to the quaternion.
pos | The position \(\mathbf{x}\). |
vec | The vector \(\mathbf{v}\). |
This function is mainly used for projecting the gradients or forces on the rotated atoms to the forces on quaternion. Assume this rotation can be represented as \(R(\mathbf{q})\), where \(\mathbf{q} := (q_0, q_1, q_2, q_3)\) is the current quaternion, the function returns the following new quaternion:
\[ \left(\mathbf{v}^\mathrm{T}\frac{\partial R(\mathbf{q})}{\partial q_0}\mathbf{x}, \mathbf{v}^\mathrm{T}\frac{\partial R(\mathbf{q})}{\partial q_1}\mathbf{x}, \mathbf{v}^\mathrm{T}\frac{\partial R(\mathbf{q})}{\partial q_2}\mathbf{x}, \mathbf{v}^\mathrm{T}\frac{\partial R(\mathbf{q})}{\partial q_3}\mathbf{x}\right) \]
where \(\mathbf{v}\) is usually the gradient of \(\xi\) with respect to the rotated frame \(\tilde{\mathbf{X}}\), \(\partial \xi / \partial \tilde{\mathbf{X}}\), or the force acting on it ( \(\mathbf{F}_{\tilde{\mathbf{X}}}\)). By using the following loop in pseudo C++ code, either \(\partial \xi / \partial \tilde{\mathbf{X}}\) or \(\mathbf{F}_{\tilde{\mathbf{X}}}\), can be projected to \(\partial \xi / \partial \mathbf{q}\) or \(\mathbf{F}_q\) into sum_dxdq
:
|
inline |
"Constructor" after Euler angles (in radians)
http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles