10 #ifndef SRC_INCLUDE_SMASH_THREEVECTOR_H_
11 #define SRC_INCLUDE_SMASH_THREEVECTOR_H_
52 double inline x1()
const;
54 void inline set_x1(
double x);
56 double inline x2()
const;
58 void inline set_x2(
double y);
60 double inline x3()
const;
62 void inline set_x3(
double z);
64 double inline sqr()
const;
66 double inline abs()
const;
91 void inline rotate(
double phi,
double theta,
double psi);
168 std::array<double, 3>
x_;
243 return a.
x1() * b.
x1() + a.
x2() * b.
x2() + a.
x3() * b.
x3();
253 const double a_inv = 1.0 / a;
274 return std::atan2(
x2(),
x1());
280 return (r > 0.) ? std::acos(
x3() / r) : 0.;
285 const double cos_phi = std::cos(phi);
286 const double sin_phi = std::sin(phi);
287 const double cos_theta = std::cos(theta);
288 const double sin_theta = std::sin(theta);
289 const double cos_psi = std::cos(psi);
290 const double sin_psi = std::sin(psi);
292 std::array<double, 3> x_old =
x_;
294 x_[0] = (cos_phi * cos_psi - sin_phi * cos_theta * sin_psi) * x_old[0] +
295 (-cos_phi * sin_psi - sin_phi * cos_theta * cos_psi) * x_old[1] +
296 (sin_phi * sin_theta) * x_old[2];
297 x_[1] = (sin_phi * cos_psi + cos_phi * cos_theta * sin_psi) * x_old[0] +
298 (-sin_phi * sin_psi + cos_phi * cos_theta * cos_psi) * x_old[1] +
299 (-cos_phi * sin_theta) * x_old[2];
300 x_[2] = (sin_theta * sin_psi) * x_old[0] + (sin_theta * cos_psi) * x_old[1] +
301 (cos_theta)*x_old[2];
305 const double cost = std::cos(theta);
306 const double sint = std::sin(theta);
308 std::array<double, 3> x_old =
x_;
310 x_[0] = cost * x_old[0] + sint * x_old[2];
312 x_[2] = -sint * x_old[0] + cost * x_old[2];
316 const double cost = std::cos(theta);
317 const double sint = std::sin(theta);
319 std::array<double, 3> x_old =
x_;
321 x_[0] = cost * x_old[0] - sint * x_old[1];
322 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.
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.