ProSHADE  0.7.6.6 (JUL 2022)
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 111 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 125 of file ProSHADE_maths.hpp.

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

◆ ~BicubicInterpolator()

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

This is the destructor for the BicubicInterpolator class.

This destructor does nothing.

Definition at line 262 of file ProSHADE_maths.hpp.

262 { ; }

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 273 of file ProSHADE_maths.hpp.

274  {
275  //======================================== Sanity check
276  if ( ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) ||
277  ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) )
278  {
279  if ( ( x < this->xStartIndex ) || ( x > ( this->xStartIndex + this->xRange ) ) ) { std::cout << "PROBLEM WITH LAT" << std::endl; }
280  if ( ( y < this->yStartIndex ) || ( y > ( this->yStartIndex + this->yRange ) ) ) { std::cout << "PROBLEM WITH LON" << std::endl; }
281 
282  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." );
283  }
284 
285  //======================================== Convert x and y to unit square
286  proshade_double unitSquareX = ( x - this->xStartIndex ) / this->xRange;
287  proshade_double unitSquareY = ( y - this->yStartIndex ) / this->yRange;
288 
289  //======================================== Precompute powers
290  proshade_double x2 = std::pow ( unitSquareX, 2.0 );
291  proshade_double x3 = std::pow ( unitSquareX, 3.0 );
292  proshade_double y2 = std::pow ( unitSquareY, 2.0 );
293  proshade_double y3 = std::pow ( unitSquareY, 3.0 );
294 
295  //======================================== Done
296  return ( ( this->a00 + this->a01 * unitSquareY + this->a02 * y2 + this->a03 * y3 ) +
297  ( this->a10 + this->a11 * unitSquareY + this->a12 * y2 + this->a13 * y3 ) * unitSquareX +
298  ( this->a20 + this->a21 * unitSquareY + this->a22 * y2 + this->a23 * y3 ) * x2 +
299  ( this->a30 + this->a31 * unitSquareY + this->a32 * y2 + this->a33 * y3 ) * x3 );
300  }

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