Collective Variables Module - Developer Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 const &x, cvm::real const &y, cvm::real const &z)
 Constructor from a 3-d vector.
 
 quaternion (cvm::real const qv[4])
 Constructor component by component.
 
 quaternion (cvm::real const &q0i, cvm::real const &q1i, cvm::real const &q2i, cvm::real const &q3i)
 Constructor component by component.
 
 quaternion (cvm::vector1d< cvm::real > const &v)
 
void set_from_euler_angles (cvm::real const &phi_in, cvm::real const &theta_in, cvm::real const &psi_in)
 
 quaternion ()
 Default constructor.
 
void set (cvm::real const &value=0.0)
 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 const &i)
 Access the quaternion as a 4-d array (return a reference)
 
cvm::real operator[] (int const &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 const &a)
 
void operator/= (cvm::real const &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 const &real_width)
 Tell the number of characters required to print a quaternion, given that of a real number.
 
static cvm::quaternion promote (cvm::rvector const &v)
 Promote a 3-vector to a quaternion.
 

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: More...
 
cvm::quaternion operator* (cvm::real const &c, cvm::quaternion const &q)
 
cvm::quaternion operator* (cvm::quaternion const &q, cvm::real const &c)
 
cvm::quaternion operator/ (cvm::quaternion const &q, cvm::real const &c)
 

Detailed Description

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

Member Function Documentation

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

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

void colvarmodule::quaternion::set_from_euler_angles ( cvm::real const &  phi_in,
cvm::real const &  theta_in,
cvm::real const &  psi_in 
)
inline

Friends And Related Function Documentation

cvm::quaternion operator* ( cvm::quaternion const &  h,
cvm::quaternion const &  q 
)
friend

Provides the quaternion product. NOTE: for the inner product use:

h.inner (q);

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