The SKIRT project
advanced radiative transfer for astrophysics
TetraMeshSpatialGrid::Tetra Class Reference

Public Member Functions

 Tetra (const vector< Vec > &vertices, const FourIndices &vertexIndices, const FourFaces &faces)
const Veccentroid () const
bool contains (const Position &bfr) const
double diagonal () const
Vec edge (int t1, int t2) const
const Boxextent () const
const FourFacesfaces () const
int findEnteringFace (const Vec &pos, const Direction &dir) const
double generateBarycentric (double &s, double &t, double &u) const
Position generatePosition (Random *random) const
Vec vertex (int t) const
double volume () const

Private Attributes

Vec _centroid
Box _extent
FourFaces _faces
FourIndices _vertexIndices
const vector< Vec > & _vertices

Detailed Description

Private class that represents a tetrahedron, storing all relevant information to fully describe its geometry and allow photon traversal through it.

Constructor & Destructor Documentation

◆ Tetra()

TetraMeshSpatialGrid::Tetra::Tetra ( const vector< Vec > & vertices,
const FourIndices & vertexIndices,
const FourFaces & faces )

This constructor initializes the tetrahedron by setting its fields and calculating the bounding box and centroid.

Member Function Documentation

◆ centroid()

const Vec & TetraMeshSpatialGrid::Tetra::centroid ( ) const

This function returns the centroid of the tetrahedron.

◆ contains()

bool TetraMeshSpatialGrid::Tetra::contains ( const Position & bfr) const

This function checks if the given position is contained inside the tetrahedron. It first checks if the position is inside the bounding box of the tetrahedron.

◆ diagonal()

double TetraMeshSpatialGrid::Tetra::diagonal ( ) const

This function calculates and returns the approximate diagonal of the tetrahedron. It calculates the square root of the average of the squared edge lengths.

◆ edge()

Vec TetraMeshSpatialGrid::Tetra::edge ( int t1,
int t2 ) const

This function returns the edge from vertex \(t1\) to \(t2\) of the tetrahedron, where \(t1, t2 \in \{0, 1, 2, 3\}\).

◆ extent()

const Box & TetraMeshSpatialGrid::Tetra::extent ( ) const

This function returns the extent of the tetrahedron.

◆ faces()

const FourFaces & TetraMeshSpatialGrid::Tetra::faces ( ) const

This function returns a reference to an array of the faces of the tetrahedron.

◆ findEnteringFace()

int TetraMeshSpatialGrid::Tetra::findEnteringFace ( const Vec & pos,
const Direction & dir ) const

This function finds a face that is not the leaving face which can act as the entering face in the traversal algorithm.

◆ generateBarycentric()

double TetraMeshSpatialGrid::Tetra::generateBarycentric ( double & s,
double & t,
double & u ) const

This function generates three random barycentric coordinates for uniformly sampling inside this tetrahedron. The fourth coordinate is calculated by ensuring their sum equals 1, i.e. r=1-s-t-u. Source: Generating Random Points in a Tetrahedron: DOI 10.1080/10867651.2000.10487528

◆ generatePosition()

Position TetraMeshSpatialGrid::Tetra::generatePosition ( Random * random) const

This function generates a random position inside the tetrahedron by generating random barycentric coordinates and using the vertices of the tetrahedron.

◆ vertex()

Vec TetraMeshSpatialGrid::Tetra::vertex ( int t) const

This function returns the vertex with index \(t\) of the tetrahedron, where \(t \in \{0, 1, 2, 3\}\).

◆ volume()

double TetraMeshSpatialGrid::Tetra::volume ( ) const

This function calculates and returns the volume of the tetrahedron.


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