The SKIRT project
advanced radiative transfer for astrophysics
Public Types | Public Member Functions | List of all members
Position Class Reference

#include <Position.hpp>

Inheritance diagram for Position:
Inheritance graph
[legend]

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
 
Vecoperator*= (double s)
 
Vecoperator+= (Vec v)
 
Vecoperator-= (Vec v)
 
Vecoperator/= (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
 

Detailed Description

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.

Member Enumeration Documentation

◆ CoordinateSystem

enum class Position::CoordinateSystem
strong

This enum has a constant for each of the supported coordinate systems.

Constructor & Destructor Documentation

◆ Position() [1/6]

Position::Position ( )
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)\).

◆ Position() [2/6]

Position::Position ( double  x,
double  y,
double  z 
)
inline

Constructor for a position with given cartesian coordinates \(x\), \(y\) and \(z\).

◆ Position() [3/6]

Position::Position ( Vec  r)
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() [4/6]

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() [5/6]

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} \]

◆ Position() [6/6]

Position::Position ( Direction  bfk)
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.

Member Function Documentation

◆ cartesian()

void Position::cartesian ( double &  x,
double &  y,
double &  z 
) const

This function returns the three cartesian coordinates \((x,y,z)\) of the position. Note that these cartesian coordinates are also directly accessible through the functions x(), y() and z() inherited from the Vec class.

◆ cylindrical()

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} \]

◆ cylRadius()

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.

◆ height()

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.

◆ radius()

double Position::radius ( ) const

This function returns the radius \(r\) of the position, i.e. the distance between the position and the centre of the reference system, given by

\[ r=\sqrt{x^2+y^2+z^2}. \]

This function returns the result of the norm() function inherited from the Vec class.

◆ spherical()

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} \]


The documentation for this class was generated from the following file: