Belle II Software  release-08-01-10
TriangularInterpolation Class Reference

The TriangularInterpolation class. More...

Collaboration diagram for TriangularInterpolation:

Public Member Functions

const vector< xy_t > & getPoints () const
 returns list of verticies
 
const vector< triangle_t > & getTriangles () const
 returns list of triangles
 
 TriangularInterpolation ()=default
 Default constructor.
 
 TriangularInterpolation (vector< xy_t > &pc, vector< triangle_t > &ts, double d)
 More complex constructor.
 
 ~TriangularInterpolation ()=default
 Destructor.
 
void init (vector< xy_t > &points, vector< triangle_t > &triangles, double d)
 Calculate extents of a triangular mesh and build spatial index. More...
 
xy_t triangleCenter (const triangle_t &p) const
 Calculate triangle center. More...
 
void makeIndex (int nx, double xmin, double xmax, int ny, double ymin, double ymax)
 Make spatial index. More...
 
short int sideCross (short int prev, short int curr, const xy_t &r, const xy_t &v0) const
 Determine which triangle side is crossed by a line segment defined by r and v0 points. More...
 
void weights (short int i, const xy_t &r, double &w0, double &w1, double &w2) const
 Calculate barycentric coordinates of a point inside triangle. More...
 
short int findTriangle (const xy_t &r0) const
 Find the triangle which contain the point. More...
 

Protected Attributes

vector< triangle_tm_triangles
 Triangle list.
 
vector< xy_tm_points
 Vertex list.
 
vector< xy_tm_triangleCenters
 Triangle centers.
 
vector< double > m_triangleAreas
 Triangle areas.
 
vector< short int > m_spatialIndex
 Spatial index.
 
double m_xmin
 Border of the region where the spatial index is constructed.
 
double m_xmax
 Border of the region where the spatial index is constructed.
 
double m_ymin
 Border of the region where the spatial index is constructed.
 
double m_ymax
 Border of the region where the spatial index is constructed.
 
unsigned int m_nx
 Spatial index grid size.
 
unsigned int m_ny
 Spatial index grid size.
 
double m_ixnorm {1}
 Reciprocals to speedup the index calculation.
 
double m_iynorm {1}
 Reciprocals to speedup the index calculation.
 

Detailed Description

The TriangularInterpolation class.

This class travers triangular meshes which satisfies the Delaunay condition. In other meshes it may give a wrong result. The mesh is represented by a list of triangles coupled to a list of xy-points. To speed up the traverse a sort of spatial index is constructed where on a regular cartesian grid the closeses triangle center is memorized.

Definition at line 61 of file BFieldComponentBeamline.cc.

Member Function Documentation

◆ findTriangle()

short int findTriangle ( const xy_t r0) const
inline

Find the triangle which contain the point.

If not returns the closest one. First using the spatial index locate triangle close to the point and then traverse the mesh using Delaunay triangulation properties.

Parameters
r02d cartesian point
Returns
Triangle index in the list

Definition at line 232 of file BFieldComponentBeamline.cc.

◆ init()

void init ( vector< xy_t > &  points,
vector< triangle_t > &  triangles,
double  d 
)
inline

Calculate extents of a triangular mesh and build spatial index.

Moves vector contents inside the class.

Parameters
pointsList of verticies
trianglesList of triangles
dHint how close spatial index should be built

Definition at line 88 of file BFieldComponentBeamline.cc.

◆ makeIndex()

void makeIndex ( int  nx,
double  xmin,
double  xmax,
int  ny,
double  ymin,
double  ymax 
)
inline

Make spatial index.

Parameters
nxGrid size in X axis
xminLow border on in X
xmaxUpper border on in X
nyGrid size in Y axis
yminLow border on in Y
ymaxUpper border on in Y

Definition at line 136 of file BFieldComponentBeamline.cc.

◆ sideCross()

short int sideCross ( short int  prev,
short int  curr,
const xy_t r,
const xy_t v0 
) const
inline

Determine which triangle side is crossed by a line segment defined by r and v0 points.

Parameters
prevTriangle number which has been already checked
currTriangle number which is being checked
rStarting point of the line segment
v0Ending point of the line segment
Returns
Next triangle index in the list if nothing found returns the total number of triangles in the list

Definition at line 181 of file BFieldComponentBeamline.cc.

◆ triangleCenter()

xy_t triangleCenter ( const triangle_t p) const
inline

Calculate triangle center.

Parameters
pTriangle

Definition at line 120 of file BFieldComponentBeamline.cc.

◆ weights()

void weights ( short int  i,
const xy_t r,
double &  w0,
double &  w1,
double &  w2 
) const
inline

Calculate barycentric coordinates of a point inside triangle.

Parameters
iTriangle index in the list
r2d cartesian point
w0Weight of 0 vertex
w1Weight of 1 vertex
w2Weight of 2 vertex

Definition at line 211 of file BFieldComponentBeamline.cc.


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