#include <threevector.h>
The ThreeVector class represents a physical three-vector \( \vec{x} = (x_1,x_2,x_3)\) with the components \( x_1,x_2,x_3 \).
It is related to the classes FourVector and Angles, both of which can be converted into a ThreeVector using the 'threevec()' method.
Definition at line 31 of file threevector.h.
Public Types | |
using | iterator = std::array< double, 3 >::iterator |
iterates over the components More... | |
using | const_iterator = std::array< double, 3 >::const_iterator |
iterates over the components More... | |
Public Member Functions | |
ThreeVector () | |
default constructor (nulls all components) More... | |
ThreeVector (double y1, double y2, double y3) | |
Constructor for ThreeVector that takes 3 doubles to set up a ThreeVector with desired values for the components. More... | |
double & | operator[] (std::size_t i) |
access the component at offset i . More... | |
double | operator[] (std::size_t i) const |
const overload of the above. More... | |
double | x1 () const |
void | set_x1 (double x) |
set first component More... | |
double | x2 () const |
void | set_x2 (double y) |
set second component More... | |
double | x3 () const |
void | set_x3 (double z) |
set third component More... | |
double | sqr () const |
double | abs () const |
double | get_phi () const |
double | get_theta () const |
void | rotate (double phi, double theta, double psi) |
Rotate vector by the given Euler angles phi, theta, psi. More... | |
void | rotate_around_y (double theta) |
Rotate the vector around the y axis by the given angle theta. More... | |
void | rotate_around_z (double theta) |
Rotate the vector around the z axis by the given angle theta. More... | |
void | rotate_z_axis_to (ThreeVector &r) |
Rotate the z-axis onto the vector r. More... | |
ThreeVector | operator- () const |
negation: Returns \(-\vec x\) More... | |
ThreeVector | operator+= (const ThreeVector &v) |
increase this vector by \(\vec v: \vec x^\prime = \vec x + \vec v\) More... | |
ThreeVector | operator-= (const ThreeVector &v) |
decrease this vector by \(\vec v: \vec x^\prime = \vec x - \vec v\) More... | |
ThreeVector | operator*= (const double &a) |
scale this vector by \(a: \vec x^\prime = a \cdot \vec x\) More... | |
ThreeVector | operator/= (const double &a) |
divide this vector by \(a: \vec x^\prime = \frac{1}{a} \cdot \vec x\) More... | |
bool | operator== (const ThreeVector &rhs) const |
bool | operator!= (const ThreeVector &rhs) const |
ThreeVector | CrossProduct (const ThreeVector &b) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const overload of the above More... | |
const_iterator | end () const |
const overload of the above More... | |
const_iterator | cbegin () const |
const_iterator | cend () const |
Private Attributes | |
std::array< double, 3 > | x_ |
the internal storage of the components. More... | |
using smash::ThreeVector::iterator = std::array<double, 3>::iterator |
iterates over the components
Definition at line 129 of file threevector.h.
using smash::ThreeVector::const_iterator = std::array<double, 3>::const_iterator |
iterates over the components
Definition at line 131 of file threevector.h.
|
inline |
default constructor (nulls all components)
Definition at line 34 of file threevector.h.
|
inline |
Constructor for ThreeVector that takes 3 doubles to set up a ThreeVector with desired values for the components.
[in] | y1 | value of the first component |
[in] | y2 | value of the second component |
[in] | y3 | value of the third component |
Definition at line 44 of file threevector.h.
|
inline |
access the component at offset i
.
Definition at line 47 of file threevector.h.
|
inline |
const overload of the above.
Definition at line 49 of file threevector.h.
|
inline |
Definition at line 165 of file threevector.h.
|
inline |
set first component
Definition at line 167 of file threevector.h.
|
inline |
Definition at line 169 of file threevector.h.
|
inline |
set second component
Definition at line 171 of file threevector.h.
|
inline |
Definition at line 173 of file threevector.h.
|
inline |
set third component
Definition at line 175 of file threevector.h.
|
inline |
Definition at line 259 of file threevector.h.
|
inline |
Definition at line 261 of file threevector.h.
|
inline |
Definition at line 263 of file threevector.h.
|
inline |
Definition at line 271 of file threevector.h.
|
inline |
Rotate vector by the given Euler angles phi, theta, psi.
If we assume the standard basis x, y, z, then this means applying the matrix for a rotation by phi about the z-axis, followed by the matrix for a rotation by theta about the rotated x-axis. Last, psi is a rotation about the rotated z-axis. To reverse the rotation one has to therefore exchange phi and psi and use the negative values for all angles.
[in] | phi | angle by which the first rotation is done about the z-axis. Range: [0,2&pi] |
[in] | theta | angle by which the second rotation is done about the rotated x-axis. Range: [0,&pi] |
[in] | psi | angle by which the third rotation is done about the rotated z-axis. Range: [0,2&pi] |
Euler angles are used to make rotation of several (different) position vectors belonging to one rigid body easy. A ThreeVector could be rotated via only two angles, but then the angles for rotating a rigid body consisting of multiple particles would require a different pair of rotation angles for every position.
Definition at line 276 of file threevector.h.
|
inline |
Rotate the vector around the y axis by the given angle theta.
[in] | theta | angle by which the rotation is done about y axis. |
Definition at line 297 of file threevector.h.
|
inline |
Rotate the vector around the z axis by the given angle theta.
[in] | theta | angle by which the rotation is done about z axis. |
Definition at line 308 of file threevector.h.
|
inline |
Rotate the z-axis onto the vector r.
[in] | r | direction in which new z-axis is aligned |
Definition at line 319 of file threevector.h.
|
inline |
negation: Returns \(-\vec x\)
Definition at line 177 of file threevector.h.
|
inline |
increase this vector by \(\vec v: \vec x^\prime = \vec x + \vec v\)
Definition at line 182 of file threevector.h.
|
inline |
decrease this vector by \(\vec v: \vec x^\prime = \vec x - \vec v\)
Definition at line 195 of file threevector.h.
|
inline |
scale this vector by \(a: \vec x^\prime = a \cdot \vec x\)
Definition at line 208 of file threevector.h.
|
inline |
divide this vector by \(a: \vec x^\prime = \frac{1}{a} \cdot \vec x\)
Definition at line 245 of file threevector.h.
|
inline |
Definition at line 119 of file threevector.h.
|
inline |
Definition at line 121 of file threevector.h.
|
inline |
Definition at line 239 of file threevector.h.
|
inline |
The iterator implements the randomIterator concept. Thus, you can simply write begin() + 1
to get an iterator that points to the 1st component.
Definition at line 139 of file threevector.h.
|
inline |
Definition at line 142 of file threevector.h.
|
inline |
const overload of the above
Definition at line 145 of file threevector.h.
|
inline |
const overload of the above
Definition at line 147 of file threevector.h.
|
inline |
Definition at line 150 of file threevector.h.
|
inline |
Definition at line 152 of file threevector.h.
|
private |
the internal storage of the components.
Definition at line 156 of file threevector.h.