23 Double_t
const kPI = TMath::Pi();
24 Double_t
const kTWOPI = 2.*kPI;
40 TVector2::TVector2(Double_t *v)
49 TVector2::TVector2(Double_t x0, Double_t y0)
64 Double_t TVector2::Mod()
const
66 return TMath::Sqrt(fX*fX+fY*fY);
72 TVector2 TVector2::Unit()
const
74 return (Mod2()) ? *
this/Mod() : TVector2();
80 Double_t TVector2::Phi()
const
82 return TMath::Pi()+TMath::ATan2(-fY,-fX);
88 Double_t TVector2::Phi_0_2pi(Double_t x) {
90 gROOT->Error(
"TVector2::Phi_0_2pi",
"function called with NaN");
93 while (x >= kTWOPI) x -= kTWOPI;
94 while (x < 0.) x += kTWOPI;
101 Double_t TVector2::Phi_mpi_pi(Double_t x) {
103 gROOT->Error(
"TVector2::Phi_mpi_pi",
"function called with NaN");
106 while (x >= kPI) x -= kTWOPI;
107 while (x < -kPI) x += kTWOPI;
114 TVector2 TVector2::Rotate (Double_t phi)
const
116 return TVector2( fX*TMath::Cos(phi)-fY*TMath::Sin(phi), fX*TMath::Sin(phi)+fY*TMath::Cos(phi) );
122 void TVector2::SetMagPhi(Double_t mag, Double_t phi)
124 Double_t amag = TMath::Abs(mag);
125 fX = amag * TMath::Cos(phi);
126 fY = amag * TMath::Sin(phi);
131 void TVector2::Streamer(TBuffer &R__b)
133 if (R__b.IsReading()) {
135 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
137 R__b.ReadClassBuffer(TVector2::Class(),
this, R__v, R__s, R__c);
141 if (R__v < 2) TObject::Streamer(R__b);
144 R__b.CheckByteCount(R__s, R__c, TVector2::IsA());
148 R__b.WriteClassBuffer(TVector2::Class(),
this);
152 void TVector2::Print(Option_t*)
const
155 Printf(
"%s %s (x,y)=(%f,%f) (rho,phi)=(%f,%f)",GetName(),GetTitle(),X(),Y(),
156 Mod(),Phi()*TMath::RadToDeg());