ProSHADE  0.7.6.1 (AUG 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 104 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 118 of file ProSHADE_maths.hpp.

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

◆ ~BicubicInterpolator()

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

This is the destructor for the BicubicInterpolator class.

This destructor does nothing.

Definition at line 255 of file ProSHADE_maths.hpp.

255 { ; }

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

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

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