CMS 3D CMS Logo

Namespaces | Functions

/data/refman/pasoursint/CMSSW_5_3_0/src/DataFormats/GeometryVector/interface/Pi.h File Reference

Go to the source code of this file.

Namespaces

namespace  Geom

Functions

float Geom::fhalfPi ()
float Geom::fpi ()
float Geom::ftwoPi ()
double Geom::halfPi ()
double Geom::pi ()
double Geom::twoPi ()

Detailed Description

Just pi (the ratio of circle length to diameter). Since the C++ standard seems not to care about PI and the M_PI macro definition in <cmath> is not even in the standard a definition is provided here. The goal of this implementation is to be as efficient as a macro, and transparent to use. Excluding macros, there are four ways to implement a constant for shared use: 1) As a global constant (possibly within a namespace), that is initialized by the linker/loader and used as a memory reference 2) As a file scope constant (i.e. in the unnamed namespace) with one copy per file 3) As an in-line function that returns the value 4) As a class with an in-line method that returns the value The first way is probably the most efficient but it requires an additional libraby to link, something you should not need if you just want to use pi. The fourth way is only justified if you need more than one method for the same constant (e.g. return it in different units) The difference between the second and the third is essentially in the parantheses of the function call, which are not needed in the second method.

Definition in file Pi.h.