#include <SphericalCell.hpp>
Public Member Functions | |
SphericalCell () | |
SphericalCell (double rmin, double thetamin, double phimin, double rmax, double thetamax, double phimax) | |
Box | boundingBox () const |
Position | center () const |
bool | contains (Vec bfr) const |
void | extent (double &rmin, double &thetamin, double &phimin, double &rmax, double &thetamax, double &phimax) const |
double | intersection (Vec r, const Vec k) const |
double | phimax () const |
double | phimin () const |
double | rmax () const |
double | rmin () const |
double | thetamax () const |
double | thetamin () const |
double | volume () const |
SphericalCell is a low-level class for working with basic three-dimensional cells in spherical coordinates. Each SphericalCell 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.
SphericalCell::SphericalCell | ( | double | rmin, |
double | thetamin, | ||
double | phimin, | ||
double | rmax, | ||
double | thetamax, | ||
double | phimax | ||
) |
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 SphericalCell::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 intersection of a conical cell boundary and a spherical cell boundary is a horizontal circle segment. This means that the z coordinate of the intersection does not depend on
For the projection on the equatorial plane, things are more complicated. If the cell straddles an x or y axis in the azimuthal direction, or if it straddles the xy plane in the polar direction, the projection of the outer sphere boundary on the x and/or y axes extends beyond the projection of the cell corner points. The bounding box must thus enclose the corresponding extreme points in addition to the cell corner points.
Position SphericalCell::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 spherical coordinates, i.e.
As stated above the function returns this position after converting it to Cartesian coordinates.
bool SphericalCell::contains | ( | Vec | bfr | ) | 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 surfaces 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 surfaces.
The ray can be represented by its parameter equation
The two intersection points with a radial boundary sphere
The two intersection points with an angular boundary cone
The intersection point with a meriodonal plane
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
|
inline |
This function returns the
double SphericalCell::volume | ( | ) | const |
This function returns the volume of the cell, given by