10 #ifndef SRC_INCLUDE_SMASH_THREEVECTOR_H_
11 #define SRC_INCLUDE_SMASH_THREEVECTOR_H_
53 :
x_({arr[0], arr[1], arr[2]}) {}
61 double inline x1()
const;
63 void inline set_x1(
double x);
65 double inline x2()
const;
67 void inline set_x2(
double y);
69 double inline x3()
const;
71 void inline set_x3(
double z);
73 double inline sqr()
const;
75 double inline abs()
const;
100 void inline rotate(
double phi,
double theta,
double psi);
177 std::array<double, 3>
x_;
252 return a.
x1() * b.
x1() + a.
x2() * b.
x2() + a.
x3() * b.
x3();
262 const double a_inv = 1.0 / a;
283 return std::atan2(
x2(),
x1());
289 return (r > 0.) ? std::acos(
x3() / r) : 0.;
294 const double cos_phi = std::cos(phi);
295 const double sin_phi = std::sin(phi);
296 const double cos_theta = std::cos(theta);
297 const double sin_theta = std::sin(theta);
298 const double cos_psi = std::cos(psi);
299 const double sin_psi = std::sin(psi);
301 std::array<double, 3> x_old =
x_;
303 x_[0] = (cos_phi * cos_psi - sin_phi * cos_theta * sin_psi) * x_old[0] +
304 (-cos_phi * sin_psi - sin_phi * cos_theta * cos_psi) * x_old[1] +
305 (sin_phi * sin_theta) * x_old[2];
306 x_[1] = (sin_phi * cos_psi + cos_phi * cos_theta * sin_psi) * x_old[0] +
307 (-sin_phi * sin_psi + cos_phi * cos_theta * cos_psi) * x_old[1] +
308 (-cos_phi * sin_theta) * x_old[2];
309 x_[2] = (sin_theta * sin_psi) * x_old[0] + (sin_theta * cos_psi) * x_old[1] +
310 (cos_theta)*x_old[2];
314 const double cost = std::cos(theta);
315 const double sint = std::sin(theta);
317 std::array<double, 3> x_old =
x_;
319 x_[0] = cost * x_old[0] + sint * x_old[2];
321 x_[2] = -sint * x_old[0] + cost * x_old[2];
325 const double cost = std::cos(theta);
326 const double sint = std::sin(theta);
328 std::array<double, 3> x_old =
x_;
330 x_[0] = cost * x_old[0] - sint * x_old[1];
331 x_[1] = sint * x_old[0] + cost * x_old[1];
The ThreeVector class represents a physical three-vector with the components .
std::array< double, 3 > x_
the internal storage of the components.
ThreeVector operator-=(const ThreeVector &v)
Decrease this vector by : .
void set_x1(double x)
set first component
ThreeVector(double y1, double y2, double y3)
Constructor for ThreeVector that takes 3 doubles to set up a ThreeVector with desired values for the ...
std::array< double, 3 >::iterator iterator
iterates over the components
void rotate_around_y(double theta)
Rotate the vector around the y axis by the given angle theta.
const_iterator begin() const
const overload of the above
bool operator!=(const ThreeVector &rhs) const
const_iterator cbegin() const
void rotate_around_z(double theta)
Rotate the vector around the z axis by the given angle theta.
void set_x3(double z)
set third component
void rotate(double phi, double theta, double psi)
Rotate vector by the given Euler angles phi, theta, psi.
ThreeVector operator*=(const double &a)
Scale this vector by : .
void set_x2(double y)
set second component
bool operator==(const ThreeVector &rhs) const
void rotate_z_axis_to(ThreeVector &r)
Rotate the z-axis onto the vector r.
ThreeVector(std::array< double, 3 > arr)
Constructor for ThreeVector that takes an array of 3 doubles to set up a ThreeVector with desired val...
double & operator[](std::size_t i)
access the component at offset i.
ThreeVector operator+=(const ThreeVector &v)
Increase this vector by : .
ThreeVector operator/=(const double &a)
Divide this vector by : .
const_iterator cend() const
ThreeVector cross_product(const ThreeVector &b) const
double operator[](std::size_t i) const
const overload of the above.
ThreeVector()
default constructor (nulls all components)
const_iterator end() const
const overload of the above
ThreeVector operator-() const
Negation: Returns .
std::array< double, 3 >::const_iterator const_iterator
iterates over the components
Collection of useful constants that are known at compile time.
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
constexpr double really_small
Numerical error tolerance.
EnergyMomentumTensor operator+(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct addition operator.
EnergyMomentumTensor operator/(EnergyMomentumTensor a, const double b)
Direct division operator.