1 #ifndef RIVET_MATH_VECTOR2 2 #define RIVET_MATH_VECTOR2 4 #include "Rivet/Math/MathConstants.hh" 5 #include "Rivet/Math/MathUtils.hh" 6 #include "Rivet/Math/VectorN.hh" 12 typedef Vector2 TwoVector;
15 Vector2 multiply(
const double,
const Vector2&);
16 Vector2 multiply(
const Vector2&,
const double);
17 Vector2 add(
const Vector2&,
const Vector2&);
18 Vector2 operator*(
const double,
const Vector2&);
19 Vector2 operator*(
const Vector2&,
const double);
20 Vector2
operator/(
const Vector2&,
const double);
21 Vector2 operator+(
const Vector2&,
const Vector2&);
22 Vector2 operator-(
const Vector2&,
const Vector2&);
39 this->setX(other.x());
40 this->setY(other.y());
44 this->setX(other.get(0));
45 this->setY(other.get(1));
64 double x()
const {
return get(0); }
65 double y()
const {
return get(1); }
66 Vector2& setX(
double x) {
set(0, x);
return *
this; }
67 Vector2& setY(
double y) {
set(1, y);
return *
this; }
72 return _vec.dot(v._vec);
78 if (localDotOther > 1.0)
return 0.0;
79 if (localDotOther < -1.0)
return M_PI;
80 return acos(localDotOther);
87 if ( md <= 0.0 )
return Vector2();
88 else return *
this * 1.0/md;
98 Vector2& operator*=(
const double a) {
99 _vec = multiply(a, *
this)._vec;
103 Vector2& operator/=(
const double a) {
104 _vec = multiply(1.0/a, *
this)._vec;
109 _vec = add(*
this, v)._vec;
114 _vec = subtract(*
this, v)._vec;
134 result._vec = a * v._vec;
139 return multiply(a, v);
143 return multiply(a, v);
147 return multiply(a, v);
151 return multiply(1.0/a, v);
156 result._vec = a._vec + b._vec;
162 result._vec = a._vec - b._vec;
171 return subtract(a, b);
Definition: MC_Cent_pPb.hh:10
double angle(const Vector2 &v) const
Angle in radians to another vector.
Definition: Vector2.hh:76
string operator/(const string &a, const string &b)
Operator for joining strings a and b with filesystem separators.
Definition: Utils.hh:260
Vector2 unit() const
Synonym for unitVec.
Definition: Vector2.hh:92
Vector2 unitVec() const
Unit-normalized version of this vector.
Definition: Vector2.hh:85
Two-dimensional specialisation of Vector.
Definition: Vector2.hh:26
A minimal base class for -dimensional vectors.
Definition: VectorN.hh:13
double dot(const Vector2 &v) const
Dot-product with another vector.
Definition: Vector2.hh:71
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:95