CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

Geom::Phi< T > Class Template Reference

#include <Phi.h>

List of all members.

Public Member Functions

T degrees () const
template<class T1 >
 operator Phi< T1 > ()
 Template argument conversion.
 operator T () const
 conversion operator makes transparent use possible.
Phioperator*= (const T &a)
Phioperator+= (const Phi &a)
Phioperator+= (const T &a)
 Standard arithmetics.
Phioperator-= (const T &a)
Phioperator-= (const Phi &a)
Phioperator/= (const T &a)
 Phi ()
 Default constructor does not initialise - just as double.
 Phi (const T &val)
T phi () const
T value () const
 Explicit access to value in case implicit conversion not OK.

Private Member Functions

void normalize ()

Private Attributes

T theValue

Detailed Description

template<class T>
class Geom::Phi< T >

A class for azimuthal angle represantation and algebra. The use of Phi<T> is tranparant due to the implicit conversion to T Constructs like cos(phi) work as with float or double. The difference with respect to built-in types is that Phi is kept in the range (-pi, pi], and this is consistently implemented in aritmetic operations. In other words, Phi implements "modulo(2 pi)" arithmetics.

Definition at line 20 of file Phi.h.


Constructor & Destructor Documentation

template<class T>
Geom::Phi< T >::Phi ( ) [inline]

Default constructor does not initialise - just as double.

Definition at line 24 of file Phi.h.

{}
template<class T>
Geom::Phi< T >::Phi ( const T val) [inline, explicit]

Constructor from T, does not provide automatic conversion. The constructor provides range checking and normalization, e.g. the value of Pi(2*pi()+1) is 1

Definition at line 29 of file Phi.h.

: theValue(val) { normalize();}

Member Function Documentation

template<class T>
T Geom::Phi< T >::degrees ( ) const [inline]

Definition at line 54 of file Phi.h.

Referenced by TrackerHitAnalyzer::analyze(), and CSCRecHit2DValidation::analyze().

{ return theValue*180./pi();}
template<class T>
void Geom::Phi< T >::normalize ( ) [inline, private]
template<class T>
template<class T1 >
Geom::Phi< T >::operator Phi< T1 > ( ) [inline]

Template argument conversion.

Definition at line 35 of file Phi.h.

{ return Phi<T1>(theValue);}
template<class T>
Geom::Phi< T >::operator T ( ) const [inline]

conversion operator makes transparent use possible.

Definition at line 32 of file Phi.h.

References Geom::Phi< T >::theValue.

{ return theValue;}
template<class T>
Phi& Geom::Phi< T >::operator*= ( const T a) [inline]

Definition at line 50 of file Phi.h.

{theValue*=a; normalize(); return *this;}
template<class T>
Phi& Geom::Phi< T >::operator+= ( const T a) [inline]

Standard arithmetics.

Definition at line 44 of file Phi.h.

{theValue+=a; normalize(); return *this;}
template<class T>
Phi& Geom::Phi< T >::operator+= ( const Phi< T > &  a) [inline]

Definition at line 45 of file Phi.h.

Referenced by Geom::Phi< float >::operator+=().

{return operator+=(a.value());}
template<class T>
Phi& Geom::Phi< T >::operator-= ( const Phi< T > &  a) [inline]

Definition at line 48 of file Phi.h.

Referenced by Geom::Phi< float >::operator-=().

{return operator-=(a.value());}
template<class T>
Phi& Geom::Phi< T >::operator-= ( const T a) [inline]

Definition at line 47 of file Phi.h.

{theValue-=a; normalize(); return *this;}
template<class T>
Phi& Geom::Phi< T >::operator/= ( const T a) [inline]

Definition at line 52 of file Phi.h.

{theValue/=a; normalize(); return *this;}
template<class T>
T Geom::Phi< T >::phi ( ) const [inline]
template<class T>
T Geom::Phi< T >::value ( ) const [inline]

Member Data Documentation

template<class T>
T Geom::Phi< T >::theValue [private]