FACT++  1.0
void Interpolator2D::CalculateGrid ( )
inlineprivate

the weights used for the interpolation

Calculate the collection of circles/triangles which describe the input grid. This is the collection of circles which are calculated from any three points and do not contain any other point of the grid.

Definition at line 90 of file Interpolator2D.h.

References Interpolator2D::vec::dist(), Interpolator2D::circle::isInsideCircle(), Interpolator2D::vec::orto(), Interpolator2D::circle::p, Interpolator2D::circle::r, Interpolator2D::vec::x, and Interpolator2D::vec::y.

Referenced by SetInputGrid().

91  {
92  circles.reserve(2*inputGrid.size());
93 
94  // Loop over all triplets of points
95  for (auto it0=inputGrid.cbegin(); it0<inputGrid.cend(); it0++)
96  {
97  for (auto it1=inputGrid.cbegin(); it1<it0; it1++)
98  {
99  for (auto it2=inputGrid.cbegin(); it2<it1; it2++)
100  {
101  // Calculate the circle through the three points
102 
103  // Vectors along the side of the corresponding triangle
104  const vec v1 = *it1 - *it0;
105  const vec v2 = *it2 - *it1;
106 
107  // Orthogonal vectors on the sides
108  const vec n1 = v1.orto();
109  const vec n2 = v2.orto();
110 
111  // Center point of two of the three sides
112  const vec p1 = (*it0 + *it1)/2;
113  const vec p2 = (*it1 + *it2)/2;
114 
115  // Calculate the crossing point of the two
116  // orthogonal vectors originating in the
117  // center of the sides.
118  const double denom = n1^n2;
119  if (denom==0)
120  continue;
121 
122  const vec x(n1.x, n2.x);
123  const vec y(n1.y, n2.y);
124 
125  const vec w(p1^(p1+n1), p2^(p2+n2));
126 
127  circle c;
128 
129  // This is the x and y coordinate of the circle
130  // through the three points and the circle's radius.
131  c.x = (x^w)/denom;
132  c.y = (y^w)/denom;
133  c.r = c.dist(*it1);
134 
135  // Check if any other grid point lays within this circle
136  auto it3 = inputGrid.cbegin();
137  for (; it3<inputGrid.cend(); it3++)
138  {
139  if (it3==it0 || it3==it1 || it3==it2)
140  continue;
141 
142  if (c.isInsideCircle(*it3))
143  break;
144  }
145 
146  // If a point was found inside, reject the circle
147  if (it3!=inputGrid.cend())
148  continue;
149 
150  // Store the three points of the triangle
151  c.p[0] = *it0;
152  c.p[1] = *it1;
153  c.p[2] = *it2;
154 
155  // Keep in list
156  circles.push_back(c);
157  }
158  }
159  }
160  }
std::vector< point > inputGrid
std::vector< circle > circles
positions at which inter-/extrapolated values should be provided

+ Here is the call graph for this function:

+ Here is the caller graph for this function: