ParM  parm
A molecular dynamics library
Public Member Functions | Static Public Member Functions | Friends | List of all members
Vector3< T > Class Template Reference

A 3D physics vector, with methods for adding, subtracting, dot product, etc. More...

#include <vec.hpp>

Inheritance diagram for Vector3< T >:
NumVector< T, 3 > NVector< T, N >

Public Member Functions

 Vector3 ()
 
 Vector3 (const T a, const T b, const T c)
 
 Vector3 (const NumVector< T, 3 > rhs)
 
 Vector3 (const NVector< T, 3 > rhs)
 
const T getx () const
 
const T gety () const
 
const T getz () const
 
double getxd () const
 Return x as a double. Useful with some versions of Python and long doubles. More...
 
double getyd () const
 
double getzd () const
 
void setx (const T a)
 
void sety (const T b)
 
void setz (const T c)
 
void setxd (const double a)
 Set x with a double. Useful with some versions of Python and long doubles. More...
 
void setyd (const double b)
 
void setzd (const double c)
 
void set (const T a, const T b, const T c)
 
Vector3 operator- () const
 
Vector3 operator+ (const Vector3 &rhs) const
 
Vector3 operator- (const Vector3 &rhs) const
 
operator* (const Vector3 &rhs) const
 
template<class U >
Vector3 operator* (const U rhs) const
 
template<class U >
Vector3 operator/ (const U rhs) const
 
Vector3 cross (const Vector3 &rhs) const
 Cross product, \(\vec r \times \vec s \). More...
 
Vector3 norm () const
 
Vector3operator-= (const Vector3 &rhs)
 
Vector3operator+= (const Vector3 &rhs)
 
template<class U >
Vector3operator*= (const U rhs)
 
template<class U >
Vector3operator/= (const U rhs)
 
 ~Vector3 ()
 
template<class U >
Vector3< T > & operator*= (const U rhs)
 
template<class U >
Vector3< T > & operator/= (const U rhs)
 
- Public Member Functions inherited from NumVector< T, 3 >
 NumVector ()
 
 NumVector (const NVector< T, N > &rhs)
 
 NumVector (const T rhs[N])
 
dot (const NumVector &other) const
 Inner product. More...
 
sq () const
 
mag () const
 The square of the vector, \(\vec r^2 \). More...
 
distance (const NumVector &rhs) const
 The magnitude of the vector, \( \left| \vec r \right| \). More...
 
NumVector perpto (const NumVector &other) const
 
void normalize ()
 Normalize in place. More...
 
NumVector norm () const
 Return the normalized version. More...
 
 ~NumVector ()
 
- Public Member Functions inherited from NVector< T, N >
 NVector ()
 
 NVector (const NVector &rhs)
 
template<class U >
 NVector (const NVector< U, N > &rhs)
 
 NVector (const T locs[N])
 
const T & get (const unsigned int n) const
 
void set (const unsigned int n, const T a)
 
unsigned int len () const
 
NVectoroperator+= (const NVector &rhs)
 
NVectoroperator-= (const NVector &rhs)
 
template<class U >
NVectoroperator*= (const U rhs)
 
template<class U >
NVectoroperator/= (const U rhs)
 
NVector operator- () const
 
NVector operator+ (const NVector &rhs) const
 
NVector operator- (const NVector &rhs) const
 
T & operator[] (const unsigned int i)
 
const T & operator[] (const unsigned int i) const
 
template<class U >
NVector operator* (const U rhs) const
 Multiplication by a scalar. More...
 
template<class U >
NVector operator/ (const U rhs) const
 Division by a scalar. More...
 
T * begin ()
 
T * end ()
 
 ~NVector ()
 
template<class U >
NVector< T, N > & operator*= (const U rhs)
 
template<class U >
NVector< T, N > & operator/= (const U rhs)
 

Static Public Member Functions

static T angle (const Vector3 &dx1, const Vector3 &dx2)
 The angle between two vectors, assuming they start at the same point (i.e. the origin). More...
 
static T angle (const Vector3 &x1, const Vector3 &x2, const Vector3 &x3)
 The angle between three points. More...
 
static T Dihedral (const Vector3 &dx1, const Vector3 &dx2, const Vector3 &dx3)
 The Dihedral angle between three vectors: More...
 
static T Dihedral (const Vector3 &x1, const Vector3 &x2, const Vector3 &x3, const Vector3 &x4)
 The Dihedral angle between four points. More...
 

Friends

template<class U >
ostream & operator<< (ostream &out, const Vector3< U > v)
 

Additional Inherited Members

- Public Types inherited from NVector< T, N >
typedef T * iterator
 
- Protected Attributes inherited from NVector< T, N >
vals [N]
 

Detailed Description

template<class T>
class Vector3< T >

A 3D physics vector, with methods for adding, subtracting, dot product, etc.

This is aliased as Vec when compiled with NDIM=3.

Template Parameters
Ta numerical type, as as float or double.

Constructor & Destructor Documentation

