/usr/include/root/TVector2.h is in libroot-math-physics-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | // @(#)root/physics:$Id$
// Author: Pasha Murat 12/02/99
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TVector2
#define ROOT_TVector2
#include "TObject.h"
class TVector2 : public TObject {
//------------------------------------------------------------------------------
// data members
//------------------------------------------------------------------------------
protected:
Double_t fX; // components of the vector
Double_t fY;
//------------------------------------------------------------------------------
// function members
//------------------------------------------------------------------------------
public:
typedef Double_t Scalar; // to be able to use it with the ROOT::Math::VectorUtil functions
TVector2 ();
TVector2 (Double_t *s);
TVector2 (Double_t x0, Double_t y0);
virtual ~TVector2();
// ****** unary operators
TVector2& operator = (TVector2 const & v);
TVector2& operator += (TVector2 const & v);
TVector2& operator -= (TVector2 const & v);
Double_t operator *= (TVector2 const & v);
TVector2& operator *= (Double_t s);
TVector2& operator /= (Double_t s);
// ****** binary operators
friend TVector2 operator + (const TVector2&, const TVector2&);
friend TVector2 operator + (const TVector2&, Double_t );
friend TVector2 operator + (Double_t , const TVector2&);
friend TVector2 operator - (const TVector2&, const TVector2&);
friend TVector2 operator - (const TVector2&, Double_t );
friend Double_t operator * (const TVector2&, const TVector2&);
friend TVector2 operator * (const TVector2&, Double_t );
friend TVector2 operator * (Double_t , const TVector2&);
friend TVector2 operator / (const TVector2&, Double_t );
friend Double_t operator ^ (const TVector2&, const TVector2&);
// ****** setters
void Set(const TVector2& v);
void Set(Double_t x0, Double_t y0);
void Set(float x0, float y0);
// ****** other member functions
Double_t Mod2() const { return fX*fX+fY*fY; };
Double_t Mod () const;
Double_t Px() const { return fX; };
Double_t Py() const { return fY; };
Double_t X () const { return fX; };
Double_t Y () const { return fY; };
// phi() is defined in [0,TWOPI]
Double_t Phi () const;
Double_t DeltaPhi(const TVector2& v) const;
void SetMagPhi(Double_t mag, Double_t phi);
// unit vector in the direction of *this
TVector2 Unit() const;
TVector2 Ort () const;
// projection of *this to the direction
// of TVector2 vector `v'
TVector2 Proj(const TVector2& v) const;
// component of *this normal to `v'
TVector2 Norm(const TVector2& v) const;
// rotates 2-vector by phi radians
TVector2 Rotate (Double_t phi) const;
// returns phi angle in the interval [0,2*PI)
static Double_t Phi_0_2pi(Double_t x); // returns phi angle in the interval
// returns phi angle in the interval [-PI,PI)
static Double_t Phi_mpi_pi(Double_t x);
void Print(Option_t* option="") const;
ClassDef(TVector2,3) // A 2D physics vector
};
// ****** unary operators
inline TVector2& TVector2::operator = (TVector2 const& v) {fX = v.fX; fY = v.fY; return *this;}
inline TVector2& TVector2::operator += (TVector2 const& v) {fX += v.fX; fY += v.fY; return *this;}
inline TVector2& TVector2::operator -= (TVector2 const& v) {fX -= v.fX; fY -= v.fY; return *this;}
// scalar product of 2 2-vectors
inline Double_t TVector2::operator *= (const TVector2& v) { return(fX*v.fX+fY*v.fY); }
inline TVector2& TVector2::operator *= (Double_t s) { fX *=s; fY *=s; return *this; }
inline TVector2& TVector2::operator /= (Double_t s) { fX /=s; fY /=s; return *this; }
// ****** binary operators
inline TVector2 operator + (const TVector2& v1, const TVector2& v2) {
return TVector2(v1.fX+v2.fX,v1.fY+v2.fY);
}
inline TVector2 operator + (const TVector2& v1, Double_t bias) {
return TVector2 (v1.fX+bias,v1.fY+bias);
}
inline TVector2 operator + (Double_t bias, const TVector2& v1) {
return TVector2 (v1.fX+bias,v1.fY+bias);
}
inline TVector2 operator - (const TVector2& v1, const TVector2& v2) {
return TVector2(v1.fX-v2.fX,v1.fY-v2.fY);
}
inline TVector2 operator - (const TVector2& v1, Double_t bias) {
return TVector2 (v1.fX-bias,v1.fY-bias);
}
inline TVector2 operator * (const TVector2& v, Double_t s) {
return TVector2 (v.fX*s,v.fY*s);
}
inline TVector2 operator * (Double_t s, const TVector2& v) {
return TVector2 (v.fX*s,v.fY*s);
}
inline Double_t operator * (const TVector2& v1, const TVector2& v2) {
return v1.fX*v2.fX+v1.fY*v2.fY;
}
inline TVector2 operator / (const TVector2& v, Double_t s) {
return TVector2 (v.fX/s,v.fY/s);
}
inline Double_t operator ^ (const TVector2& v1, const TVector2& v2) {
return v1.fX*v2.fY-v1.fY*v2.fX;
}
inline Double_t TVector2::DeltaPhi(const TVector2& v) const { return Phi_mpi_pi(Phi()-v.Phi()); }
inline TVector2 TVector2::Ort () const { return Unit(); }
inline TVector2 TVector2::Proj(const TVector2& v) const { return v*(((*this)*v)/v.Mod2()); }
inline TVector2 TVector2::Norm(const TVector2& v) const {return *this-Proj(v); }
// ****** setters
inline void TVector2::Set(const TVector2& v ) { fX = v.fX; fY = v.fY; }
inline void TVector2::Set(Double_t x0, Double_t y0) { fX = x0 ; fY = y0 ; }
inline void TVector2::Set(float x0, float y0) { fX = x0 ; fY = y0 ; }
#endif
|