#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 30 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) | |
| copy constructor 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 119 of file threevector.h.
| using smash::ThreeVector::const_iterator = std::array<double, 3>::const_iterator |
iterates over the components
Definition at line 121 of file threevector.h.
|
inline |
default constructor (nulls all components)
Definition at line 33 of file threevector.h.
|
inline |
copy constructor
Definition at line 36 of file threevector.h.
|
inline |
access the component at offset i.
Definition at line 39 of file threevector.h.
|
inline |
const overload of the above.
Definition at line 41 of file threevector.h.
|
inline |
Definition at line 155 of file threevector.h.
|
inline |
set first component
Definition at line 157 of file threevector.h.
|
inline |
Definition at line 159 of file threevector.h.
|
inline |
set second component
Definition at line 161 of file threevector.h.
|
inline |
Definition at line 163 of file threevector.h.
|
inline |
set third component
Definition at line 165 of file threevector.h.
|
inline |
Definition at line 249 of file threevector.h.
|
inline |
Definition at line 251 of file threevector.h.
|
inline |
Definition at line 253 of file threevector.h.
|
inline |
Definition at line 261 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 of phi about z, followed by the matrix for a rotation theta about the rotated x axis. Last, psi is a rotation about the rotated z axis.
| [in] | phi | angle by which the first rotation is done about z axis. |
| [in] | theta | angle by which the second rotation is done about the rotated x axis. |
| [in] | psi | angle by which the third rotation is done about the rotated z axis. |
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 266 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 287 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 298 of file threevector.h.
|
inline |
Rotate the z-axis onto the vector r.
| [in] | r | direction in which new new z-axis is aligned |
Definition at line 309 of file threevector.h.
|
inline |
negation: Returns \(-\vec x\)
Definition at line 167 of file threevector.h.
|
inline |
increase this vector by \(\vec v: \vec x^\prime = \vec x + \vec v\)
Definition at line 172 of file threevector.h.
|
inline |
decrease this vector by \(\vec v: \vec x^\prime = \vec x - \vec v\)
Definition at line 185 of file threevector.h.
|
inline |
scale this vector by \(a: \vec x^\prime = a \cdot \vec x\)
Definition at line 198 of file threevector.h.
|
inline |
divide this vector by \(a: \vec x^\prime = \frac{1}{a} \cdot \vec x\)
Definition at line 235 of file threevector.h.
|
inline |
Definition at line 109 of file threevector.h.
|
inline |
Definition at line 111 of file threevector.h.
|
inline |
Definition at line 229 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 129 of file threevector.h.
|
inline |
Definition at line 132 of file threevector.h.
|
inline |
const overload of the above
Definition at line 135 of file threevector.h.
|
inline |
const overload of the above
Definition at line 137 of file threevector.h.
|
inline |
Definition at line 140 of file threevector.h.
|
inline |
Definition at line 142 of file threevector.h.
|
private |
the internal storage of the components.
Definition at line 146 of file threevector.h.