template<class T>
Vector3< T >::Vector3 ( )
inline
template<class T>
Vector3< T >::Vector3 ( const T  a,
const T  b,
const T  c 
)
inline
template<class T>
Vector3< T >::Vector3 ( const NumVector< T, 3 >  rhs)
inline
template<class T>
Vector3< T >::Vector3 ( const NVector< T, 3 >  rhs)
inline
template<class T>
Vector3< T >::~Vector3 ( )
inline

Member Function Documentation

template<class T>
static T Vector3< T >::angle ( const Vector3< T > &  dx1,
const Vector3< T > &  dx2 
)
inlinestatic

The angle between two vectors, assuming they start at the same point (i.e. the origin).

Equal to \(\theta = \arccos \left(\frac{\vec x_1 \cdot \vec x_2}{\left| \vec x_1 \right| \left| \vec x_2 \right|}\right) \)

Parameters
dx1\(\vec x_1 \)
dx2\(\vec x_2 \)
template<class T>
static T Vector3< T >::angle ( const Vector3< T > &  x1,
const Vector3< T > &  x2,
const Vector3< T > &  x3 
)
inlinestatic

The angle between three points.

Equivalent to angle(x1 - x2, x3 - x2).

Parameters
x1The first point.
x2The middle point, around which we are finding the angle.
x3The third point.
template<class T >
Vector3< T > Vector3< T >::cross ( const Vector3< T > &  rhs) const

Cross product, \(\vec r \times \vec s \).

template<class T>
static T Vector3< T >::Dihedral ( const Vector3< T > &  dx1,
const Vector3< T > &  dx2,
const Vector3< T > &  dx3 
)
inlinestatic

The Dihedral angle between three vectors:

\( \phi=\operatorname{arctan2}\left( \vec{r}_{1}\cdot\left(\vec{r}_{2}\times \vec{r}_{3}\right)\left|\vec{r}_{2}\right|, \left(\vec{r}_{1}\times\vec{r}_{2}\right)\cdot \left(\vec{r}_{2}\times\vec{r}_{3}\right) \right) \)

Parameters
dx1\(\vec r_1\)
dx2\(\vec r_2\)
dx3\(\vec r_3\)
template<class T>
static T Vector3< T >::Dihedral ( const Vector3< T > &  x1,
const Vector3< T > &  x2,
const Vector3< T > &  x3,
const Vector3< T > &  x4 
)
inlinestatic

The Dihedral angle between four points.

Equivalent to Dihedral(x2 - x1, x3 - x2, x4 - x3).

template<class T>
const T Vector3< T >::getx ( ) const
inline
template<class T>
double Vector3< T >::getxd ( ) const
inline

Return x as a double. Useful with some versions of Python and long doubles.

template<class T>
const T Vector3< T >::gety ( ) const
inline
template<class T>
double Vector3< T >::getyd ( ) const
inline
template<class T>
const T Vector3< T >::getz ( ) const
inline
template<class T>
double Vector3< T >::getzd ( ) const
inline
template<class T>
Vector3 Vector3< T >::norm ( ) const
inline
template<class T>
T Vector3< T >::operator* ( const Vector3< T > &  rhs) const
inline
template<class T>
template<class U >
Vector3 Vector3< T >::operator* ( const U  rhs) const
inline
template<class T>
template<class U >
Vector3& Vector3< T >::operator*= ( const U  rhs)
template<class T>
template<class U >
Vector3<T>& Vector3< T >::operator*= ( const U  rhs)
template<class T>
Vector3 Vector3< T >::operator+ ( const Vector3< T > &  rhs) const
inline
template<class T>
Vector3& Vector3< T >::operator+= ( const Vector3< T > &  rhs)
inline
template<class T>
Vector3 Vector3< T >::operator- ( ) const
inline
template<class T>
Vector3 Vector3< T >::operator- ( const Vector3< T > &  rhs) const
inline
template<class T>
Vector3& Vector3< T >::operator-= ( const Vector3< T > &  rhs)
inline
template<class T>
template<class U >
Vector3 Vector3< T >::operator/ ( const U  rhs) const
inline
template<class T>
template<class U >
Vector3& Vector3< T >::operator/= ( const U  rhs)
template<class T>
template<class U >
Vector3<T>& Vector3< T >::operator/= ( const U  rhs)
template<class T>
void Vector3< T >::set ( const T  a,
const T  b,
const T  c 
)
inline
template<class T>
void Vector3< T >::setx ( const T  a)
inline
template<class T>
void Vector3< T >::setxd ( const double  a)
inline

Set x with a double. Useful with some versions of Python and long doubles.

template<class T>
void Vector3< T >::sety ( const T  b)
inline
template<class T>
void Vector3< T >::setyd ( const double  b)
inline
template<class T>
void Vector3< T >::setz ( const T  c)
inline
template<class T>
void Vector3< T >::setzd ( const double  c)
inline

Friends And Related Function Documentation

template<class T>
template<class U >
ostream& operator<< ( ostream &  out,
const Vector3< U >  v 
)
friend

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