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) {
64 double x()
const {
return get(0); }
65 double y()
const {
return get(1); }
66 double z()
const {
return get(2); }
67 Vector3& setX(
double x) {
set(0, x);
return *
this; }
68 Vector3& setY(
double y) {
set(1, y);
return *
this; }
69 Vector3& setZ(
double z) {
set(2, z);
return *
this; }
71 double dot(
const Vector3& v)
const {
72 return _vec.dot(v._vec);
77 result._vec = _vec.cross(v._vec);
81 double angle(
const Vector3& v)
const {
82 const double localDotOther =
unit().dot(v.
unit());
84 else if (
fuzzyEquals(localDotOther, -1.0))
return M_PI;
85 return acos(localDotOther);
90 if (
isZero())
return *
this;
91 else return *
this * 1.0/this->
mod();
94 double polarRadius2()
const {
95 return x()*x() + y()*y();
100 return polarRadius2();
105 return polarRadius2();
108 double polarRadius()
const {
109 return sqrt(polarRadius2());
114 return polarRadius();
119 return polarRadius();
128 const double value = atan2( y(), x() );
140 const double polarangle = atan2(polarRadius(), z());
161 Vector3& operator*=(
const double a) {
162 _vec = multiply(a, *
this)._vec;
166 Vector3& operator/=(
const double a) {
167 _vec = multiply(1.0/a, *
this)._vec;
172 _vec = add(*
this, v)._vec;
177 _vec = subtract(*
this, v)._vec;
201 result._vec = a * v._vec;
206 return multiply(a, v);
210 return multiply(a, v);
214 return multiply(a, v);
218 return multiply(1.0/a, v);
223 result._vec = a._vec + b._vec;
229 result._vec = a._vec - b._vec;
238 return subtract(a, b);
249 inline double polarRadius2(
const Vector3& v) {
250 return v.polarRadius2();
263 return v.polarRadius();
282 return v.
phi(mapping);
315 inline double deltaEta(
const Vector3& v,
double eta2) {
320 inline double deltaEta(
double eta1,
const Vector3& v) {
336 inline double deltaPhi(
const Vector3& v,
double phi2) {
341 inline double deltaPhi(
double phi1,
const Vector3& v) {
358 inline double deltaR(
const Vector3& v,
double eta2,
double phi2) {
363 inline double deltaR(
double eta1,
double phi1,
const Vector3& v) {
Definition: MC_JetAnalysis.hh:9
bool isZero(double tolerance=1E-5) const
Check for nullness, allowing for numerical precision.
Definition: VectorN.hh:67
double mod2() const
Calculate the modulus-squared of a vector. .
Definition: VectorN.hh:76
double rho() const
Synonym for polarRadius.
Definition: Vector3.hh:118
double perp() const
Synonym for polarRadius.
Definition: Vector3.hh:113
double mapAngle(double angle, PhiMapping mapping)
Map an angle into the enum-specified range.
Definition: MathUtils.hh:441
Specialisation of MatrixN to aid 3 dimensional rotations.
Definition: Matrix3.hh:13
double polarAngle() const
Angle subtended by the vector and the z-axis.
Definition: Vector3.hh:138
PhiMapping
Enum for range of to be mapped into.
Definition: MathHeader.hh:63
double pseudorapidity() const
Definition: Vector3.hh:151
double rho2() const
Synonym for polarRadius2.
Definition: Vector3.hh:104
bool isZero(double val, double tolerance=1E-8)
Definition: MathUtils.hh:17
A minimal base class for -dimensional vectors.
Definition: VectorN.hh:13
double mapAngle0ToPi(double angle)
Map an angle into the range [0, PI].
Definition: MathUtils.hh:433
Vector3 unit() const
Definition: Vector3.hh:88
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:123
double theta() const
Synonym for polarAngle.
Definition: Vector3.hh:145
double phi(const PhiMapping mapping=ZERO_2PI) const
Synonym for azimuthalAngle.
Definition: Vector3.hh:133
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
double eta() const
Synonym for pseudorapidity.
Definition: Vector3.hh:156
bool fuzzyEquals(double a, double b, double tolerance=1E-5)
Compare two floating point numbers for equality with a degree of fuzziness.
Definition: MathUtils.hh:34
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:87
double perp2() const
Synonym for polarRadius2.
Definition: Vector3.hh:99