10 #ifndef SRC_INCLUDE_THREEVECTOR_H_ 11 #define SRC_INCLUDE_THREEVECTOR_H_ 44 double inline x1()
const;
46 void inline set_x1(
double x);
48 double inline x2()
const;
50 void inline set_x2(
double y);
52 double inline x3()
const;
54 void inline set_x3(
double z);
56 double inline sqr()
const;
58 double inline abs()
const;
81 void inline rotate(
double phi,
double theta,
double psi);
146 std::array<double, 3>
x_;
222 return a.
x1() * b.
x1() + a.
x2() * b.
x2() + a.
x3() * b.
x3();
236 const double a_inv = 1.0 / a;
257 return std::atan2(
x2(),
x1());
263 return (r > 0.) ? std::acos(
x3() / r) : 0.;
268 const double cos_phi = std::cos(phi);
269 const double sin_phi = std::sin(phi);
270 const double cos_theta = std::cos(theta);
271 const double sin_theta = std::sin(theta);
272 const double cos_psi = std::cos(psi);
273 const double sin_psi = std::sin(psi);
275 std::array<double, 3> x_old =
x_;
277 x_[0] = (cos_phi * cos_psi - sin_phi * cos_theta * sin_psi) * x_old[0] +
278 (sin_phi * cos_psi + cos_phi * cos_theta * sin_psi) * x_old[1] +
279 sin_theta * sin_psi * x_old[2];
280 x_[1] = (-cos_phi * sin_psi - sin_phi * cos_theta * cos_psi) * x_old[0] +
281 (-sin_phi * sin_psi + cos_phi * cos_theta * cos_psi) * x_old[1] +
282 sin_theta * cos_psi * x_old[2];
283 x_[2] = sin_phi * sin_theta * x_old[0] - cos_phi * sin_theta * x_old[1] +
284 cos_theta * x_old[2];
288 const double cost = std::cos(theta);
289 const double sint = std::sin(theta);
291 std::array<double, 3> x_old =
x_;
293 x_[0] = cost * x_old[0] + sint * x_old[2];
295 x_[2] = -sint * x_old[0] + cost * x_old[2];
299 const double cost = std::cos(theta);
300 const double sint = std::sin(theta);
302 std::array<double, 3> x_old =
x_;
304 x_[0] = cost * x_old[0] - sint * x_old[1];
305 x_[1] = sint * x_old[0] + cost * x_old[1];
316 #endif // SRC_INCLUDE_THREEVECTOR_H_ ThreeVector operator/=(const double &a)
divide this vector by
double operator[](std::size_t i) const
const overload of the above.
double & operator[](std::size_t i)
access the component at offset i.
The ThreeVector class represents a physical three-vector with the components .
constexpr double really_small
Numerical error tolerance.
const_iterator begin() const
const overload of the above
EnergyMomentumTensor operator/(EnergyMomentumTensor a, const double b)
Direct division operator.
ThreeVector CrossProduct(const ThreeVector &b) const
ThreeVector operator+=(const ThreeVector &v)
increase this vector by
Collection of useful constants that are known at compile time.
EnergyMomentumTensor operator+(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct addition operator.
bool operator!=(const ThreeVector &rhs) const
std::array< double, 3 > x_
the internal storage of the components.
ThreeVector operator*=(const double &a)
scale this vector by
ThreeVector()
default constructor (nulls all components)
const_iterator cbegin() const
void rotate_around_y(double theta)
Rotate the vector around the y axis by the given angle theta.
void set_x1(double x)
set first component
void rotate_z_axis_to(ThreeVector &r)
Rotate the z-axis onto the vector r.
std::array< double, 3 >::const_iterator const_iterator
iterates over the components
void rotate_around_z(double theta)
Rotate the vector around the z axis by the given angle theta.
ThreeVector operator-=(const ThreeVector &v)
decrease this vector by
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
std::array< double, 3 >::iterator iterator
iterates over the components
void set_x3(double z)
set third component
ThreeVector(double y1, double y2, double y3)
copy constructor
ThreeVector operator-() const
negation: Returns
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
const_iterator cend() const
const_iterator end() const
const overload of the above
void set_x2(double y)
set second component
void rotate(double phi, double theta, double psi)
Rotate vector by the given Euler angles phi, theta, psi.
bool operator==(const ThreeVector &rhs) const