thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
ThePEG::ThreeVector< Value > Class Template Reference

A 3-component vector. More...

#include <ThreeVector.h>

Public Member Functions

Constructors.
 ThreeVector ()
 
 ThreeVector (Value x, Value y, Value z)
 
template<typename ValueB >
 ThreeVector (const ThreeVector< ValueB > &v)
 
Component access methods.
Value x () const
 
Value y () const
 
Value z () const
 
Component set methods.
void setX (Value x)
 
void setY (Value y)
 
void setZ (Value z)
 
Value2 mag2 () const
 Squared magnitude \(x^2+y^2+z^2\).
 
Value mag () const
 Magnitude \(\sqrt{x^2+y^2+z^2}\).
 
Value2 perp2 () const
 Squared transverse component \(x^2+y^2\).
 
Value perp () const
 Transverse component \(\sqrt{x^2+y^2}\).
 
template<typename U >
auto dot (const ThreeVector< U > &a) const -> decltype(this->x() *a.x())
 Dot product.
 
template<typename U >
Value2 perp2 (const ThreeVector< U > &p) const
 Squared transverse component with respect to the given axis.
 
template<typename U >
Value perp (const ThreeVector< U > &p) const
 Transverse component with respect to the given axis.
 
Spherical coordinates.
double theta () const
 Polar angle.
 
double phi () const
 Azimuthal angle.
 
void setTheta (double th)
 Set the polar angle.
 
void setPhi (double ph)
 Set the azimuthal angle.
 
ThreeVector< double > unit () const
 Parallel vector with unit length.
 
ThreeVector< Value > orthogonal () const
 Orthogonal vector.
 
template<typename U >
double deltaPhi (const ThreeVector< U > &v2) const
 Azimuthal angle difference, brought into the range \((-\pi,\pi]\).
 
template<typename U >
ThreeVector< Value > & rotate (double angle, const ThreeVector< U > &axis)
 Apply a rotation.
 
ThreeVector< Value > & rotateUz (const Axis &axis)
 Rotate the reference frame to a new z-axis.
 
ThreeVector< Value > & rotateUzBack (const Axis &axis)
 Rotate from a reference frame to the z-axis.
 
template<typename U >
auto cross (const ThreeVector< U > &a) const -> ThreeVector< decltype(this->y() *a.z())>
 Vector cross-product.
 
Comparison operators.
bool operator== (const ThreeVector< Value > &a) const
 
bool operator!= (const ThreeVector< Value > &a) const
 
bool almostEqual (const ThreeVector< Value > &a, double threshold=1e-04) const
 
bool almostUnequal (const ThreeVector< Value > &a, double threshold=1e-04) const
 
Mathematical assignment operators.
ThreeVector< Value > & operator+= (const ThreeVector< Value > &a)
 
ThreeVector< Value > & operator-= (const ThreeVector< Value > &a)
 
ThreeVector< Value > & operator*= (double a)
 
ThreeVector< Value > & operator/= (double a)
 
template<typename U >
double cosTheta (const ThreeVector< U > &q) const
 Cosine of the azimuthal angle between two vectors.
 
template<typename U >
double angle (const ThreeVector< U > &v) const
 Angle between two vectors.
 

Private Types

using Value2 = decltype(sqr(std::declval< Value >()))
 Value squared.
 

Private Attributes

Vector components
Value theX
 
Value theY
 
Value theZ
 

Detailed Description

template<typename Value>
class ThePEG::ThreeVector< Value >

A 3-component vector.

It can be created with any unit type as template parameter. All basic mathematical operations are supported, as well as a subset of the CLHEP Vector3 functionality.

Definition at line 34 of file ThreeVector.h.

Member Typedef Documentation

◆ Value2

template<typename Value >
using ThePEG::ThreeVector< Value >::Value2 = decltype(sqr(std::declval<Value>()))
private

Value squared.

Definition at line 38 of file ThreeVector.h.

Constructor & Destructor Documentation

◆ ThreeVector() [1/3]

template<typename Value >
ThePEG::ThreeVector< Value >::ThreeVector ( )
inline

Definition at line 43 of file ThreeVector.h.

◆ ThreeVector() [2/3]

template<typename Value >
ThePEG::ThreeVector< Value >::ThreeVector ( Value  x,
Value  y,
Value  z 
)
inline

