BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Vec3< T > Class Template Reference

Description

template<class T>
class Vec3< T >

Three-dimensional vector class, templated on base type.

Base type T can be int, double, or complex<double>. The resulting classes shall be abbreviated I3, R3, C3.

Public Member Functions

 Vec3 ()
 Constructs the null vector. More...
 
 Vec3 (const T x_, const T y_, const T z_)
 Constructs a vector from cartesian components. More...
 
C3 complex () const
 Returns this, trivially converted to complex type. More...
 
Vec3< T > conj () const
 Returns complex conjugate vector. More...
 
double mag () const
 Returns magnitude of the vector. More...
 
double mag2 () const
 Returns magnitude squared of the vector. More...
 
double magxy () const
 Returns distance from z axis. More...
 
double magxy2 () const
 Returns squared distance from z axis. More...
 
bool operator!= (const Vec3< T > &other) const
 
Vec3< T > & operator+= (const Vec3< T > &v)
 Adds other vector to this, and returns result. More...
 
Vec3< T > & operator-= (const Vec3< T > &v)
 Subtracts other vector from this, and returns result. More...
 
bool operator== (const Vec3< T > &other) const
 
R3 real () const
 Returns real parts. More...
 
Vec3< T > rotatedY (double a) const
 Returns result of rotation around y-axis. More...
 
Vec3< T > rotatedZ (double a) const
 Returns result of rotation around z-axis. More...
 
void setX (const T &a)
 Sets x-component in cartesian coordinate system. More...
 
void setY (const T &a)
 Sets y-component in cartesian coordinate system. More...
 
void setZ (const T &a)
 Sets z-component in cartesian coordinate system. More...
 
Vec3< T > unit () const
 Returns unit vector in direction of this. Throws for null vector. More...
 
x () const
 Returns x-component in cartesian coordinate system. More...
 
y () const
 Returns y-component in cartesian coordinate system. More...
 
z () const
 Returns z-component in cartesian coordinate system. More...
 

Constructor & Destructor Documentation

◆ Vec3() [1/2]

template<class T >
Vec3< T >::Vec3 ( const T  x_,
const T  y_,
const T  z_ 
)

Constructs a vector from cartesian components.

◆ Vec3() [2/2]

template<class T >
Vec3< T >::Vec3 ( )

Constructs the null vector.

Member Function Documentation

◆ complex()

template<class T >
C3 Vec3< T >::complex ( ) const

Returns this, trivially converted to complex type.

◆ conj()

template<class T >
Vec3<T> Vec3< T >::conj ( ) const

Returns complex conjugate vector.

◆ mag()

template<class T >
double Vec3< T >::mag ( ) const

Returns magnitude of the vector.

◆ mag2()

template<class T >
double Vec3< T >::mag2 ( ) const

Returns magnitude squared of the vector.

◆ magxy()

template<class T >
double Vec3< T >::magxy ( ) const

Returns distance from z axis.

◆ magxy2()

template<class T >
double Vec3< T >::magxy2 ( ) const

Returns squared distance from z axis.

◆ operator!=()

template<class T >
bool Vec3< T >::operator!= ( const Vec3< T > &  other) const

◆ operator+=()

template<class T >
Vec3<T>& Vec3< T >::operator+= ( const Vec3< T > &  v)

Adds other vector to this, and returns result.

◆ operator-=()

template<class T >
Vec3<T>& Vec3< T >::operator-= ( const Vec3< T > &  v)

Subtracts other vector from this, and returns result.

◆ operator==()

template<class T >
bool Vec3< T >::operator== ( const Vec3< T > &  other) const

◆ real()

template<class T >
R3 Vec3< T >::real ( ) const

Returns real parts.

◆ rotatedY()

template<class T >
Vec3<T> Vec3< T >::rotatedY ( double  a) const

Returns result of rotation around y-axis.

◆ rotatedZ()

template<class T >
Vec3<T> Vec3< T >::rotatedZ ( double  a) const

Returns result of rotation around z-axis.

◆ setX()

template<class T >
void Vec3< T >::setX ( const T &  a)

Sets x-component in cartesian coordinate system.

◆ setY()

template<class T >
void Vec3< T >::setY ( const T &  a)

Sets y-component in cartesian coordinate system.

◆ setZ()

template<class T >
void Vec3< T >::setZ ( const T &  a)

Sets z-component in cartesian coordinate system.

◆ unit()

template<class T >
Vec3<T> Vec3< T >::unit ( ) const

Returns unit vector in direction of this. Throws for null vector.

◆ x()

template<class T >
T Vec3< T >::x ( ) const

Returns x-component in cartesian coordinate system.

◆ y()

template<class T >
T Vec3< T >::y ( ) const

Returns y-component in cartesian coordinate system.

◆ z()

template<class T >
T Vec3< T >::z ( ) const

Returns z-component in cartesian coordinate system.