#include <Position.hpp>
Public Types | |
enum class | CoordinateSystem { CARTESIAN , CYLINDRICAL , SPHERICAL } |
Public Member Functions | |
Position () | |
Position (Direction bfk) | |
Position (double r, Direction bfk) | |
Position (double u, double v, double w, CoordinateSystem coordtype) | |
Position (double x, double y, double z) | |
Position (Vec r) | |
void | cartesian (double &x, double &y, double &z) const |
void | cylindrical (double &R, double &phi, double &z) const |
double | cylRadius () const |
double | height () const |
double | radius () const |
void | spherical (double &r, double &theta, double &phi) const |
Public Member Functions inherited from Vec | |
Vec () | |
Vec (double x, double y, double z) | |
void | clear () |
bool | isNull () const |
double | norm () const |
double | norm2 () const |
Vec & | operator*= (double s) |
Vec & | operator+= (Vec v) |
Vec & | operator-= (Vec v) |
Vec & | operator/= (double s) |
void | set (double x, double y, double z) |
double | x () const |
double | y () const |
double | z () const |
Additional Inherited Members | |
Static Public Member Functions inherited from Vec | |
static Vec | cross (Vec a, Vec b) |
static double | dot (Vec a, Vec b) |
Protected Attributes inherited from Vec | |
double | _x |
double | _y |
double | _z |
An object of the Position class is used to define a position in three-dimensional space. To fully specify a position, three independent coordinates are necessary. Various options are possible. However in this class, a position is internally represented by means of its three cartesian coordinates \((x,y,z)\). Position is in fact publicly based on the Vec class, so that all functions and operators defined for Vec are automatically available for Position as well.
|
strong |
This enum has a constant for each of the supported coordinate systems.
|
inline |
The default constructor for the class Position creates a point in the origin of the reference system, with cartesian coordinates \((x,y,z)=(0,0,0)\).
|
inline |
Constructor for a position with given cartesian coordinates \(x\), \(y\) and \(z\).
|
inlineexplicit |
Constructor for a position with given cartesian coordinates \({\bf{r}}_x\), \({\bf{r}}_y\) and \({\bf{r}}_z\). It is declared explicit
to avoid implicit type conversions.
Position::Position | ( | double | u, |
double | v, | ||
double | w, | ||
CoordinateSystem | coordtype | ||
) |
Constructor for a position with three coordinates \((u,v,w)\) given in a coordinate system defined by the last argument. If the coordinate system is cartesian, the coordinates are just copied. If it is cylindrical, it is assumed that \((u,v,w) = (R,\phi,z)\) and the cartesian coordinates are calculated as
\[ \begin{split} x &= r\,\sin\theta\,\cos\varphi, \\ y &= r\,\sin\theta\,\sin\varphi, \\ z &= r\,\cos\theta, \end{split} \]
If spherical coordinates are used, we assume that \((u,v,w) = (r,\theta,\phi)\) and the cartesian coordinates are calculated as
\[ \begin{split} x &= R\,\cos\varphi, \\ y &= R\,\sin\varphi, \\ z &= z. \end{split} \]
Position::Position | ( | double | r, |
Direction | bfk | ||
) |
Constructor for a position, starting from a radius \(r\) and a direction \({\bf k}\). With \((k_x,k_y,k_z)\) the cartesian coordinates of \({\bf k}\), the construction of the cartesian coordinates for the position is straightforward,
\[ \begin{split} x &= r\,k_x, \\ y &= r\,k_y, \\ z &= r\,k_z. \end{split} \]
|
explicit |
Constructor for a position, starting from only a direction \({\bf k}\). This constructor hence generates a position on the unit sphere, and can be used to convert directions into positions. It is declared explicit
to avoid implicit type conversions.
void Position::cartesian | ( | double & | x, |
double & | y, | ||
double & | z | ||
) | const |
void Position::cylindrical | ( | double & | R, |
double & | phi, | ||
double & | z | ||
) | const |
This function determines the three cylindrical coordinates \((R,\varphi,z)\) of the position. The connection between these coordinates and the internally stored cartesian coordinates is
\[ \begin{split} R &= \sqrt{x^2+y^2}, \\ \varphi &= \arctan\left(\frac{y}{x}\right), \\ z &= z. \end{split} \]
double Position::cylRadius | ( | ) | const |
This function returns the radius of the projection of the position on the XY-plane, which is the radial coordinate in a cylindrical coordinate system. The formula simply reads
\[ R = \sqrt{x^2+y^2}. \]
Useful in systems with an axial symmetry, where only \(R\) and \(z\) are necessary to characterize the physical conditions at a given position.
double Position::height | ( | ) | const |
This function returns the height of a position above the XY-plane, i.e. the \(z\)-coordinate. Useful in systems with an axial symmetry, where only \(R\) and \(z\) are necessary to characterize the physical conditions at a given position.
double Position::radius | ( | ) | const |
void Position::spherical | ( | double & | r, |
double & | theta, | ||
double & | phi | ||
) | const |
This function determines the three spherical coordinates \((r,\theta,\phi)\) of the position. The connection between these coordinates and the internally stored cartesian coordinates is
\[ \begin{split} r &= \sqrt{x^2+y^2+z^2}, \\ \theta &= \arccos\left(\frac{z}{r}\right), \\ \varphi &= \arctan\left(\frac{y}{x}\right). \end{split} \]