Definition at line 46 of file ThreeVector.h.

◆ ThreeVector() [3/3]

template<typename Value >
template<typename ValueB >
ThePEG::ThreeVector< Value >::ThreeVector ( const ThreeVector< ValueB > &  v)
inline

Definition at line 50 of file ThreeVector.h.

Member Function Documentation

◆ almostEqual()

template<typename Value >
bool ThePEG::ThreeVector< Value >::almostEqual ( const ThreeVector< Value > &  a,
double  threshold = 1e-04 
) const
inline

Definition at line 268 of file ThreeVector.h.

◆ almostUnequal()

template<typename Value >
bool ThePEG::ThreeVector< Value >::almostUnequal ( const ThreeVector< Value > &  a,
double  threshold = 1e-04 
) const
inline

Definition at line 271 of file ThreeVector.h.

◆ angle()

template<typename Value >
template<typename U >
double ThePEG::ThreeVector< Value >::angle ( const ThreeVector< U > &  v) const
inline

Angle between two vectors.

Definition at line 321 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::cosTheta().

Referenced by ThePEG::ThreeVector< Value >::rotate().

◆ cosTheta()

template<typename Value >
template<typename U >
double ThePEG::ThreeVector< Value >::cosTheta ( const ThreeVector< U > &  q) const
inline

Cosine of the azimuthal angle between two vectors.

Definition at line 310 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::dot(), ThePEG::ThreeVector< Value >::mag(), and ThePEG::ZERO.

Referenced by ThePEG::ThreeVector< Value >::angle().

◆ cross()

template<typename Value >
template<typename U >
auto ThePEG::ThreeVector< Value >::cross ( const ThreeVector< U > &  a) const -> ThreeVector<decltype(this->y()*a.z())>
inline

Vector cross-product.

Definition at line 251 of file ThreeVector.h.

◆ deltaPhi()

template<typename Value >
template<typename U >
double ThePEG::ThreeVector< Value >::deltaPhi ( const ThreeVector< U > &  v2) const
inline

Azimuthal angle difference, brought into the range \((-\pi,\pi]\).

Definition at line 161 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::phi(), ThePEG::Constants::pi, and ThePEG::Constants::twopi.

◆ dot()

template<typename Value >
template<typename U >
auto ThePEG::ThreeVector< Value >::dot ( const ThreeVector< U > &  a) const -> decltype(this->x()*a.x())
inline

Dot product.

Definition at line 84 of file ThreeVector.h.

Referenced by ThePEG::ThreeVector< Value >::cosTheta(), and ThePEG::ThreeVector< Value >::perp2().

◆ mag()

template<typename Value >
Value ThePEG::ThreeVector< Value >::mag ( ) const
inline

◆ mag2()

◆ operator!=()

template<typename Value >
bool ThePEG::ThreeVector< Value >::operator!= ( const ThreeVector< Value > &  a) const
inline

Definition at line 265 of file ThreeVector.h.

◆ operator*=()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::operator*= ( double  a)
inline

Definition at line 293 of file ThreeVector.h.

◆ operator+=()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::operator+= ( const ThreeVector< Value > &  a)
inline

Definition at line 279 of file ThreeVector.h.

◆ operator-=()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::operator-= ( const ThreeVector< Value > &  a)
inline

Definition at line 286 of file ThreeVector.h.

◆ operator/=()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::operator/= ( double  a)
inline

Definition at line 300 of file ThreeVector.h.

◆ operator==()

template<typename Value >
bool ThePEG::ThreeVector< Value >::operator== ( const ThreeVector< Value > &  a) const
inline

Definition at line 262 of file ThreeVector.h.

◆ orthogonal()

template<typename Value >
ThreeVector< Value > ThePEG::ThreeVector< Value >::orthogonal ( ) const
inline

Orthogonal vector.

Definition at line 147 of file ThreeVector.h.

References ThePEG::ZERO.

◆ perp() [1/2]

template<typename Value >
Value ThePEG::ThreeVector< Value >::perp ( ) const
inline

Transverse component \(\sqrt{x^2+y^2}\).

Definition at line 80 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::perp2().

Referenced by ThePEG::ThreeVector< Value >::setPhi(), and ThePEG::ThreeVector< Value >::theta().

◆ perp() [2/2]

