/usr/include/CLHEP/Vector/TwoVector.icc is in libclhep-dev 2.1.2.3-1.
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 | // -*- C++ -*-
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// This is the definitions of the inline member functions of the
// Hep2Vector class.
//
#include <cmath>
namespace CLHEP {
inline double Hep2Vector::x() const {
return dx;
}
inline double Hep2Vector::y() const {
return dy;
}
inline Hep2Vector::Hep2Vector(double x1, double y1)
: dx(x1), dy(y1) {}
inline Hep2Vector::Hep2Vector( const Hep3Vector & v3)
: dx(v3.x()), dy(v3.y()) {}
inline void Hep2Vector::setX(double x1) {
dx = x1;
}
inline void Hep2Vector::setY(double y1) {
dy = y1;
}
inline void Hep2Vector::set(double x1, double y1) {
dx = x1;
dy = y1;
}
double & Hep2Vector::operator[] (int i) { return operator()(i); }
double Hep2Vector::operator[] (int i) const { return operator()(i); }
inline Hep2Vector::Hep2Vector(const Hep2Vector & p)
: dx(p.x()), dy(p.y()) {}
inline Hep2Vector::~Hep2Vector() {}
inline Hep2Vector & Hep2Vector::operator = (const Hep2Vector & p) {
dx = p.x();
dy = p.y();
return *this;
}
inline bool Hep2Vector::operator == (const Hep2Vector& v) const {
return (v.x()==x() && v.y()==y()) ? true : false;
}
inline bool Hep2Vector::operator != (const Hep2Vector& v) const {
return (v.x()!=x() || v.y()!=y()) ? true : false;
}
inline Hep2Vector& Hep2Vector::operator += (const Hep2Vector & p) {
dx += p.x();
dy += p.y();
return *this;
}
inline Hep2Vector& Hep2Vector::operator -= (const Hep2Vector & p) {
dx -= p.x();
dy -= p.y();
return *this;
}
inline Hep2Vector Hep2Vector::operator - () const {
return Hep2Vector(-dx, -dy);
}
inline Hep2Vector& Hep2Vector::operator *= (double a) {
dx *= a;
dy *= a;
return *this;
}
inline double Hep2Vector::dot(const Hep2Vector & p) const {
return dx*p.x() + dy*p.y();
}
inline double Hep2Vector::mag2() const {
return dx*dx + dy*dy;
}
inline double Hep2Vector::mag() const {
return std::sqrt(mag2());
}
inline double Hep2Vector::r() const {
return std::sqrt(mag2());
}
inline Hep2Vector Hep2Vector::unit() const {
double tot = mag2();
Hep2Vector p(*this);
return tot > 0.0 ? p *= (1.0/std::sqrt(tot)) : Hep2Vector(1,0);
}
inline Hep2Vector Hep2Vector::orthogonal() const {
double x1 = std::fabs(dx), y1 = std::fabs(dy);
if (x1 < y1) {
return Hep2Vector(dy,-dx);
}else{
return Hep2Vector(-dy,dx);
}
}
inline double Hep2Vector::phi() const {
return dx == 0.0 && dy == 0.0 ? 0.0 : std::atan2(dy,dx);
}
inline double Hep2Vector::angle(const Hep2Vector & q) const {
double ptot2 = mag2()*q.mag2();
return ptot2 <= 0.0 ? 0.0 : std::acos(dot(q)/std::sqrt(ptot2));
}
inline void Hep2Vector::setMag(double r1){
double ph = phi();
setX( r1 * std::cos(ph) );
setY( r1 * std::sin(ph) );
}
inline void Hep2Vector::setR(double r1){
setMag(r1);
}
inline void Hep2Vector::setPhi(double phi1){
double ma = mag();
setX( ma * std::cos(phi1) );
setY( ma * std::sin(phi1) );
}
inline void Hep2Vector::setPolar(double r1, double phi1){
setX( r1 * std::cos(phi1) );
setY( r1 * std::sin(phi1) );
}
inline Hep2Vector operator + (const Hep2Vector & a, const Hep2Vector & b) {
return Hep2Vector(a.x() + b.x(), a.y() + b.y());
}
inline Hep2Vector operator - (const Hep2Vector & a, const Hep2Vector & b) {
return Hep2Vector(a.x() - b.x(), a.y() - b.y());
}
inline Hep2Vector operator * (const Hep2Vector & p, double a) {
return Hep2Vector(a*p.x(), a*p.y());
}
inline Hep2Vector operator * (double a, const Hep2Vector & p) {
return Hep2Vector(a*p.x(), a*p.y());
}
inline double operator * (const Hep2Vector & a, const Hep2Vector & b) {
return a.dot(b);
}
inline double Hep2Vector::getTolerance () {
return tolerance;
}
} // namespace CLHEP
|