Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarmodule::quaternion Class Reference

\brief 1-dimensional vector of real numbers with four components and a quaternion algebra. More...

#include <colvartypes.h>

List of all members.

Public Methods

 quaternion (cvm::real x, cvm::real y, cvm::real z)
 Constructor from a 3-d vector. More...

 quaternion (cvm::real const qv[4])
 Constructor component by component. More...

 quaternion (cvm::real q0i, cvm::real q1i, cvm::real q2i, cvm::real q3i)
 Constructor component by component. More...

 quaternion (cvm::vector1d< cvm::real > const &v)
void set_from_euler_angles (cvm::real phi_in, cvm::real theta_in, cvm::real psi_in)
 "Constructor" after Euler angles (in radians) http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles. More...

 quaternion ()
 \brief Default constructor. More...

void set (cvm::real value)
 \brief Set all components to a scalar. More...

void reset ()
 \brief Set all components to zero (null quaternion). More...

void reset_rotation ()
 \brief Set the q0 component to 1 and the others to 0 (quaternion representing no rotation). More...

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). More...

cvm::real operator[] (int i) const
 Access the quaternion as a 4-d array (return a value). More...

cvm::vector1d< cvm::real
> const 
as_vector () const
cvm::real norm2 () const
 Square norm of the quaternion. More...

cvm::real norm () const
 Norm of the quaternion. More...

cvm::quaternion conjugate () const
 Return the conjugate quaternion. More...

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. More...

cvm::rvector rotate (cvm::rvector const &v) const
 \brief Rotate v through this quaternion (put it in the rotated reference frame). More...

cvm::quaternion rotate (cvm::quaternion const &Q2) const
 \brief Rotate Q2 through this quaternion (put it in the rotated reference frame). More...

cvm::rmatrix rotation_matrix () const
 Return the 3x3 matrix associated to this quaternion. More...

cvm::quaternion position_derivative_inner (cvm::rvector const &pos, cvm::rvector const &vec) const
 \brief 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
 \brief Return the cosine between the orientation frame associated to this quaternion and another. More...

cvm::real dist2 (cvm::quaternion const &Q2) const
 \brief Square distance from another quaternion on the 4-dimensional unit sphere: returns the square of the angle along the shorter of the two geodesics. More...

cvm::quaternion dist2_grad (cvm::quaternion const &Q2) const
 Gradient of the square distance: returns a 4-vector equivalent to that provided by slerp. More...

void match (cvm::quaternion &Q2) const
 \brief Choose the closest between Q2 and -Q2 and save it back. Not required for dist2() and dist2_grad(). More...

cvm::real inner (cvm::quaternion const &Q2) const
 \brief Inner product (as a 4-d vector) with Q2; requires match() if the largest overlap is looked for. More...


Static Public Methods

size_t output_width (size_t real_width)
 Tell the number of characters required to print a quaternion, given that of a real number. More...


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)
 \brief Formatted output operator. More...

std::istream & operator>> (std::istream &is, cvm::quaternion &q)
 \brief Formatted input operator. More...

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)
 \brief Provides the quaternion product. NOTE: for the inner product use: `h.inner (q);`. More...

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

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

Definition at line 937 of file colvartypes.h.


Constructor & Destructor Documentation

colvarmodule::quaternion::quaternion cvm::real    x,
cvm::real    y,
cvm::real    z
[inline]
 

Constructor from a 3-d vector.

Definition at line 944 of file colvartypes.h.

References z.

colvarmodule::quaternion::quaternion cvm::real const    qv[4] [inline]
 

Constructor component by component.

Definition at line 949 of file colvartypes.h.

colvarmodule::quaternion::quaternion cvm::real    q0i,
cvm::real    q1i,
cvm::real    q2i,
cvm::real    q3i
[inline]
 

Constructor component by component.

Definition at line 954 of file colvartypes.h.

colvarmodule::quaternion::quaternion cvm::vector1d< cvm::real > const &    v [inline]
 

Definition at line 961 of file colvartypes.h.

colvarmodule::quaternion::quaternion   [inline]
 

\brief Default constructor.

Definition at line 986 of file colvartypes.h.

References colvarmodule::reset.


Member Function Documentation

cvm::vector1d<cvm::real> const colvarmodule::quaternion::as_vector   const [inline]
 

Definition at line 1060 of file colvartypes.h.

References result.

cvm::quaternion colvarmodule::quaternion::conjugate   const [inline]
 

Return the conjugate quaternion.

Definition at line 1083 of file colvartypes.h.

cvm::real colvarmodule::quaternion::cosine cvm::quaternion const &    q const [inline]
 

\brief Return the cosine between the orientation frame associated to this quaternion and another.

Definition at line 1209 of file colvartypes.h.

cvm::real colvarmodule::quaternion::dist2 cvm::quaternion const &    Q2 const [inline]
 

\brief Square distance from another quaternion on the 4-dimensional unit sphere: returns the square of the angle along the shorter of the two geodesics.

Definition at line 1218 of file colvartypes.h.

References colvarmodule::acos, and PI.

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.

Definition at line 1235 of file colvartypes.h.

References colvarmodule::acos, colvarmodule::fabs, PI, and colvarmodule::sin.

int colvarmodule::quaternion::from_simple_string std::string const &    s
 

cvm::rvector colvarmodule::quaternion::get_vector   const [inline]
 

Return the vector component.

Definition at line 1117 of file colvartypes.h.

cvm::real colvarmodule::quaternion::inner cvm::quaternion const &    Q2 const [inline]
 

\brief Inner product (as a 4-d vector) with Q2; requires match() if the largest overlap is looked for.

Definition at line 1271 of file colvartypes.h.

