1 #ifndef RIVET_MATH_VECTOR3 2 #define RIVET_MATH_VECTOR3 4 #include "Rivet/Math/MathHeader.hh" 5 #include "Rivet/Math/MathUtils.hh" 6 #include "Rivet/Math/VectorN.hh" 12 typedef Vector3 ThreeVector;
15 Vector3 multiply(
const double,
const Vector3&);
16 Vector3 multiply(
const Vector3&,
const double);
17 Vector3 add(
const Vector3&,
const Vector3&);
18 Vector3 operator*(
const double,
const Vector3&);
19 Vector3 operator*(
const Vector3&,
const double);
20 Vector3 operator/(
const Vector3&,
const double);
21 Vector3 operator+(
const Vector3&,
const Vector3&);
22 Vector3 operator-(
const Vector3&,
const Vector3&);
39 this->setX(other.x());
40 this->setY(other.y());
41 this->setZ(other.z());
45 this->setX(other.get(0));
46 this->setY(other.get(1));
47 this->setZ(other.get(2));
50 Vector3(
double x,
double y,
double z) {
68 double x()
const {
return get(0); }
69 double y()
const {
return get(1); }
70 double z()
const {
return get(2); }
71 Vector3& setX(
double x) {
set(0, x);
return *
this; }
72 Vector3& setY(
double y) {
set(1, y);
return *
this; }
73 Vector3& setZ(
double z) {
set(2, z);
return *
this; }
78 return _vec.dot(v._vec);
84 result._vec = _vec.
cross(v._vec);
91 if (localDotOther > 1.0)
return 0.0;
92 if (localDotOther < -1.0)
return M_PI;
93 return acos(localDotOther);
100 if (
isZero())
return *
this;
101 else return *
this * 1.0/this->
mod();
127 return x()*x() + y()*y();
157 const double value = atan2( y(), x() );
168 const double polarangle = atan2(
polarRadius(), z());
183 const double epsilon = DBL_EPSILON;
185 if ( m == 0.0 )
return 0.0;
186 double pt =
max(epsilon*m,
perp());
187 double rap = std::log((m + fabs(z()))/pt);
188 return z() > 0.0 ? rap: -rap;
203 Vector3& operator*=(
const double a) {
204 _vec = multiply(a, *
this)._vec;
208 Vector3& operator/=(
const double a) {
209 _vec = multiply(1.0/a, *
this)._vec;
214 _vec = add(*
this, v)._vec;
219 _vec = subtract(*
this, v)._vec;
243 result._vec = a * v._vec;
248 return multiply(a, v);
252 return multiply(a, v);
256 return multiply(a, v);
260 return multiply(1.0/a, v);
265 result._vec = a._vec + b._vec;
271 result._vec = a._vec - b._vec;
280 return subtract(a, b);
355 return sqrt(
deltaR2(v, eta2, phi2));
365 return sqrt(
deltaR2(eta1, phi1, v));
Definition: ALICE_2010_I880049.cc:13
Vector3 rhoVec() const
Synonym for polarVec.
Definition: Vector3.hh:121
bool isZero(double tolerance=1E-5) const
Check for nullness, allowing for numerical precision.
Definition: VectorN.hh:75
double mod2() const
Calculate the modulus-squared of a vector. .
Definition: VectorN.hh:84
double polarRadius() const
Polar radius.
Definition: Vector3.hh:139
double rho() const
Synonym for polarRadius.
Definition: Vector3.hh:147
double perp() const
Synonym for polarRadius.
Definition: Vector3.hh:143
double mapAngle(double angle, PhiMapping mapping)
Map an angle into the enum-specified range.
Definition: MathUtils.hh:547
Specialisation of MatrixN to aid 3 dimensional rotations.
Definition: Matrix3.hh:13
double angle(const Vector3 &v) const
Angle in radians to another vector.
Definition: Vector3.hh:89
Vector3 unitVec() const
Unit-normalized version of this vector.
Definition: Vector3.hh:98
Vector3 polarVec() const
Polar projection of this vector into the x-y plane.
Definition: Vector3.hh:111
double dot(const Vector3 &v) const
Dot-product with another vector.
Definition: Vector3.hh:77
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition: Vector3.hh:166
PhiMapping
Enum for range of to be mapped into.
Definition: MathHeader.hh:31
double pseudorapidity() const
Definition: Vector3.hh:182
double deltaPhi(double phi1, double phi2, bool sign=false)
Calculate the difference between two angles in radians.
Definition: MathUtils.hh:569
double rho2() const
Synonym for polarRadius2.
Definition: Vector3.hh:134
Vector3 cross(const Vector3 &v) const
Cross-product with another vector.
Definition: Vector3.hh:82
double deltaEta(double eta1, double eta2)
Definition: MathUtils.hh:577
A minimal base class for -dimensional vectors.
Definition: VectorN.hh:13
double deltaR2(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:590
double deltaR(double rap1, double phi1, double rap2, double phi2)
Definition: MathUtils.hh:597
double max(const vector< double > &in, double errval=DBL_NAN)
Find the maximum value in the vector.
Definition: Utils.hh:465
Vector3 perpVec() const
Synonym for polarVec.
Definition: Vector3.hh:117
double mapAngle0ToPi(double angle)
Map an angle into the range [0, PI].
Definition: MathUtils.hh:539
Vector3 unit() const
Synonym for unitVec.
Definition: Vector3.hh:105
std::enable_if< std::is_floating_point< NUM >::value, bool >::type isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition: MathUtils.hh:21
double azimuthalAngle(const PhiMapping mapping=ZERO_2PI) const
Angle subtended by the vector's projection in x-y and the x-axis.
Definition: Vector3.hh:152
double theta() const
Synonym for polarAngle.
Definition: Vector3.hh:173
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector3.hh:161
double abseta() const
Convenience shortcut for fabs(eta())
Definition: Vector3.hh:197
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
double eta() const
Synonym for pseudorapidity.
Definition: Vector3.hh:192
double polarRadius2() const
Square of the polar radius (.
Definition: Vector3.hh:126
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95
double perp2() const
Synonym for polarRadius2.
Definition: Vector3.hh:130
std::enable_if< std::is_arithmetic< NUM >::value, int >::type sign(NUM val)
Find the sign of a number.
Definition: MathUtils.hh:236