ProSHADE  0.7.6.2 (DEC 2021)
Protein Shape Detection
ProSHADE_internal_maths::BicubicInterpolator Class Reference

Public Member Functions

 BicubicInterpolator (proshade_double **areaToInterpolate, proshade_double xStart, proshade_double yStart)
 This is the constructor for the BicubicInterpolator class. More...
 
 ~BicubicInterpolator (void)
 This is the destructor for the BicubicInterpolator class. More...
 
proshade_double getValue (proshade_double x, proshade_double y)
 This function allows accessing the interpolated value for a given position x and y. More...
 

Detailed Description

Definition at line 109 of file ProSHADE_maths.hpp.

Constructor & Destructor Documentation

◆ BicubicInterpolator()

ProSHADE_internal_maths::BicubicInterpolator::BicubicInterpolator ( proshade_double **  areaToInterpolate,
proshade_double  xStart,
proshade_double  yStart 
)
inline

This is the constructor for the BicubicInterpolator class.

This constructor takes the 4 by 4 array of values and pre-computes all the interpolators required for fast computation of any positions value.

Parameters
[in]areaToInterpolatePointer to pointer of 4 by 4 equidistantly spaced grid of values.

Definition at line 123 of file ProSHADE_maths.hpp.

124  {
125  //======================================== Save the original non-unit square positions
126  this->xStartIndex = xStart;
127  this->yStartIndex = yStart;
128 
129  //======================================== Prepare variables for converting from original indices to unit square
130  this->xRange = 1.0;
131  this->yRange = 1.0;
132 
133  //======================================== Precompute interpolators
134  this->a00 = areaToInterpolate[1][1];
135  this->a01 = - ( 0.5 * areaToInterpolate[1][0] ) +
136  ( 0.5 * areaToInterpolate[1][2] );
137  this->a02 = areaToInterpolate[1][0] -
138  ( 2.5 * areaToInterpolate[1][1] ) +
139  ( 2.0 * areaToInterpolate[1][2] ) -
140  ( 0.5 * areaToInterpolate[1][3] );
141  this->a03 = - ( 0.5 * areaToInterpolate[1][0] ) +
142  ( 1.5 * areaToInterpolate[1][1] ) -
143  ( 1.5 * areaToInterpolate[1][2] ) +
144  ( 0.5 * areaToInterpolate[1][3] );
145  this->a10 = - ( 0.5 * areaToInterpolate[0][1] ) +
146  ( 0.5 * areaToInterpolate[2][1] );
147  this->a11 = ( 0.25 * areaToInterpolate[0][0] ) -
148  ( 0.25 * areaToInterpolate[0][2] ) -
149  ( 0.25 * areaToInterpolate[2][0] ) +
150  ( 0.25 * areaToInterpolate[2][2] );
151  this->a12 = - ( 0.5 * areaToInterpolate[0][0] ) +
152  ( 1.25 * areaToInterpolate[0][1] ) -
153  areaToInterpolate[0][2] +
154  ( 0.25 * areaToInterpolate[0][3] ) +
155  ( 0.5 * areaToInterpolate[2][0] ) -
156  ( 1.25 * areaToInterpolate[2][1] ) +
157  areaToInterpolate[2][2] -
158  ( 0.25 * areaToInterpolate[2][3] );
159  this->a13 = ( 0.25 * areaToInterpolate[0][0] ) -
160  ( 0.75 * areaToInterpolate[0][1] ) +
161  ( 0.75 * areaToInterpolate[0][2] ) -
162  ( 0.25 * areaToInterpolate[0][3] ) -
163  ( 0.25 * areaToInterpolate[2][0] ) +
164  ( 0.75 * areaToInterpolate[2][1] ) -
165  ( 0.75 * areaToInterpolate[2][2] ) +
166  ( 0.25 * areaToInterpolate[2][3] );
167  this->a20 = areaToInterpolate[0][1] -
168  ( 2.5 * areaToInterpolate[1][1] ) +
169  ( 2.0 * areaToInterpolate[2][1] ) -
170  ( 0.5 * areaToInterpolate[3][1] );
171  this->a21 = - ( 0.5 * areaToInterpolate[0][0] ) +
172  ( 0.5 * areaToInterpolate[0][2] ) +
173  ( 1.25 * areaToInterpolate[1][0] ) -
174  ( 1.25 * areaToInterpolate[1][2] ) -
175  areaToInterpolate[2][0] + areaToInterpolate[2][2] +
176  ( 0.25 * areaToInterpolate[3][0] ) -
177  ( 0.25 * areaToInterpolate[3][2] );
178  this->a22 = areaToInterpolate[0][0] -
179  ( 2.5 * areaToInterpolate[0][1] ) +
180  ( 2.0 * areaToInterpolate[0][2] ) -
181  ( 0.5 * areaToInterpolate[0][3] ) -
182  ( 2.5 * areaToInterpolate[1][0] ) +
183  ( 6.25 * areaToInterpolate[1][1] ) -
184  ( 5.0 * areaToInterpolate[1][2] ) +
185  ( 1.25 * areaToInterpolate[1][3] ) +
186  ( 2.0 * areaToInterpolate[2][0] ) -
187  ( 5.0 * areaToInterpolate[2][1] ) +
188  ( 4.0 * areaToInterpolate[2][2] ) -
189  areaToInterpolate[2][3] -
190  ( 0.5 * areaToInterpolate[3][0] ) +
191  ( 1.25 * areaToInterpolate[3][1] ) -
192  areaToInterpolate[3][2] +
193  ( 0.25 * areaToInterpolate[3][3] );
194  this->a23 = - ( 0.5 * areaToInterpolate[0][0] ) +
195  ( 1.5 * areaToInterpolate[0][1] ) -
196  ( 1.5 * areaToInterpolate[0][2] ) +
197  ( 0.5 * areaToInterpolate[0][3] ) +
198  ( 1.25 * areaToInterpolate[1][0] ) -
199  ( 3.75 * areaToInterpolate[1][1] ) +
200  ( 3.75 * areaToInterpolate[1][2] ) -
201  ( 1.25 * areaToInterpolate[1][3] ) -
202  areaToInterpolate[2][0] +
203  ( 3.0 * areaToInterpolate[2][1] ) -
204  ( 3.0 * areaToInterpolate[2][2] ) +
205  areaToInterpolate[2][3] +
206  ( 0.25 * areaToInterpolate[3][0] ) -
207  ( 0.75 * areaToInterpolate[3][1] ) +
208  ( 0.75 * areaToInterpolate[3][2] ) -
209  ( 0.25 * areaToInterpolate[3][3] );
210  this->a30 = - ( 0.5 * areaToInterpolate[0][1] ) +
211  ( 1.5 * areaToInterpolate[1][1] ) -
212  ( 1.5 * areaToInterpolate[2][1] ) +
213  ( 0.5*areaToInterpolate[3][1] );
214  this->a31 = ( 0.25 * areaToInterpolate[0][0] ) -
215  ( 0.25 * areaToInterpolate[0][2] ) -
216  ( 0.75 * areaToInterpolate[1][0] ) +
217  ( 0.75 * areaToInterpolate[1][2] ) +
218  ( 0.75 * areaToInterpolate[2][0] ) -
219  ( 0.75 * areaToInterpolate[2][2] ) -
220  ( 0.25 * areaToInterpolate[3][0] ) +
221  ( 0.25 * areaToInterpolate[3][2] );
222  this->a32 = - ( 0.5 * areaToInterpolate[0][0] ) +
223  ( 1.25 * areaToInterpolate[0][1] ) -
224  areaToInterpolate[0][2] +
225  ( 0.25 * areaToInterpolate[0][3] ) +
226  ( 1.5 * areaToInterpolate[1][0] ) -
227  ( 3.75 * areaToInterpolate[1][1] ) +
228  ( 3.0 * areaToInterpolate[1][2] ) -
229  ( 0.75 * areaToInterpolate[1][3] ) -
230  ( 1.5 * areaToInterpolate[2][0] ) +
231  ( 3.75 * areaToInterpolate[2][1] ) -
232  ( 3.0 * areaToInterpolate[2][2] ) +
233  ( 0.75 * areaToInterpolate[2][3] ) +
234  ( 0.5 * areaToInterpolate[3][0] ) -
235  ( 1.25 * areaToInterpolate[3][1] ) +
236  areaToInterpolate[3][2] -
237  ( 0.25 * areaToInterpolate[3][3] );
238  this->a33 = ( 0.25 * areaToInterpolate[0][0] ) -
239  ( 0.75 * areaToInterpolate[0][1] ) +
240  ( 0.75 * areaToInterpolate[0][2] ) -
241  ( 0.25 * areaToInterpolate[0][3] ) -
242  ( 0.75 * areaToInterpolate[1][0] ) +
243  ( 2.25 * areaToInterpolate[1][1] ) -
244  ( 2.25 * areaToInterpolate[1][2] ) +
245  ( 0.75 * areaToInterpolate[1][3] ) +
246  ( 0.75 * areaToInterpolate[2][0] ) -
247  ( 2.25 * areaToInterpolate[2][1] ) +
248  ( 2.25 * areaToInterpolate[2][2] ) -
249  ( 0.75 * areaToInterpolate[2][3] ) -
250  ( 0.25 * areaToInterpolate[3][0] ) +
251  ( 0.75 * areaToInterpolate[3][1] ) -
252  ( 0.75 * areaToInterpolate[3][2] ) +
253  ( 0.25 * areaToInterpolate[3][3] );
254  }

◆ ~BicubicInterpolator()

ProSHADE_internal_maths::BicubicInterpolator::~BicubicInterpolator ( void  )
inline

This is the destructor for the BicubicInterpolator class.

This destructor does nothing.

Definition at line 260 of file ProSHADE_maths.hpp.

260 { ; }

Member Function Documentation

◆ getValue()

proshade_double ProSHADE_internal_maths::BicubicInterpolator::getValue ( proshade_double  x,
proshade_double  y 
)
inline

This function allows accessing the interpolated value for a given position x and y.

This constructor takes the 4 by 4 array of values and pre-computes all the interpolators required for fast computation of any positions value.

Parameters
[in]xThe x-axis position on the unit square for which the interpolated value should be computed.
[in]yThe y-axis position on the unit square for which the interpolated value should be computed.
[out]resThe interpolated value for the position x and y.

Definition at line 271 of file ProSHADE_maths.hpp.

272  {
273  //======================================== Sanity check
274  if ( ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) ||
275  ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) )
276  {
277  if ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) { std::cout << "PROBLEM WITH LAT" << std::endl; }
278  if ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) { std::cout << "PROBLEM WITH LON" << std::endl; }
279 
280  throw ProSHADE_exception ( "Requested bicubic interpolation outside of pre-computed\n : square.", "ES00064", __FILE__, __LINE__, __func__, "The supplied x or y value(s) is outside of the range of\n : the bi-cubic interpolator's pre-computed square. Please\n : make sure the start values were correctly supplied when\n : the constructor was called or create a new interpolator\n : for these values." );
281  }
282 
283  //======================================== Convert x and y to unit square
284  proshade_double unitSquareX = ( x - this->xStartIndex ) / this->xRange;
285  proshade_double unitSquareY = ( y - this->yStartIndex ) / this->yRange;
286 
287  //======================================== Precompute powers
288  proshade_double x2 = std::pow ( unitSquareX, 2.0 );
289  proshade_double x3 = std::pow ( unitSquareX, 3.0 );
290  proshade_double y2 = std::pow ( unitSquareY, 2.0 );
291  proshade_double y3 = std::pow ( unitSquareY, 3.0 );
292 
293  //======================================== Done
294  return ( ( this->a00 + this->a01 * unitSquareY + this->a02 * y2 + this->a03 * y3 ) +
295  ( this->a10 + this->a11 * unitSquareY + this->a12 * y2 + this->a13 * y3 ) * unitSquareX +
296  ( this->a20 + this->a21 * unitSquareY + this->a22 * y2 + this->a23 * y3 ) * x2 +
297  ( this->a30 + this->a31 * unitSquareY + this->a32 * y2 + this->a33 * y3 ) * x3 );
298  }

The documentation for this class was generated from the following file:
ProSHADE_exception
This class is the representation of ProSHADE exception.
Definition: ProSHADE_exceptions.hpp:37