void colvarmodule::quaternion::match cvm::quaternion &    Q2 const [inline]
 

\brief Choose the closest between Q2 and -Q2 and save it back. Not required for dist2() and dist2_grad().

Definition at line 1262 of file colvartypes.h.

cvm::real colvarmodule::quaternion::norm   const [inline]
 

Norm of the quaternion.

Definition at line 1077 of file colvartypes.h.

References colvarmodule::sqrt.

cvm::real colvarmodule::quaternion::norm2   const [inline]
 

Square norm of the quaternion.

Definition at line 1071 of file colvartypes.h.

void colvarmodule::quaternion::operator *= cvm::real    a [inline]
 

Definition at line 1088 of file colvartypes.h.

void colvarmodule::quaternion::operator+= cvm::quaternion const &    h [inline]
 

Definition at line 1107 of file colvartypes.h.

void colvarmodule::quaternion::operator-= cvm::quaternion const &    h [inline]
 

Definition at line 1111 of file colvartypes.h.

void colvarmodule::quaternion::operator/= cvm::real    a [inline]
 

Definition at line 1093 of file colvartypes.h.

cvm::real colvarmodule::quaternion::operator[] int    i const [inline]
 

Access the quaternion as a 4-d array (return a value).

Definition at line 1043 of file colvartypes.h.

References colvarmodule::error.

cvm::real& colvarmodule::quaternion::operator[] int    i [inline]
 

Access the quaternion as a 4-d array (return a reference).

Definition at line 1026 of file colvartypes.h.

References colvarmodule::error.

size_t colvarmodule::quaternion::output_width size_t    real_width [inline, static]
 

Tell the number of characters required to print a quaternion, given that of a real number.

Definition at line 1012 of file colvartypes.h.

cvm::quaternion colvarmodule::quaternion::position_derivative_inner cvm::rvector const &    pos,
cvm::rvector const &    vec
const
 

\brief Multiply the given vector by the derivative of the given (rotated) position with respect to the quaternion.

void colvarmodule::quaternion::reset   [inline]
 

\brief Set all components to zero (null quaternion).

Definition at line 998 of file colvartypes.h.

void colvarmodule::quaternion::reset_rotation   [inline]
 

\brief Set the q0 component to 1 and the others to 0 (quaternion representing no rotation).

Definition at line 1005 of file colvartypes.h.

cvm::quaternion colvarmodule::quaternion::rotate cvm::quaternion const &    Q2 const [inline]
 

\brief Rotate Q2 through this quaternion (put it in the rotated reference frame).

Definition at line 1173 of file colvartypes.h.

References rotate.

cvm::rvector colvarmodule::quaternion::rotate cvm::rvector const &    v const [inline]
 

\brief Rotate v through this quaternion (put it in the rotated reference frame).

Definition at line 1165 of file colvartypes.h.

cvm::rmatrix colvarmodule::quaternion::rotation_matrix   const [inline]
 

Return the 3x3 matrix associated to this quaternion.

Definition at line 1180 of file colvartypes.h.

void colvarmodule::quaternion::set cvm::real    value [inline]
 

\brief Set all components to a scalar.

Definition at line 992 of file colvartypes.h.

void colvarmodule::quaternion::set_from_euler_angles cvm::real    phi_in,
cvm::real    theta_in,
cvm::real    psi_in
[inline]
 

"Constructor" after Euler angles (in radians) http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles.

Definition at line 968 of file colvartypes.h.

References colvarmodule::cos, and colvarmodule::sin.

void colvarmodule::quaternion::set_positive   [inline]
 

Definition at line 1098 of file colvartypes.h.

std::string colvarmodule::quaternion::to_simple_string   const
 


Friends And Related Function Documentation

cvm::quaternion operator * cvm::quaternion const &    q,
cvm::real    c
[friend]
 

Definition at line 1151 of file colvartypes.h.

cvm::quaternion operator * cvm::real    c,
cvm::quaternion const &    q
[friend]
 

Definition at line 1146 of file colvartypes.h.

cvm::quaternion operator * cvm::quaternion const &    h,
cvm::quaternion const &    q
[friend]
 

\brief Provides the quaternion product. NOTE: for the inner product use: `h.inner (q);`.

Definition at line 1137 of file colvartypes.h.

cvm::quaternion operator+ cvm::quaternion const &    h,
cvm::quaternion const &    q
[friend]
 

Definition at line 1123 of file colvartypes.h.

cvm::quaternion operator- cvm::quaternion const &    h,
cvm::quaternion const &    q
[friend]
 

Definition at line 1129 of file colvartypes.h.

cvm::quaternion operator/ cvm::quaternion const &    q,
cvm::real    c
[friend]
 

Definition at line 1156 of file colvartypes.h.

std::ostream& operator<< std::ostream &    os,
cvm::quaternion const &    q
[friend]
 

\brief Formatted output operator.

std::istream& operator>> std::istream &    is,
cvm::quaternion &    q
[friend]
 

\brief Formatted input operator.


Member Data Documentation

cvm::real colvarmodule::quaternion::q0
 

Definition at line 941 of file colvartypes.h.

Referenced by operator<<, and operator>>.

cvm::real colvarmodule::quaternion::q1
 

Definition at line 941 of file colvartypes.h.

Referenced by operator<<, and operator>>.

cvm::real colvarmodule::quaternion::q2
 

Definition at line 941 of file colvartypes.h.

Referenced by operator<<, and operator>>.

cvm::real colvarmodule::quaternion::q3
 

Definition at line 941 of file colvartypes.h.

Referenced by operator<<, and operator>>.


The documentation for this class was generated from the following file:
Generated on Fri Nov 8 02:46:52 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002