20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wshadow"
25#pragma GCC diagnostic pop
72 if (
n == 0 || !
x || !
y || !z )
return;
75 xmin = *std::min_element(
x,
x+
n);
76 xmax = *std::max_element(
x,
x+
n);
78 ymin = *std::min_element(
y,
y+
n);
79 ymax = *std::max_element(
y,
y+
n);
180 for (i = 0; i < fNpoints; ++i) points[i] = CDT::V2d<double>(
fXN[i],
fYN[i]);
181 CDT::RemoveDuplicates(
points);
184 "This TGraph2D has duplicated vertices. To remove them call RemoveDuplicates before drawing");
186 CDT::Triangulation<double> cdt;
187 cdt.insertVertices(
points);
188 cdt.eraseSuperTriangle();
190 auto AllTriangles = cdt.triangles;
191 auto AllVertices = cdt.vertices;
198 const auto& t = AllTriangles[i];
200 const auto&
v0 = AllVertices[t.vertices[0]];
203 tri.
idx[0] = t.vertices[0];
205 const auto&
v1 = AllVertices[t.vertices[1]];
208 tri.
idx[1] = t.vertices[1];
210 const auto&
v2 = AllVertices[t.vertices[2]];
213 tri.
idx[2] = t.vertices[2];
215 tri.
invDenom = 1 / ( (tri.
y[1] - tri.
y[2])*(tri.
x[0] - tri.
x[2]) + (tri.
x[2] - tri.
x[1])*(tri.
y[0] - tri.
y[2]) );
219 auto bx = std::minmax({tri.
x[0], tri.
x[1], tri.
x[2]});
220 auto by = std::minmax({tri.
y[0], tri.
y[1], tri.
y[2]});
222 unsigned int cellXmin =
CellX(bx.first);
223 unsigned int cellXmax =
CellX(bx.second);
225 unsigned int cellYmin =
CellY(by.first);
226 unsigned int cellYmax =
CellY(by.second);
228 for(
unsigned int j = cellXmin; j <= cellXmax; j++) {
229 for(
unsigned int k = cellYmin; k <= cellYmax; k++) {
247 auto bayCoords = [&](
const unsigned int t) -> std::tuple<double, double, double> {
255 return std::make_tuple(la, lb, (1 - la - lb));
263 auto inTriangle = [](
const std::tuple<double, double, double> &coords) ->
bool {
264 constexpr double eps = -4 * std::numeric_limits<double>::epsilon();
265 return std::get<0>(coords) > eps && std::get<1>(coords) > eps && std::get<2>(coords) > eps;
276 auto coords = bayCoords(t);
281 if (inTriangle(coords)) {
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
int fNpoints
! Number of data points
double fXNmin
! Minimum value of fXN
std::set< unsigned int > fCells[(fNCells+1) *(fNCells+1)]
! grid cells with containing triangles
int fNdt
! Number of Delaunay triangles found
double DoInterpolateNormalized(double x, double y)
internal method to compute the interpolation
int CellY(double y) const
double Interpolate(double x, double y)
Return the Interpolated z value corresponding to the given (x,y) point.
const double * fZ
! Pointer to Z array
double fXNmax
! Maximum value of fXN
double fZout
! Height for points lying outside the convex hull
double fOffsetY
! Normalization offset Y
Triangles fTriangles
! Triangles of Triangulation
double Linear_transform(double x, double offset, double factor)
double fYCellStep
! inverse denominator to calculate X cell = fNCells / (fYNmax - fYNmin)
std::vector< double > fYN
! normalized Y
Delaunay2D(int n, const double *x, const double *y, const double *z, double xmin=0, double xmax=0, double ymin=0, double ymax=0)
class constructor from array of data points
void FindAllTriangles()
Find all triangles.
static const int fNCells
! number of cells to divide the normalized space
bool fInit
! True if FindAllTriangles() has been performed
unsigned int Cell(unsigned int x, unsigned int y) const
std::vector< double > fXN
! normalized X
double fXCellStep
! inverse denominator to calculate X cell = fNCells / (fXNmax - fXNmin)
double fYNmin
! Minimum value of fYN
double fOffsetX
! Normalization offset X
const double * fY
! Pointer to Y array
void SetInputPoints(int n, const double *x, const double *y, const double *z, double xmin=0, double xmax=0, double ymin=0, double ymax=0)
set the input points for building the graph
const double * fX
! Pointer to X array (managed externally)
void DoNormalizePoints()
internal function to normalize the points.
double fYNmax
! Maximum value of fYN
int NumberOfTriangles() const
return the number of triangles
double fScaleFactorY
! Normalization factor Y
double fScaleFactorX
! Normalization factor X
void DoFindTriangles()
internal function to find the triangle
int CellX(double x) const
Namespace for new Math classes and functions.