1 #ifndef BLI2DNONUNIF_OBJECT_GRID_H_ 2 #define BLI2DNONUNIF_OBJECT_GRID_H_ 48 template<
typename ZObject,
typename IndexType =
int,
typename XType = double,
60 const std::vector<YType>*
Y,
const std::vector<ZObject>*
Z,
65 inline XType
x_min()
const {
return fX->front(); }
68 inline XType
x_max()
const {
return fX->back(); }
71 inline YType
y_min()
const {
return fY->front(); }
74 inline YType
y_max()
const {
return fY->back(); }
80 IndexType
index_Z(IndexType ix, IndexType iy)
const {
81 IndexType num_y_points =
fY->size();
83 return (num_y_points * ix) + iy;
91 IndexType ix_lo, ix_hi, iy_lo, iy_hi;
116 XType
x1 =
fX->at( ix_lo );
117 XType
x2 =
fX->at( ix_hi );
118 YType y1 =
fY->at( iy_lo );
119 YType y2 =
fY->at( iy_hi );
123 const ZObject& z11 =
fZ->at( this->
index_Z(ix_lo, iy_lo) );
124 const ZObject& z21 =
fZ->at( this->
index_Z(ix_hi, iy_lo) );
125 const ZObject& z12 =
fZ->at( this->
index_Z(ix_lo, iy_hi) );
126 const ZObject& z22 =
fZ->at( this->
index_Z(ix_hi, iy_hi) );
129 ZObject z1 = z11 * (y2-evaly)/(y2-y1) + z12 * (evaly-y1)/(y2-y1);
130 ZObject z2 = z21 * (y2-evaly)/(y2-y1) + z22 * (evaly-y1)/(y2-y1);
131 ZObject
z = z1 * (x2-evalx)/(x2-x1) + z2 * (evalx-
x1)/(x2-x1);
138 const std::vector<XType>*
fX;
139 const std::vector<YType>*
fY;
142 const std::vector<ZObject>*
fZ;
162 Type val,
int& lower_index,
int& upper_index)
const 169 Iterator
begin = vec->begin();
170 Iterator
end = vec->end();
174 Iterator not_less_point = std::lower_bound(begin, end, val);
176 Iterator lower_point;
179 if (not_less_point == begin) {
182 if (*begin != val) within =
false;
184 else if (not_less_point == end) {
187 lower_point = end - 2;
191 lower_point = not_less_point - 1;
195 upper_index = lower_index + 1;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
THE MAIN GENIE PROJECT NAMESPACE
IndexType index_Z(IndexType ix, IndexType iy) const
YType y_max() const
Retrieve the maximum y value.
const std::vector< ZObject > * fZ
Pointer to the vector of z coordinate objects.
YType y_min() const
Retrieve the minimum y value.
const std::vector< XType > * fX
Pointer to the vector of x coordinates.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
static int max(int a, int b)
XType x_max() const
Retrieve the maximum x value.
A class template that performs bilinear interpolation on a non-uniform grid with an implementation si...
const std::vector< YType > * fY
Pointer to the vector of y coordinates.
XType x_min() const
Retrieve the minimum x value.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
bool get_bound_indices(const std::vector< Type > *vec, Type val, int &lower_index, int &upper_index) const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
BLI2DNonUnifObjectGrid(const std::vector< XType > *X, const std::vector< YType > *Y, const std::vector< ZObject > *Z, bool extrapolate=false)
ZObject interpolate(double x, double y) const