Collective Variables Module - Developer Documentation
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
colvarmodule::quaternion Class Reference

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::realoperator[] (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.
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


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)

Detailed Description

1-dimensional vector of real numbers with four components and a quaternion algebra

Member Function Documentation

◆ dist2_grad()

cvm::quaternion colvarmodule::quaternion::dist2_grad ( cvm::quaternion const &  Q2) const

Gradient of the square distance: returns a 4-vector equivalent to that provided by slerp

◆ set_from_euler_angles()

void colvarmodule::quaternion::set_from_euler_angles ( cvm::real  phi_in,
cvm::real  theta_in,
cvm::real  psi_in 

The documentation for this class was generated from the following files: