CLHEP 2.4.7.2
C++ Class Library for High Energy Physics
HepGeom::BasicVector3D< T > Class Template Reference

#include <CLHEP/Geometry/BasicVector3D.h>

Inheritance diagram for HepGeom::BasicVector3D< T >:
HepGeom::Normal3D< T > HepGeom::Point3D< T > HepGeom::Vector3D< T >

Public Types

enum  {
  X = 0 , Y = 1 , Z = 2 , NUM_COORDINATES = 3 ,
  SIZE = NUM_COORDINATES
}

Public Member Functions

 BasicVector3D (T x1, T y1, T z1)
 BasicVector3D (const BasicVector3D< T > &)=default
template<typename U = T, typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
 BasicVector3D (const BasicVector3D< float > &v)
 BasicVector3D (BasicVector3D< T > &&)=default
virtual ~BasicVector3D ()=default
 operator T* ()
 operator const T * () const
 operator CLHEP::Hep3Vector () const
BasicVector3D< T > & operator= (const BasicVector3D< T > &)=default
BasicVector3D< T > & operator= (BasicVector3D< T > &&)=default
BasicVector3D< T > & operator+= (const BasicVector3D< T > &v)
BasicVector3D< T > & operator-= (const BasicVector3D< T > &v)
BasicVector3D< T > & operator*= (double a)
BasicVector3D< T > & operator/= (double a)
T operator() (int i) const
T operator[] (int i) const
T & operator() (int i)
T & operator[] (int i)
T x () const
T y () const
T z () const
void setX (T a)
void setY (T a)
void setZ (T a)
void set (T x1, T y1, T z1)
T perp2 () const
T perp () const
T rho () const
void setPerp (T rh)
T mag2 () const
T mag () const
T r () const
T phi () const
T theta () const
T cosTheta () const
T getR () const
T getPhi () const
T getTheta () const
void setMag (T ma)
void setR (T ma)
void setPhi (T ph)
void setTheta (T th)
T pseudoRapidity () const
T eta () const
T getEta () const
void setEta (T a)
T dot (const BasicVector3D< T > &v) const
BasicVector3D< T > cross (const BasicVector3D< T > &v) const
T perp2 (const BasicVector3D< T > &v) const
T perp (const BasicVector3D< T > &v) const
T angle (const BasicVector3D< T > &v) const
BasicVector3D< T > unit () const
BasicVector3D< T > orthogonal () const
BasicVector3D< T > & rotateX (T a)
BasicVector3D< T > & rotateY (T a)
BasicVector3D< T > & rotateZ (T a)
BasicVector3D< T > & rotate (T a, const BasicVector3D< T > &v)

Protected Member Functions

 BasicVector3D ()

Protected Attributes

T v_ [3]

(Note that these are not member symbols.)

