ROOT  6.06/09
Reference Guide
VectorUtil.cxx
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: W. Brown, M. Fischler, L. Moneta 2006
3 
4  /**********************************************************************
5  * *
6  * Copyright (c) 2006 , LCG ROOT MathLib Team *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Implementation of VectorUtil functions
12 //
13 // Created by: Lorenzo Moneta 22 Aug 2006
14 //
16 
17 namespace ROOT {
18 
19 namespace Math {
20 
21 
22 double VectorUtil::Phi_0_2pi(double angle) {
23  // returns phi angle in the interval (0,2*PI]
24  if ( angle <= 2.*M_PI && angle > 0 ) return angle;
25 
26  if ( angle > 0 ) {
27  int n = static_cast<int>( angle/(2.*M_PI) );
28  angle -= 2.*M_PI*n;
29  } else {
30  int n = static_cast<int>( -(angle)/(2.*M_PI) );
31  angle += 2.*M_PI*(n+1);
32  }
33  return angle;
34 }
35 
36 double VectorUtil::Phi_mpi_pi(double angle) {
37  // returns phi angle in the interval (-PI,PI]
38 
39  if ( angle <= M_PI && angle > -M_PI ) return angle;
40 
41  if ( angle > 0 ) {
42  int n = static_cast<int>( (angle+M_PI)/(2.*M_PI) );
43  angle -= 2*M_PI*n;
44  } else {
45  int n = static_cast<int>( -(angle-M_PI)/(2.*M_PI) );
46  angle += 2*M_PI*n;
47  }
48  return angle;
49 }
50 
51 
52 
53 } //namespace Math
54 } //namespace ROOT
double Phi_0_2pi(double phi)
Return a phi angle in the interval (0,2*PI].
Definition: VectorUtil.cxx:22
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
#define M_PI
Definition: Rotated.cxx:105
double Phi_mpi_pi(double phi)
Returns phi angle in the interval (-PI,PI].
Definition: VectorUtil.cxx:36
Namespace for new Math classes and functions.
const Int_t n
Definition: legend1.C:16