#include <CylindricalCell.hpp>
Public Member Functions | |
CylindricalCell () | |
CylindricalCell (double Rmin, double phimin, double zmin, double Rmax, double phimax, double zmax) | |
Box | boundingBox () const |
Position | center () const |
bool | contains (Vec r) const |
void | extent (double &Rmin, double &phimin, double &zmin, double &Rmax, double &phimax, double &zmax) const |
double | intersection (Vec r, const Vec k) const |
double | phimax () const |
double | phimin () const |
double | Rmax () const |
double | Rmin () const |
double | volume () const |
double | zmax () const |
double | zmin () const |
Private Attributes | |
double | _cosphimax |
double | _cosphimin |
double | _phimax |
double | _phimin |
double | _Rmax |
double | _Rmin |
double | _sinphimax |
double | _sinphimin |
double | _zmax |
double | _zmin |
CylindricalCell is a low-level class for working with basic three-dimensional cells in cylindrical coordinates. Each CylindricalCell instance represents a cell bordered by:
The class offers functions to retrieve various basic properties of the cell, such as its border coordinates and its volume, and for geometric operations such as determining whether a given Cartesian position is inside the cell or calculating the intersection with a ray.
|
inline |
The default constructor creates an empty cell at the origin, i.e. it initializes all border coordinates to zero.
CylindricalCell::CylindricalCell | ( | double | Rmin, |
double | phimin, | ||
double | zmin, | ||
double | Rmax, | ||
double | phimax, | ||
double | zmax | ||
) |
This constructor initializes the cell border coordinates to the values provided as arguments. It does not verify that these values conform to the limits described in the class header. Non-conforming values lead to undefined behavior.
Box CylindricalCell::boundingBox | ( | ) | const |
This function returns the Cartesian bounding box of the cell, in other words the smallest cuboid lined up with the Cartesian coordinate axes that encloses the cell.
The bounds along the z-axis are the same for Cylindrical and Cartesian coordinates, but the function needs to specifically determine the bounding rectangle projected on the xy plane. This bounding rectangle must of course enclose the four corner points of the cell. In addition, if the cell straddles one of the coordinate axes, the bounding rectangle must also enclose a point on that axis at radius
Position CylindricalCell::center | ( | ) | const |
This function returns the "center" of the cell in Cartesian coordinates. This position is defined as the halfway point between the cell borders in cylindrical coordinates, i.e.
As stated above the function returns this position after converting it to Cartesian coordinates.
bool CylindricalCell::contains | ( | Vec | r | ) | const |
This function returns true if the Cartesian position
|
inline |
This function stores the cell border coordinates in the provided arguments.
This function intersects the receiving cell with a ray (half-line) defined by the specified starting position
A ray that touches the cell border in a single point is not considered to intersect. A ray along an edge or face on the "lower" side of the cell is considered to intersect, while ray along an edge or face on the "upper" side of the cell is considered not to intersect. This approach avoids duplicate intersection of adjacent cells.
Implementation
The function uses the following strategy. First it calculates all intersection points with the bordering planes and cylinders and sorts them on distance along the ray. Then, for each segment between consecutive intersections beyond the ray's starting point, it determines whether the segment's midpoint is inside the cell or not, and accumulates the lengths of the inside segments. This automatically takes care of the cases where the ray lies in one of the bordering planes or cylinders.
The ray equation can be written as
Intersection with a horizontal plane with equation
Intersection with a meridional plane with equation
Intersection with a vertical cylinder centered on the origin with equation
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
double CylindricalCell::volume | ( | ) | const |
This function returns the volume of the cell, given by
|
inline |
This function returns the
|
inline |
This function returns the