std::ostream & operator<< (std::ostream &, const BasicVector3D< float > &)
std::istream & operator>> (std::istream &, BasicVector3D< float > &)
BasicVector3D< float > operator+ (const BasicVector3D< float > &v)
BasicVector3D< float > operator+ (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator- (const BasicVector3D< float > &v)
BasicVector3D< float > operator- (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator* (const BasicVector3D< float > &v, double a)
float operator* (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator* (double a, const BasicVector3D< float > &v)
BasicVector3D< float > operator/ (const BasicVector3D< float > &v, double a)
bool operator== (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
bool operator!= (const BasicVector3D< float > &a, const BasicVector3D< float > &b)
std::ostream & operator<< (std::ostream &, const BasicVector3D< double > &)
std::istream & operator>> (std::istream &, BasicVector3D< double > &)
BasicVector3D< double > operator+ (const BasicVector3D< double > &v)
BasicVector3D< double > operator+ (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< double > operator- (const BasicVector3D< double > &v)
BasicVector3D< double > operator- (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< double > operator* (const BasicVector3D< double > &v, double a)
double operator* (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< double > operator* (double a, const BasicVector3D< double > &v)
BasicVector3D< double > operator/ (const BasicVector3D< double > &v, double a)
bool operator== (const BasicVector3D< double > &a, const BasicVector3D< double > &b)
bool operator!= (const BasicVector3D< double > &a, const BasicVector3D< double > &b)

Detailed Description

template<class T>
class HepGeom::BasicVector3D< T >

Base class for Point3D<T>, Vector3D<T> and Normal3D<T>. It defines only common functionality for those classes and should not be used as separate class.

Author
Evgeni Chernyaev Evgue.nosp@m.ni.T.nosp@m.chern.nosp@m.iaev.nosp@m.@cern.nosp@m..ch

Definition at line 29 of file BasicVector3D.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T>
anonymous enum

Safe indexing of the coordinates when using with matrices, arrays, etc.

Enumerator
X 

index for x-component

Y 

index for y-component

Z 

index for z-component

NUM_COORDINATES 

number of components

SIZE 

number of components

Definition at line 43 of file BasicVector3D.h.

Constructor & Destructor Documentation

◆ BasicVector3D() [1/5]

template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( )
inlineprotected

Default constructor. It is protected - this class should not be instantiated directly.

Definition at line 37 of file BasicVector3D.h.

References v_.

Referenced by angle(), BasicVector3D(), BasicVector3D(), BasicVector3D(), cross(), dot(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), operator=(), orthogonal(), perp(), perp2(), rotate(), rotateX(), rotateY(), rotateZ(), and unit().

◆ BasicVector3D() [2/5]

template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( T x1,
T y1,
T z1 )
inline

Constructor from three numbers.

Definition at line 53 of file BasicVector3D.h.

References v_.

◆ BasicVector3D() [3/5]

template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( const BasicVector3D< T > & )
default

Copy constructor.

References BasicVector3D().

◆ BasicVector3D() [4/5]

template<class T>
template<typename U = T, typename = typename std::enable_if<!std::is_same<U,float>::value >::type>
HepGeom::BasicVector3D< T >::BasicVector3D ( const BasicVector3D< float > & v)
inline

Constructor for BasicVector3D<double> from BasicVector3D<float>.

Definition at line 63 of file BasicVector3D.h.

References BasicVector3D(), v_, x(), y(), and z().

◆ BasicVector3D() [5/5]

template<class T>
HepGeom::BasicVector3D< T >::BasicVector3D ( BasicVector3D< T > && )
default

Move constructor.

References BasicVector3D().

◆ ~BasicVector3D()

template<class T>
virtual HepGeom::BasicVector3D< T >::~BasicVector3D ( )
virtualdefault

Destructor.

Member Function Documentation

◆ angle()

template<class T>
T HepGeom::BasicVector3D< T >::angle ( const BasicVector3D< T > & v) const

Returns angle w.r.t. another vector.

References BasicVector3D().

◆ cosTheta()

template<class T>
T HepGeom::BasicVector3D< T >::cosTheta ( ) const
inline

Gets cosine of polar angle.

Definition at line 219 of file BasicVector3D.h.

References mag(), and z().

◆ cross()

template<class T>
BasicVector3D< T > HepGeom::BasicVector3D< T >::cross ( const BasicVector3D< T > & v) const
inline

Vector product.

Definition at line 283 of file BasicVector3D.h.

References BasicVector3D(), x(), y(), and z().

◆ dot()

template<class T>
T HepGeom::BasicVector3D< T >::dot ( const BasicVector3D< T > & v) const
inline

Scalar product.

Definition at line 277 of file BasicVector3D.h.

References BasicVector3D(), x(), y(), and z().

Referenced by HepGeom::BasicVector3D< double >::operator*(), HepGeom::BasicVector3D< double >::operator*(), and perp2().

◆ eta()

template<class T>
T HepGeom::BasicVector3D< T >::eta ( ) const
inline

Gets pseudo-rapidity.

Definition at line 262 of file BasicVector3D.h.

References pseudoRapidity().

◆ getEta()

template<class T>
T HepGeom::BasicVector3D< T >::getEta ( ) const
inline

Gets pseudo-rapidity.

Definition at line 265 of file BasicVector3D.h.

References pseudoRapidity().

◆ getPhi()

template<class T>
T HepGeom::BasicVector3D< T >::getPhi ( ) const
inline

Gets phi-component in spherical coordinate system

Definition at line 226 of file BasicVector3D.h.

References phi().

◆ getR()

template<class T>
T HepGeom::BasicVector3D< T >::getR ( ) const
inline

Gets r-component in spherical coordinate system

Definition at line 223 of file BasicVector3D.h.

References r().

◆ getTheta()

template<class T>
T HepGeom::BasicVector3D< T >::getTheta ( ) const
inline

Gets theta-component in spherical coordinate system

Definition at line 229 of file BasicVector3D.h.

References theta().

◆ mag()

template<class T>
T HepGeom::BasicVector3D< T >::mag ( ) const
inline

Gets magnitude of the vector.

Definition at line 203 of file BasicVector3D.h.

References mag2().

Referenced by cosTheta(), r(), setMag(), setTheta(), and unit().

◆ mag2()

template<class T>
T HepGeom::BasicVector3D< T >::mag2 ( ) const
inline

Gets magnitude squared of the vector.

Definition at line 200 of file BasicVector3D.h.

References x(), y(), and z().

Referenced by HepGeom::Point3D< double >::distance2(), HepGeom::Point3D< float >::distance2(), mag(), and perp2().

◆ operator CLHEP::Hep3Vector()

template<class T>
HepGeom::BasicVector3D< T >::operator CLHEP::Hep3Vector ( ) const
inline

Conversion (cast) to CLHEP::Hep3Vector. This operator is needed only for backward compatibility and in principle should not exit.

Definition at line 92 of file BasicVector3D.h.

References x(), y(), and z().

◆ operator const T *()

template<class T>
HepGeom::BasicVector3D< T >::operator const T * ( ) const
inline

Conversion (cast) to ordinary const array.

Definition at line 85 of file BasicVector3D.h.

◆ operator T*()

template<class T>
HepGeom::BasicVector3D< T >::operator T* ( )
inline

Conversion (cast) to ordinary array.

Definition at line 81 of file BasicVector3D.h.

◆ operator()() [1/2]

template<class T>
T & HepGeom::BasicVector3D< T >::operator() ( int i)
inline

Sets components by index.

Definition at line 138 of file BasicVector3D.h.

References v_.

◆ operator()() [2/2]

template<class T>
T HepGeom::BasicVector3D< T >::operator() ( int i) const
inline

Gets components by index.

Definition at line 131 of file BasicVector3D.h.

References v_.

◆ operator*=()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::operator*= ( double a)
inline

Multiplication by scalar.

Definition at line 116 of file BasicVector3D.h.

References BasicVector3D(), and v_.

◆ operator+=()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::operator+= ( const BasicVector3D< T > & v)
inline

Addition.

Definition at line 106 of file BasicVector3D.h.

References BasicVector3D(), and v_.

◆ operator-=()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::operator-= ( const BasicVector3D< T > & v)
inline

Subtraction.

Definition at line 111 of file BasicVector3D.h.

References BasicVector3D(), and v_.

◆ operator/=()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::operator/= ( double a)
inline

Division by scalar.

Definition at line 121 of file BasicVector3D.h.

References BasicVector3D(), and v_.

◆ operator=() [1/2]

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::operator= ( BasicVector3D< T > && )
default

Move assignment.

References BasicVector3D().

◆ operator=() [2/2]

◆ operator[]() [1/2]

template<class T>
T & HepGeom::BasicVector3D< T >::operator[] ( int i)
inline

Sets components by index.

Definition at line 141 of file BasicVector3D.h.

References v_.

◆ operator[]() [2/2]

template<class T>
T HepGeom::BasicVector3D< T >::operator[] ( int i) const
inline

Gets components by index.

Definition at line 134 of file BasicVector3D.h.

References v_.

◆ orthogonal()

template<class T>
BasicVector3D< T > HepGeom::BasicVector3D< T >::orthogonal ( ) const
inline

Returns orthogonal vector.

Definition at line 320 of file BasicVector3D.h.

References BasicVector3D(), x(), y(), and z().

◆ perp() [1/2]

template<class T>
T HepGeom::BasicVector3D< T >::perp ( ) const
inline

Gets transverse component.

Definition at line 180 of file BasicVector3D.h.

References perp2().

Referenced by rho(), setPerp(), setPhi(), and theta().

◆ perp() [2/2]

template<class T>
T HepGeom::BasicVector3D< T >::perp ( const BasicVector3D< T > & v) const
inline

Returns transverse component w.r.t. given axis.

Definition at line 298 of file BasicVector3D.h.

References BasicVector3D(), and perp2().

◆ perp2() [1/2]

template<class T>
T HepGeom::BasicVector3D< T >::perp2 ( ) const
inline

Gets transverse component squared.

Definition at line 177 of file BasicVector3D.h.

References x(), and y().

Referenced by perp(), and perp().

◆ perp2() [2/2]

template<class T>
T HepGeom::BasicVector3D< T >::perp2 ( const BasicVector3D< T > & v) const
inline

Returns transverse component w.r.t. given axis squared.

Definition at line 291 of file BasicVector3D.h.

References BasicVector3D(), dot(), and mag2().

◆ phi()

template<class T>
T HepGeom::BasicVector3D< T >::phi ( ) const
inline

Gets azimuth angle.

Definition at line 209 of file BasicVector3D.h.

References x(), and y().

Referenced by getPhi(), and setTheta().

◆ pseudoRapidity()

template<class T>
T HepGeom::BasicVector3D< T >::pseudoRapidity ( ) const

Gets pseudo-rapidity: -ln(tan(theta/2))

Referenced by eta(), and getEta().

◆ r()

template<class T>
T HepGeom::BasicVector3D< T >::r ( ) const
inline

Gets r-component in spherical coordinate system

Definition at line 206 of file BasicVector3D.h.

References mag().

Referenced by getR().

◆ rho()

template<class T>
T HepGeom::BasicVector3D< T >::rho ( ) const
inline

Gets rho-component in cylindrical coordinate system

Definition at line 183 of file BasicVector3D.h.

References perp().

◆ rotate()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotate ( T a,
const BasicVector3D< T > & v )

Rotates around the axis specified by another vector.

References BasicVector3D().

◆ rotateX()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateX ( T a)

Rotates around x-axis.

References BasicVector3D().

◆ rotateY()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateY ( T a)

Rotates around y-axis.

References BasicVector3D().

◆ rotateZ()

template<class T>
BasicVector3D< T > & HepGeom::BasicVector3D< T >::rotateZ ( T a)

Rotates around z-axis.

References BasicVector3D().

◆ set()

template<class T>
void HepGeom::BasicVector3D< T >::set ( T x1,
T y1,
T z1 )
inline

Sets components in cartesian coordinate system.

Definition at line 169 of file BasicVector3D.h.

References v_.

Referenced by setTheta().

◆ setEta()

template<class T>
void HepGeom::BasicVector3D< T >::setEta ( T a)

Sets pseudo-rapidity, keeping magnitude and phi fixed.

◆ setMag()

template<class T>
void HepGeom::BasicVector3D< T >::setMag ( T ma)
inline

Sets magnitude.

Definition at line 233 of file BasicVector3D.h.

References mag(), and v_.

Referenced by setR().

◆ setPerp()

template<class T>
void HepGeom::BasicVector3D< T >::setPerp ( T rh)
inline

Sets transverse component keeping phi and z constant.

Definition at line 187 of file BasicVector3D.h.

References perp(), and v_.

◆ setPhi()

template<class T>
void HepGeom::BasicVector3D< T >::setPhi ( T ph)
inline

Sets phi-component in spherical coordinate system.

Definition at line 244 of file BasicVector3D.h.

References perp(), setX(), and setY().

◆ setR()

template<class T>
void HepGeom::BasicVector3D< T >::setR ( T ma)
inline

Sets r-component in spherical coordinate system.

Definition at line 241 of file BasicVector3D.h.

References setMag().

◆ setTheta()

template<class T>
void HepGeom::BasicVector3D< T >::setTheta ( T th)
inline

Sets theta-component in spherical coordinate system.

Definition at line 247 of file BasicVector3D.h.

References mag(), phi(), and set().

◆ setX()

template<class T>
void HepGeom::BasicVector3D< T >::setX ( T a)
inline

Sets x-component in cartesian coordinate system.

Definition at line 159 of file BasicVector3D.h.

References v_.

Referenced by setPhi().

◆ setY()

template<class T>
void HepGeom::BasicVector3D< T >::setY ( T a)
inline

Sets y-component in cartesian coordinate system.

Definition at line 162 of file BasicVector3D.h.

References v_.

Referenced by setPhi().

◆ setZ()

template<class T>
void HepGeom::BasicVector3D< T >::setZ ( T a)
inline

Sets z-component in cartesian coordinate system.

Definition at line 165 of file BasicVector3D.h.

References v_.

◆ theta()

template<class T>
T HepGeom::BasicVector3D< T >::theta ( ) const
inline

Gets polar angle.

Definition at line 214 of file BasicVector3D.h.

References perp(), x(), y(), and z().

Referenced by getTheta().

◆ unit()

template<class T>
BasicVector3D< T > HepGeom::BasicVector3D< T >::unit ( ) const
inline

Returns unit vector parallel to this.

Definition at line 312 of file BasicVector3D.h.

References BasicVector3D(), mag(), x(), y(), and z().

◆ x()

template<class T>
T HepGeom::BasicVector3D< T >::x ( ) const
inline

◆ y()

template<class T>
T HepGeom::BasicVector3D< T >::y ( ) const
inline

◆ z()

template<class T>
T HepGeom::BasicVector3D< T >::z ( ) const
inline

◆ operator!=() [1/2]

template<class T>
bool operator!= ( const BasicVector3D< double > & a,
const BasicVector3D< double > & b )
related

Comparison of two vectors for inequality.

Definition at line 564 of file BasicVector3D.h.

◆ operator!=() [2/2]

template<class T>
bool operator!= ( const BasicVector3D< float > & a,
const BasicVector3D< float > & b )
related

Comparison of two vectors for inequality.

Definition at line 455 of file BasicVector3D.h.

◆ operator*() [1/6]

template<class T>
double operator* ( const BasicVector3D< double > & a,
const BasicVector3D< double > & b )
related

Scalar product of two vectors.

Definition at line 527 of file BasicVector3D.h.

◆ operator*() [2/6]

template<class T>
BasicVector3D< double > operator* ( const BasicVector3D< double > & v,
double a )
related

Multiplication vector by scalar.

Definition at line 518 of file BasicVector3D.h.

◆ operator*() [3/6]

template<class T>
float operator* ( const BasicVector3D< float > & a,
const BasicVector3D< float > & b )
related

Scalar product of two vectors.

Definition at line 419 of file BasicVector3D.h.

◆ operator*() [4/6]

template<class T>
BasicVector3D< float > operator* ( const BasicVector3D< float > & v,
double a )
related

Multiplication vector by scalar.

Definition at line 410 of file BasicVector3D.h.

◆ operator*() [5/6]

template<class T>
BasicVector3D< double > operator* ( double a,
const BasicVector3D< double > & v )
related

Multiplication scalar by vector.

Definition at line 536 of file BasicVector3D.h.

◆ operator*() [6/6]

template<class T>
BasicVector3D< float > operator* ( double a,
const BasicVector3D< float > & v )
related

Multiplication scalar by vector.

Definition at line 428 of file BasicVector3D.h.

◆ operator+() [1/4]

template<class T>
BasicVector3D< double > operator+ ( const BasicVector3D< double > & a,
const BasicVector3D< double > & b )
related

Addition of two vectors.

Definition at line 491 of file BasicVector3D.h.

◆ operator+() [2/4]

template<class T>
BasicVector3D< double > operator+ ( const BasicVector3D< double > & v)
related

Unary plus.

Definition at line 484 of file BasicVector3D.h.

◆ operator+() [3/4]

template<class T>
BasicVector3D< float > operator+ ( const BasicVector3D< float > & a,
const BasicVector3D< float > & b )
related

Addition of two vectors.

Definition at line 383 of file BasicVector3D.h.

◆ operator+() [4/4]

template<class T>
BasicVector3D< float > operator+ ( const BasicVector3D< float > & v)
related

Unary plus.

Definition at line 376 of file BasicVector3D.h.

◆ operator-() [1/4]

template<class T>
BasicVector3D< double > operator- ( const BasicVector3D< double > & a,
const BasicVector3D< double > & b )
related

Subtraction of two vectors.

Definition at line 509 of file BasicVector3D.h.

◆ operator-() [2/4]

template<class T>
BasicVector3D< double > operator- ( const BasicVector3D< double > & v)
related

Unary minus.

Definition at line 500 of file BasicVector3D.h.

◆ operator-() [3/4]

template<class T>
BasicVector3D< float > operator- ( const BasicVector3D< float > & a,
const BasicVector3D< float > & b )
related

Subtraction of two vectors.

Definition at line 401 of file BasicVector3D.h.

◆ operator-() [4/4]

template<class T>
BasicVector3D< float > operator- ( const BasicVector3D< float > & v)
related

Unary minus.

Definition at line 392 of file BasicVector3D.h.

◆ operator/() [1/2]

template<class T>
BasicVector3D< double > operator/ ( const BasicVector3D< double > & v,
double a )
related

Division vector by scalar.

Definition at line 545 of file BasicVector3D.h.

◆ operator/() [2/2]

template<class T>
BasicVector3D< float > operator/ ( const BasicVector3D< float > & v,
double a )
related

Division vector by scalar.

Definition at line 437 of file BasicVector3D.h.

◆ operator<<() [1/2]

template<class T>
std::ostream & operator<< ( std::ostream & ,
const BasicVector3D< double > &  )
related

Output to stream.

◆ operator<<() [2/2]

template<class T>
std::ostream & operator<< ( std::ostream & ,
const BasicVector3D< float > &  )
related

Output to stream.

◆ operator==() [1/2]

template<class T>
bool operator== ( const BasicVector3D< double > & a,
const BasicVector3D< double > & b )
related

Comparison of two vectors for equality.

Definition at line 554 of file BasicVector3D.h.

◆ operator==() [2/2]

template<class T>
bool operator== ( const BasicVector3D< float > & a,
const BasicVector3D< float > & b )
related

Comparison of two vectors for equality.

Definition at line 446 of file BasicVector3D.h.

◆ operator>>() [1/2]

template<class T>
std::istream & operator>> ( std::istream & ,
BasicVector3D< double > &  )
related

Input from stream.

◆ operator>>() [2/2]

template<class T>
std::istream & operator>> ( std::istream & ,
BasicVector3D< float > &  )
related

Input from stream.

Member Data Documentation

◆ v_


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