CMS 3D CMS Logo

Geom::Phi< T > Class Template Reference

A class for azimuthal angle represantation and algebra. More...

#include <DataFormats/GeometryVector/interface/Phi.h>

List of all members.

Public Member Functions

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

Private Member Functions

void normalize ()

Private Attributes

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.

00024 {}

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.

00029 : theValue(val) { normalize();}


Member Function Documentation

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

Definition at line 51 of file Phi.h.

00051 { return theValue*180./pi();}

template<class T>
void Geom::Phi< T >::normalize (  )  [inline, private]

Definition at line 57 of file Phi.h.

Referenced by Geom::Phi< float >::operator *=(), Geom::Phi< float >::operator+=(), Geom::Phi< float >::operator-=(), Geom::Phi< float >::operator/=(), and Geom::Phi< float >::Phi().

00057                      { 
00058       if( theValue > twoPi() || theValue < -twoPi()) {
00059         theValue = fmod( theValue, (T) twoPi());
00060       }
00061       if (theValue <= -pi()) theValue += twoPi();
00062       if (theValue >  pi()) theValue -= twoPi();
00063     }

template<class T>
Phi& Geom::Phi< T >::operator *= ( const T &  a  )  [inline]

Definition at line 47 of file Phi.h.

00047 {theValue*=a; normalize(); return *this;}

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

Template argument conversion.

Definition at line 35 of file Phi.h.

00035 { 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.

00032 { return theValue;}

template<class T>
Phi& Geom::Phi< T >::operator+= ( const Phi< T > &  a  )  [inline]

Definition at line 42 of file Phi.h.

00042 {return operator+=(a.value());}

template<class T>
Phi& Geom::Phi< T >::operator+= ( const T &  a  )  [inline]

Standard arithmetics.

Definition at line 41 of file Phi.h.

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

00041 {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.

00045 {return operator-=(a.value());}

template<class T>
Phi& Geom::Phi< T >::operator-= ( const T &  a  )  [inline]

Definition at line 44 of file Phi.h.

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

00044 {theValue-=a; normalize(); return *this;}

template<class T>
Phi& Geom::Phi< T >::operator/= ( const T &  a  )  [inline]

Definition at line 49 of file Phi.h.

00049 {theValue/=a; normalize(); return *this;}

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

Explicit access to value in case implicit conversion not OK.

Definition at line 38 of file Phi.h.

Referenced by Basic3DVector< T >::Basic3DVector(), Geom::Phi< float >::operator+=(), Geom::operator-(), Geom::Phi< float >::operator-=(), Geom::operator/(), and PhiBorderFinder::PhiBorderFinder().

00038 { return theValue;}


Member Data Documentation

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

Definition at line 55 of file Phi.h.

Referenced by Geom::Phi< float >::degrees(), Geom::Phi< float >::normalize(), Geom::Phi< float >::operator *=(), Geom::Phi< float >::operator Phi< T1 >(), Geom::Phi< T >::operator T(), Geom::Phi< float >::operator+=(), Geom::Phi< float >::operator-=(), Geom::Phi< float >::operator/=(), and Geom::Phi< float >::value().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:47:16 2009 for CMSSW by  doxygen 1.5.4