#include <threevector.h>
The ThreeVector class represents a physical three-vector \( \mathbf{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 \(-\mathbf{x}\). More... | |
ThreeVector | operator+= (const ThreeVector &v) |
Increase this vector by \(\mathbf{v}\): \( \mathbf{x}^\prime = \mathbf{x} + \mathbf{v} \). More... | |
ThreeVector | operator-= (const ThreeVector &v) |
Decrease this vector by \(\mathbf{v}\): \( \mathbf{x}^\prime = \mathbf{x} - \mathbf{v} \). More... | |
ThreeVector | operator*= (const double &a) |
Scale this vector by \(a\): \( \mathbf{x}^\prime = a \cdot \mathbf{x} \). More... | |
ThreeVector | operator/= (const double &a) |
Divide this vector by \(a\): \( \mathbf x^\prime = \frac{1}{a} \cdot \mathbf{x}\). More... | |
bool | operator== (const ThreeVector &rhs) const |
bool | operator!= (const ThreeVector &rhs) const |
ThreeVector | cross_product (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 141 of file threevector.h.
using smash::ThreeVector::const_iterator = std::array<double, 3>::const_iterator |
iterates over the components
Definition at line 143 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 |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 266 of file threevector.h.
|
inline |
Definition at line 268 of file threevector.h.
|
inline |
Definition at line 270 of file threevector.h.
|
inline |
|
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 283 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 304 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 315 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 326 of file threevector.h.
|
inline |
Negation: Returns \(-\mathbf{x}\).
Definition at line 189 of file threevector.h.
|
inline |
Increase this vector by \(\mathbf{v}\): \( \mathbf{x}^\prime = \mathbf{x} + \mathbf{v} \).
Definition at line 194 of file threevector.h.
|
inline |
Decrease this vector by \(\mathbf{v}\): \( \mathbf{x}^\prime = \mathbf{x} - \mathbf{v} \).
Definition at line 207 of file threevector.h.
|
inline |
Scale this vector by \(a\): \( \mathbf{x}^\prime = a \cdot \mathbf{x} \).
Definition at line 220 of file threevector.h.
|
inline |
Divide this vector by \(a\): \( \mathbf x^\prime = \frac{1}{a} \cdot \mathbf{x}\).
Definition at line 252 of file threevector.h.
|
inline |
Definition at line 131 of file threevector.h.
|
inline |
Definition at line 133 of file threevector.h.
|
inline |
Definition at line 246 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 151 of file threevector.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
the internal storage of the components.
Definition at line 168 of file threevector.h.