VectorUtil.cxx

Go to the documentation of this file.
00001 // @(#)root/mathcore:$Id: VectorUtil.cxx 22516 2008-03-07 15:14:26Z moneta $
00002 // Authors: W. Brown, M. Fischler, L. Moneta    2006  
00003 
00004  /**********************************************************************
00005   *                                                                    *
00006   * Copyright (c) 2006 , LCG ROOT MathLib Team                         *
00007   *                                                                    *
00008   *                                                                    *
00009   **********************************************************************/
00010 
00011 // Implementation of VectorUtil functions
00012 //
00013 // Created by: Lorenzo Moneta 22 Aug 2006
00014 //
00015 #include "Math/GenVector/VectorUtil.h"
00016 
00017 namespace ROOT {
00018 
00019 namespace Math {
00020 
00021 
00022 double VectorUtil::Phi_0_2pi(double angle) {
00023    // returns phi angle in the interval (0,2*PI]
00024    if ( angle <= 2.*M_PI && angle > 0 ) return angle;
00025 
00026    if ( angle > 0 ) {
00027       int n = static_cast<int>( angle/(2.*M_PI) );
00028       angle -= 2.*M_PI*n;
00029    } else {
00030       int n = static_cast<int>( -(angle)/(2.*M_PI) );
00031       angle += 2.*M_PI*(n+1);  
00032    }
00033    return angle;
00034 }
00035 
00036 double VectorUtil::Phi_mpi_pi(double angle) {
00037    // returns phi angle in the interval (-PI,PI]
00038    
00039    if ( angle <= M_PI && angle > -M_PI ) return angle;
00040    
00041    if ( angle > 0 ) {
00042       int n = static_cast<int>( (angle+M_PI)/(2.*M_PI) );
00043       angle -= 2*M_PI*n;
00044    } else {
00045       int n = static_cast<int>( -(angle-M_PI)/(2.*M_PI) );
00046       angle += 2*M_PI*n;  
00047    }
00048    return angle;
00049 } 
00050 
00051 
00052 
00053 } //namespace Math
00054 } //namespace ROOT

Generated on Tue Jul 5 14:33:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1