DelaunayTriangulation
A C++ Object Oriented data structure with algorithms that could be used to generate a Delaunay triangulation
Functions
Utils Namespace Reference

Namespace of utility functions. More...

Functions

int lineLength (const std::string &line)
 Find number of parameters in file import lines. More...
 
template<typename Stream >
void loadFile (Stream &gStream, const std::string &fileName)
 Opens a stream with the specified file and verifies it has been opened correctly. More...
 
template<typename T >
double constantValueApprox (T func, const Triangle &triangle)
 Approximates integral of func over triangle using constant value approximation. More...
 
template<typename T >
double linearInterpolationApprox (T func, const Triangle &triangle)
 Approximates integral of func over triangle using linear interpolation approximation. More...
 

Detailed Description

Namespace of utility functions.

Function Documentation

◆ constantValueApprox()

template<typename T >
double Utils::constantValueApprox ( func,
const Triangle triangle 
)

Approximates integral of func over triangle using constant value approximation.

The integral of \( f(x,y) \) can be approximated as the value of the function at the circumcentre of the triangle \((O_{xT}, O_{yT})\) weighted by the triangle's area \( A_T \)

\[ \iint_T dxdy f(x,y) \approx A_T f(O_{xT}, O_{yT}) \]

Template Parameters
Tfunction of signature double(double, double)
Parameters
funcnumerical function returning value at point \((x,y)\)
triangleTriangle to approximate integral over
Returns
approximated integral of function over triangle

◆ linearInterpolationApprox()

template<typename T >
double Utils::linearInterpolationApprox ( func,
const Triangle triangle 
)

Approximates integral of func over triangle using linear interpolation approximation.

The integral of \( f(x,y) \) can be approximated as the value of the function at any point in the triangle weighted by the triangle's area \( A_T \) Given the barycentric coordinates of the point in the triangle \((\lambda_1, \lambda_2, \lambda_3)\) and a Triangle made up of points \(r_1, r_2, r_3\) where \(r_i = (x_i, y_i)\),

\[ \iint_T dxdy f(x,y) \approx A_T\left(\lambda_1f(x_1,y_1) + \lambda_2f(x_2,y_2) + \lambda_3f(x_3,y_3)\right) \]

Template Parameters
Tfunction of signature double(double, double)
Parameters
funcnumerical function returning value at point \((x,y)\)
triangleTriangle to approximate integral over
Returns
approximated integral of function over triangle

◆ lineLength()

int Utils::lineLength ( const std::string &  line)

Find number of parameters in file import lines.

Parameters
line
Returns
number of parameters in line

◆ loadFile()

template<typename Stream >
void Utils::loadFile ( Stream &  gStream,
const std::string &  fileName 
)

Opens a stream with the specified file and verifies it has been opened correctly.

Template Parameters
StreamStream of type std::ifstream or std::ofstream
Parameters
gStreamReference to stream to be opened
fileNameName of file for stream to be opened with
Exceptions
std::runtime_errorFile cannot be opened