template<typename Value >
template<typename U >
Value ThePEG::ThreeVector< Value >::perp ( const ThreeVector< U > &  p) const
inline

Transverse component with respect to the given axis.

Definition at line 104 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::perp2().

◆ perp2() [1/2]

template<typename Value >
Value2 ThePEG::ThreeVector< Value >::perp2 ( ) const
inline

Squared transverse component \(x^2+y^2\).

Definition at line 77 of file ThreeVector.h.

References ThePEG::sqr().

Referenced by ThePEG::ThreeVector< Value >::perp().

◆ perp2() [2/2]

template<typename Value >
template<typename U >
Value2 ThePEG::ThreeVector< Value >::perp2 ( const ThreeVector< U > &  p) const
inline

Squared transverse component with respect to the given axis.

Definition at line 92 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::dot(), ThePEG::ThreeVector< Value >::mag2(), ThePEG::sqr(), and ThePEG::ZERO.

◆ phi()

template<typename Value >
double ThePEG::ThreeVector< Value >::phi ( ) const
inline

Azimuthal angle.

Definition at line 117 of file ThreeVector.h.

Referenced by ThePEG::ThreeVector< Value >::deltaPhi(), and ThePEG::ThreeVector< Value >::setTheta().

◆ rotate()

template<typename Value >
template<typename U >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::rotate ( double  angle,
const ThreeVector< U > &  axis 
)
inline

Apply a rotation.

Parameters
angleRotation angle in radians.
axisRotation axis.

Definition at line 177 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::angle(), ThePEG::ThreeVector< Value >::mag(), and ThePEG::ZERO.

◆ rotateUz()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::rotateUz ( const Axis axis)
inline

Rotate the reference frame to a new z-axis.

Definition at line 206 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::unit().

◆ rotateUzBack()

template<typename Value >
ThreeVector< Value > & ThePEG::ThreeVector< Value >::rotateUzBack ( const Axis axis)
inline

Rotate from a reference frame to the z-axis.

Definition at line 229 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::unit().

◆ setPhi()

template<typename Value >
void ThePEG::ThreeVector< Value >::setPhi ( double  ph)
inline

Set the azimuthal angle.

Definition at line 131 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::perp().

◆ setTheta()

template<typename Value >
void ThePEG::ThreeVector< Value >::setTheta ( double  th)
inline

Set the polar angle.

Definition at line 122 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::mag(), and ThePEG::ThreeVector< Value >::phi().

◆ setX()

template<typename Value >
void ThePEG::ThreeVector< Value >::setX ( Value  x)
inline

Definition at line 64 of file ThreeVector.h.

◆ setY()

template<typename Value >
void ThePEG::ThreeVector< Value >::setY ( Value  y)
inline

Definition at line 65 of file ThreeVector.h.

◆ setZ()

template<typename Value >
void ThePEG::ThreeVector< Value >::setZ ( Value  z)
inline

Definition at line 66 of file ThreeVector.h.

◆ theta()

template<typename Value >
double ThePEG::ThreeVector< Value >::theta ( ) const
inline

Polar angle.

Definition at line 111 of file ThreeVector.h.

References ThePEG::ThreeVector< Value >::perp(), and ThePEG::ZERO.

◆ unit()

template<typename Value >
ThreeVector< double > ThePEG::ThreeVector< Value >::unit ( ) const
inline

◆ x()

template<typename Value >
Value ThePEG::ThreeVector< Value >::x ( ) const
inline

Definition at line 57 of file ThreeVector.h.

◆ y()

template<typename Value >
Value ThePEG::ThreeVector< Value >::y ( ) const
inline

Definition at line 58 of file ThreeVector.h.

◆ z()

template<typename Value >
Value ThePEG::ThreeVector< Value >::z ( ) const
inline

Definition at line 59 of file ThreeVector.h.

Member Data Documentation

◆ theX

template<typename Value >
Value ThePEG::ThreeVector< Value >::theX
private

Definition at line 328 of file ThreeVector.h.

◆ theY

template<typename Value >
Value ThePEG::ThreeVector< Value >::theY
private

Definition at line 329 of file ThreeVector.h.

◆ theZ

template<typename Value >
Value ThePEG::ThreeVector< Value >::theZ
private

Definition at line 330 of file ThreeVector.h.


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