ProSHADE  0.7.6.2 (DEC 2021)
Protein Shape Detection
ProSHADE_internal_spheres::ProSHADE_sphere Class Reference

This class contains all inputed and derived data for a single sphere. More...

#include <ProSHADE_spheres.hpp>

Public Member Functions

 ProSHADE_sphere (proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_single xSize, proshade_single ySize, proshade_single zSize, proshade_unsign shOrder, std::vector< proshade_single > *spherePos, bool progressiveMapping, proshade_unsign band, proshade_double *map, proshade_unsign *maxShellBand)
 Constructor for getting empty ProSHADE_sphere class. More...
 
 ~ProSHADE_sphere (void)
 Destructor for the ProSHADE_sphere class. More...
 
void allocateRotatedMap (void)
 This function allocates the rotated map memory.
 
proshade_unsign getLocalBandwidth (void)
 This function returns the local bandwidth. More...
 
proshade_unsign getLocalAngRes (void)
 This function returns the local angular resolution. More...
 
proshade_double * getMappedData (void)
 This function returns the mapped data array. More...
 
proshade_double getShellRadius (void)
 This function returns the radius of the shell in question. More...
 
void setRotatedMappedData (proshade_unsign pos, proshade_double value)
 This function sets the rotated mapped data value to the given position. More...
 
proshade_double getRotatedMappedData (proshade_unsign pos)
 This function gets the rotated mapped data value for a particular position. More...
 

Protected Member Functions

proshade_unsign getMaxCircumference (proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_single maxRange)
 This function determines the maximum circumference of a shell. More...
 
bool getMapPoint (proshade_double *map, proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_signed xPos, proshade_signed yPos, proshade_signed zPos, std::vector< proshade_double > *interpVec)
 This function fills in the interpolation vector for a single map point. More...
 
void getLongitudeCutoffs (std::vector< proshade_double > *lonCO)
 This function fills in the vector of longitudal bin boarder values. More...
 
void getLattitudeCutoffs (std::vector< proshade_double > *latCO)
 This function fills in the vector of lattitudal bin boarder values. More...
 
void getInterpolationXYZ (proshade_double *x, proshade_double *y, proshade_double *z, proshade_double thetaIt, std::vector< proshade_double > *lonCO, proshade_unsign phiIt, std::vector< proshade_double > *latCO)
 This function finds the x, y and z positions of supplied shell point. More...
 
void getXYZTopBottoms (proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_double x, proshade_double y, proshade_double z, proshade_signed *xBottom, proshade_signed *yBottom, proshade_signed *zBottom, proshade_signed *xTop, proshade_signed *yTop, proshade_signed *zTop)
 This function fills in the interpolation vector for a single map point. More...
 
void interpolateAlongFirst (std::vector< proshade_double > c000, std::vector< proshade_double > c001, std::vector< proshade_double > c010, std::vector< proshade_double > c011, std::vector< proshade_double > c100, std::vector< proshade_double > c101, std::vector< proshade_double > c110, std::vector< proshade_double > c111, std::vector< proshade_double > *c00, std::vector< proshade_double > *c01, std::vector< proshade_double > *c10, std::vector< proshade_double > *c11, proshade_double xd)
 This function interpolates along the first (X) dimension. More...
 
void interpolateAlongSecond (std::vector< proshade_double > c00, std::vector< proshade_double > c01, std::vector< proshade_double > c10, std::vector< proshade_double > c11, std::vector< proshade_double > *c0, std::vector< proshade_double > *c1, proshade_double yd)
 This function interpolates along the second (Y) dimension. More...
 
void mapData (proshade_double *map, proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax)
 This function maps the internal map to the specific sphere. More...
 

Detailed Description

This class contains all inputed and derived data for a single sphere.

This class codes the object that contains all the information about a single concentric sphere as well as all the functionality required to process such data.

Definition at line 48 of file ProSHADE_spheres.hpp.

Constructor & Destructor Documentation

◆ ProSHADE_sphere()

ProSHADE_internal_spheres::ProSHADE_sphere::ProSHADE_sphere ( proshade_unsign  xDimMax,
proshade_unsign  yDimMax,
proshade_unsign  zDimMax,
proshade_single  xSize,
proshade_single  ySize,
proshade_single  zSize,
proshade_unsign  shOrder,
std::vector< proshade_single > *  spherePos,
bool  progressiveMapping,
proshade_unsign  band,
proshade_double *  map,
proshade_unsign *  maxShellBand 
)

Constructor for getting empty ProSHADE_sphere class.

This constructor takes all the information required by the shell and proceeds to set the shell object accordingly. It can either set the spherical harmonics variables according to shell size (if the progressive mapping is allowed), or it just uses the whole map defaults (in the opposite case). It also maps the density onto the spherical grid of the shell using tri-linear interpolation.

Parameters
[in]xDimMaxThe internal map maximum index in the x dimension.
[in]yDimMaxThe internal map maximum index in the y dimension.
[in]zDimMaxThe internal map maximum index in the z dimension.
[in]xSizeThe integral map size in angstroms along the x-axis.
[in]ySizeThe integral map size in angstroms along the y-axis.
[in]zSizeThe integral map size in angstroms along the z-axis.
[in]shOrderThe order of the shell in the shell vector - 0 is the smallest shell.
[in]spherePosA Pointer to vector of proshade_single's with the shell positions.
[in]progressiveMappingShould the bandwidth and angular resolution be set by the actual number of points, or just same for all shells?
[in]bandThe bandwidth to be set for conservative mapping.
[in]mapA pointer to the internal map which should be mapped to the sphere.
[in]maxShellBandThis pointer reference will take the shell band, if it is higher than the already known one.
[out]XData object with all values set and the appropriate map part mapped.

Definition at line 46 of file ProSHADE_spheres.cpp.

47 {
48  //================================================ Save inputs
49  this->shellOrder = shOrder;
50  this->sphereWidth = static_cast< proshade_single > ( ( spherePos->at(0) + spherePos->at(1) ) / 2.0f );
51  this->sphereRadius = static_cast< proshade_double > ( spherePos->at(shOrder) );
52 
53  //================================================ Determine shell ranges in angstroms
54  proshade_double maxDist = 0.0;
55  if ( shOrder == static_cast<proshade_unsign> ( spherePos->size() - 1 ) ) { maxDist = static_cast<proshade_double> ( spherePos->at(spherePos->size()-1) + ( spherePos->at(1) - spherePos->at(0) ) ); }
56  else { maxDist = static_cast<proshade_double> ( ( spherePos->at(shOrder) + spherePos->at(shOrder+1) ) / 2.0f ); }
57 
58  //================================================ Set the max range
59  this->maxSphereRange = static_cast<proshade_single> ( 2.0 * maxDist );
60 
61  //================================================ Set map sampling rates
62  this->xDimSampling = xSize / static_cast<proshade_single> (xDimMax);
63  this->yDimSampling = ySize / static_cast<proshade_single> (yDimMax);
64  this->zDimSampling = zSize / static_cast<proshade_single> (zDimMax);
65 
66  //================================================ Get maximum circumference
67  proshade_unsign maxCircumference = this->getMaxCircumference ( xDimMax, yDimMax, zDimMax, this->maxSphereRange );
68 
69  //================================================ Get spherical harmonics calculation values
70  if ( progressiveMapping )
71  {
72  this->localBandwidth = std::min ( autoDetermineBandwidth ( maxCircumference ), band );
73  this->localAngRes = this->localBandwidth * 2;
74  }
75  else
76  {
77  this->localBandwidth = band;
78  this->localAngRes = this->localBandwidth * 2;
79  }
80 
81  //================================================ Save the maximum shell band for later
82  if ( *maxShellBand < this->localBandwidth ) { *maxShellBand = this->localBandwidth; }
83 
84  //================================================ Allocate memory for sphere mapping
85  this->mappedData = new proshade_double[this->localAngRes * this->localAngRes];
86  ProSHADE_internal_misc::checkMemoryAllocation ( this->mappedData, __FILE__, __LINE__, __func__ );
87 
88  //================================================ Set rotated mapped data
89  this->mappedDataRot = nullptr;
90 
91  //================================================ Map the data to the sphere
92  this->mapData ( map, xDimMax, yDimMax, zDimMax );
93 
94 }

◆ ~ProSHADE_sphere()

ProSHADE_internal_spheres::ProSHADE_sphere::~ProSHADE_sphere ( void  )

Destructor for the ProSHADE_sphere class.

This destructor is responsible for releasing all memory used by the data storing object

Parameters
[out]XN/A.

Definition at line 102 of file ProSHADE_spheres.cpp.

103 {
104  delete[] this->mappedData;
105 
106  if ( this->mappedDataRot != nullptr )
107  {
108  delete[] this->mappedDataRot;
109  }
110 }

Member Function Documentation

◆ getInterpolationXYZ()

void ProSHADE_internal_spheres::ProSHADE_sphere::getInterpolationXYZ ( proshade_double *  x,
proshade_double *  y,
proshade_double *  z,
proshade_double  thetaIt,
std::vector< proshade_double > *  lonCO,
proshade_unsign  phiIt,
std::vector< proshade_double > *  latCO 
)
protected

This function finds the x, y and z positions of supplied shell point.

This function converts the angular grid longitude and lattitude position (defined as in between the cutt-offs of the given index and its neighbour) to the X, Y and Z axis positions, which it saves in the supplied variables.

Parameters
[in]xA pointer to variable where the x position is to be saved.
[in]yA pointer to variable where the y position is to be saved.
[in]zA pointer to variable where the z position is to be saved.
[in]thetaItThe longitude cut-off index of the grid point of which the XYZ are to be computed.
[in]lonCOA pointer for vector of proshade_double's where the longitude cutt-off values are saved
[in]phiItThe lattitude cut-off index of the grid point of which the XYZ are to be computed.
[in]lonCOA pointer for vector of proshade_double's where the lattitude cutt-off values are saved

Definition at line 336 of file ProSHADE_spheres.cpp.

337 {
338  //================================================ Compute and save XYZ interpolation positions
339  *x = this->sphereRadius * std::cos ( ( lonCO->at( static_cast<proshade_unsign> ( thetaIt ) ) + lonCO->at( static_cast<proshade_unsign> ( thetaIt+1 ) ) ) / 2.0 ) *
340  std::cos ( ( latCO->at( static_cast<proshade_unsign> ( phiIt ) ) + latCO->at( static_cast<proshade_unsign> ( phiIt+1 ) ) ) / 2.0 );
341  *y = this->sphereRadius * std::sin ( ( lonCO->at( static_cast<proshade_unsign> ( thetaIt ) ) + lonCO->at( static_cast<proshade_unsign> ( thetaIt+1 ) ) ) / 2.0 ) *
342  std::cos ( ( latCO->at( static_cast<proshade_unsign> ( phiIt ) ) + latCO->at( static_cast<proshade_unsign> ( phiIt+1 ) ) ) / 2.0 );
343  *z = this->sphereRadius * std::sin ( ( latCO->at( static_cast<proshade_unsign> ( phiIt ) ) + latCO->at( static_cast<proshade_unsign> ( phiIt+1 ) ) ) / 2.0 );
344 
345  //================================================ Done
346  return ;
347 
348 }

◆ getLattitudeCutoffs()

void ProSHADE_internal_spheres::ProSHADE_sphere::getLattitudeCutoffs ( std::vector< proshade_double > *  latCO)
protected

This function fills in the vector of lattitudal bin boarder values.

This is a simple abstraction function which finds the boarders of the angular grid binds along the lattitudal angle.

Parameters
[in]latCOA pointer for vector of proshade_double's to which the cutt-off values are to be saved. The vector needs to be initialised for this->localAngRes + 1 size.

Definition at line 308 of file ProSHADE_spheres.cpp.

309 {
310  //================================================ Get the cut-offs
311  for ( proshade_unsign iter = 0; iter <= this->localAngRes; iter++ )
312  {
313  latCO->at(iter) = ( static_cast<proshade_double> ( iter ) *
314  ( static_cast<proshade_double> ( M_PI ) / static_cast<proshade_double> ( this->localAngRes ) ) -
315  ( static_cast<proshade_double> ( M_PI ) / 2.0 ) );
316  }
317 
318  //================================================ Done
319  return ;
320 
321 }

◆ getLocalAngRes()

proshade_unsign ProSHADE_internal_spheres::ProSHADE_sphere::getLocalAngRes ( void  )

This function returns the local angular resolution.

This is a simple accessor function so that the inverse sphere to Cartesian interpolation knows the proper angular cut-offs for each sphere.

Parameters
[out]localAngResThe value of the local angular resolution for this particular shell.

Definition at line 403 of file ProSHADE_spheres.cpp.

404 {
405  //================================================ Return the value
406  return ( this->localAngRes );
407 }

◆ getLocalBandwidth()

proshade_unsign ProSHADE_internal_spheres::ProSHADE_sphere::getLocalBandwidth ( void  )

This function returns the local bandwidth.

This is a simple accessor function so that the spherical harmonics can allocate the proper memory given the local bandwidth of the sphere.

Parameters
[out]localBandwidthThe value of the local bandwidth for this particular shell.

Definition at line 390 of file ProSHADE_spheres.cpp.

391 {
392  //================================================ Return the value
393  return ( this->localBandwidth );
394 }

◆ getLongitudeCutoffs()

void ProSHADE_internal_spheres::ProSHADE_sphere::getLongitudeCutoffs ( std::vector< proshade_double > *  lonCO)
protected

This function fills in the vector of longitudal bin boarder values.

This is a simple abstraction function which finds the boarders of the angular grid binds along the longitudal angle.

Parameters
[in]lonCOA pointer for vector of proshade_double's to which the cutt-off values are to be saved. The vector needs to be initialised for this->localAngRes + 1 size.

Definition at line 287 of file ProSHADE_spheres.cpp.

288 {
289  //================================================ Get the cut-offs
290  for ( proshade_unsign iter = 0; iter <= this->localAngRes; iter++ )
291  {
292  lonCO->at(iter) = static_cast<proshade_double> ( iter ) *
293  ( ( static_cast<proshade_double> ( M_PI ) * 2.0 ) / static_cast<proshade_double> ( this->localAngRes ) ) -
294  ( static_cast<proshade_double> ( M_PI ) );
295  }
296 
297  //================================================ Done
298  return ;
299 
300 }

◆ getMappedData()

proshade_double * ProSHADE_internal_spheres::ProSHADE_sphere::getMappedData ( void  )

This function returns the mapped data array.

This is a simple accessor function so that the spherical harmonics can access the mapped data in an array.

Parameters
[out]mappedDataproshade_double pointer to an array of mapped data.

Definition at line 416 of file ProSHADE_spheres.cpp.

417 {
418  //================================================ Return the value
419  return ( this->mappedData );
420 }

◆ getMapPoint()

bool ProSHADE_internal_spheres::ProSHADE_sphere::getMapPoint ( proshade_double *  map,
proshade_unsign  xDimMax,
proshade_unsign  yDimMax,
proshade_unsign  zDimMax,
proshade_signed  xPos,
proshade_signed  yPos,
proshade_signed  zPos,
std::vector< proshade_double > *  interpVec 
)
protected

This function fills in the interpolation vector for a single map point.

This function takes the index positions of a map point and a pointer to a vector of 4 proshade_double's and fills in the vector so that interpolation can easily be done using its values. It also returns boolean value, true if the point is in bounds and everything had succeeded and false if the point was out of bounds and therefore the interpolation is not required as the mapped value should just be 0.

Parameters
[in]mapThe density map pointer - the map which should be mapped to the data.
[in]xDimMaxThe internal map maximum index in the x dimension.
[in]yDimMaxThe internal map maximum index in the y dimension.
[in]zDimMaxThe internal map maximum index in the z dimension.
[in]xPosThe x axis index position of the point of which interpolation vector is to be obtained.
[in]yPosThe y axis index position of the point of which interpolation vector is to be obtained.
[in]zPosThe z axis index position of the point of which interpolation vector is to be obtained.
[in]interpVecThe variable to which the interpolation values are to be saved (vector of proshade_double's initialised to length 4).

Definition at line 260 of file ProSHADE_spheres.cpp.

261 {
262  //================================================ Initialise local variables
263  proshade_signed posIter = zPos + static_cast<proshade_signed> ( zDimMax ) * ( yPos + static_cast<proshade_signed> ( yDimMax ) * xPos );
264 
265  //================================================ Check of out-of-bounds shells
266  if ( ( xPos < 0 ) || ( xPos >= static_cast<proshade_signed> ( xDimMax ) ) ) { return ( false ); }
267  if ( ( yPos < 0 ) || ( yPos >= static_cast<proshade_signed> ( yDimMax ) ) ) { return ( false ); }
268  if ( ( zPos < 0 ) || ( zPos >= static_cast<proshade_signed> ( zDimMax ) ) ) { return ( false ); }
269 
270  //================================================ Get the interpolation values
271  interpVec->at(0) = static_cast<proshade_double> ( xPos ) * static_cast<proshade_double> ( this->xDimSampling );
272  interpVec->at(1) = static_cast<proshade_double> ( yPos ) * static_cast<proshade_double> ( this->yDimSampling );
273  interpVec->at(2) = static_cast<proshade_double> ( zPos ) * static_cast<proshade_double> ( this->zDimSampling );
274  interpVec->at(3) = map[posIter];
275 
276  //================================================ Done
277  return ( true );
278 
279 }

◆ getMaxCircumference()

proshade_unsign ProSHADE_internal_spheres::ProSHADE_sphere::getMaxCircumference ( proshade_unsign  xDimMax,
proshade_unsign  yDimMax,
proshade_unsign  zDimMax,
proshade_single  maxRange 
)
protected

This function determines the maximum circumference of a shell.

This function takes the input variables and finds the maximum circumference of the sphere data.

Parameters
[in]xDimMaxThe internal map maximum index in the x dimension.
[in]yDimMaxThe internal map maximum index in the y dimension.
[in]zDimMaxThe internal map maximum index in the z dimension.
[in]maxRangeThe maximum range of shell in angstroms.

Definition at line 121 of file ProSHADE_spheres.cpp.

122 {
123  //================================================ Find from and to limits on indices
124  proshade_signed xFromInd = static_cast<proshade_signed> ( xDimMax / 2 ) -
125  static_cast<proshade_signed> ( (maxRange/2) / this->xDimSampling );
126  proshade_signed yFromInd = static_cast<proshade_signed> ( yDimMax / 2 ) -
127  static_cast<proshade_signed> ( (maxRange/2) / this->yDimSampling );
128  proshade_signed zFromInd = static_cast<proshade_signed> ( zDimMax / 2 ) -
129  static_cast<proshade_signed> ( (maxRange/2) / this->zDimSampling );
130 
131  proshade_signed xToInd = static_cast<proshade_signed> ( xDimMax / 2 ) +
132  static_cast<proshade_signed> ( (maxRange/2) / this->xDimSampling );
133  proshade_signed yToInd = static_cast<proshade_signed> ( yDimMax / 2 ) +
134  static_cast<proshade_signed> ( (maxRange/2) / this->yDimSampling );
135  proshade_signed zToInd = static_cast<proshade_signed> ( zDimMax / 2 ) +
136  static_cast<proshade_signed> ( (maxRange/2) / this->zDimSampling );
137 
138  //================================================ Check for bounds
139  if ( xFromInd < 0 ) { xFromInd = 0; }
140  if ( yFromInd < 0 ) { yFromInd = 0; }
141  if ( zFromInd < 0 ) { zFromInd = 0; }
142  if ( xToInd > static_cast<proshade_signed> ( xDimMax ) ) { xToInd = static_cast<proshade_signed> ( xDimMax ); }
143  if ( yToInd > static_cast<proshade_signed> ( yDimMax ) ) { yToInd = static_cast<proshade_signed> ( yDimMax ); }
144  if ( zToInd > static_cast<proshade_signed> ( zDimMax ) ) { zToInd = static_cast<proshade_signed> ( zDimMax ); }
145 
146  //================================================ Get dim sizes
147  proshade_unsign xDimSZ = static_cast< proshade_unsign > ( xToInd - xFromInd );
148  proshade_unsign yDimSZ = static_cast< proshade_unsign > ( yToInd - yFromInd );
149  proshade_unsign zDimSZ = static_cast< proshade_unsign > ( zToInd - zFromInd );
150 
151  //================================================ check for too sparse sampling
152  if ( ( xDimSZ == 0 ) && ( yDimSZ == 0 ) && ( zDimSZ == 0 ) ) { xDimSZ = 1; yDimSZ = 1; zDimSZ = 1; }
153 
154  //================================================ Find max and mid dims
155  std::vector<proshade_unsign> dimSizes;
156  ProSHADE_internal_misc::addToUnsignVector ( &dimSizes, xDimSZ );
157  ProSHADE_internal_misc::addToUnsignVector ( &dimSizes, yDimSZ );
158  ProSHADE_internal_misc::addToUnsignVector ( &dimSizes, zDimSZ );
159  std::sort ( dimSizes.begin(), dimSizes.end() );
160  proshade_unsign maxDim = dimSizes.at(2);
161  proshade_unsign midDim = dimSizes.at(1);
162 
163  //================================================ Return max circumference
164  return ( maxDim + midDim );
165 }

◆ getRotatedMappedData()

proshade_double ProSHADE_internal_spheres::ProSHADE_sphere::getRotatedMappedData ( proshade_unsign  pos)

This function gets the rotated mapped data value for a particular position.

Parameters
[in]posThe array position from which the value should be retrieved.

Definition at line 627 of file ProSHADE_spheres.cpp.

628 {
629  //================================================ Done
630  return ( this->mappedDataRot[pos] );
631 
632 }

◆ getShellRadius()

proshade_double ProSHADE_internal_spheres::ProSHADE_sphere::getShellRadius ( void  )

This function returns the radius of the shell in question.

This is a simple accessor function so that the sphere radius can be accessed when need be.

Parameters
[out]sphereRadiusThe distance of the shell to the centre of the coordinates.

Definition at line 587 of file ProSHADE_spheres.cpp.

588 {
589  //================================================ Done
590  return ( this->sphereRadius );
591 
592 }

◆ getXYZTopBottoms()

void ProSHADE_internal_spheres::ProSHADE_sphere::getXYZTopBottoms ( proshade_unsign  xDimMax,
proshade_unsign  yDimMax,
proshade_unsign  zDimMax,
proshade_double  x,
proshade_double  y,
proshade_double  z,
proshade_signed *  xBottom,
proshade_signed *  yBottom,
proshade_signed *  zBottom,
proshade_signed *  xTop,
proshade_signed *  yTop,
proshade_signed *  zTop 
)
protected

This function fills in the interpolation vector for a single map point.

This function takes the XYZ position of a point and finds the top and bottom map points which surround the XYZ position.

Parameters
[in]xDimMaxThe internal map maximum index in the x dimension.
[in]yDimMaxThe internal map maximum index in the y dimension.
[in]zDimMaxThe internal map maximum index in the z dimension.
[in]xThe x position of the point for which the surrounding indices are to be found.
[in]yThe y position of the point for which the surrounding indices are to be found.
[in]zThe z position of the point for which the surrounding indices are to be found.
[in]xBottomA pointer to the variable which should now hold the x position of the lower surrounding point.
[in]yBottomA pointer to the variable which should now hold the y position of the lower surrounding point.
[in]zBottomA pointer to the variable which should now hold the z position of the lower surrounding point.
[in]xTopA pointer to the variable which should now hold the x position of the upper surrounding point.
[in]yTopA pointer to the variable which should now hold the y position of the upper surrounding point.
[in]zTopA pointer to the variable which should now hold the z position of the upper surrounding point.

Definition at line 367 of file ProSHADE_spheres.cpp.

368 {
369  //================================================ Get the values
370  *xBottom = static_cast< proshade_signed > ( std::floor ( ( x / static_cast< proshade_double > ( this->xDimSampling ) ) ) + ( static_cast< proshade_double > ( xDimMax ) / 2.0 ) );
371  *yBottom = static_cast< proshade_signed > ( std::floor ( ( y / static_cast< proshade_double > ( this->yDimSampling ) ) ) + ( static_cast< proshade_double > ( yDimMax ) / 2.0 ) );
372  *zBottom = static_cast< proshade_signed > ( std::floor ( ( z / static_cast< proshade_double > ( this->zDimSampling ) ) ) + ( static_cast< proshade_double > ( zDimMax ) / 2.0 ) );
373 
374  *xTop = *xBottom + 1;
375  *yTop = *yBottom + 1;
376  *zTop = *zBottom + 1;
377 
378  //================================================ Done
379  return ;
380 
381 }

◆ interpolateAlongFirst()

void ProSHADE_internal_spheres::ProSHADE_sphere::interpolateAlongFirst ( std::vector< proshade_double >  c000,
std::vector< proshade_double >  c001,
std::vector< proshade_double >  c010,
std::vector< proshade_double >  c011,
std::vector< proshade_double >  c100,
std::vector< proshade_double >  c101,
std::vector< proshade_double >  c110,
std::vector< proshade_double >  c111,
std::vector< proshade_double > *  c00,
std::vector< proshade_double > *  c01,
std::vector< proshade_double > *  c10,
std::vector< proshade_double > *  c11,
proshade_double  xd 
)
protected

This function interpolates along the first (X) dimension.

This function takes the 8 interpolation vectors for the neighbouring map points and proceeds to interpolate out the X axis from all of them, thus resulting in 4 new interpolation vectors which contain the Y and Z dimension values. This is the first step of the tri-linear interpolation procedure.

Parameters
[in]c000The interpolation vector for map point less less less (than the point of interest).
[in]c001The interpolation vector for map point less less more (than the point of interest).
[in]c010The interpolation vector for map point less more less (than the point of interest).
[in]c011The interpolation vector for map point less more more (than the point of interest).
[in]c100The interpolation vector for map point more less less (than the point of interest).
[in]c101The interpolation vector for map point more less more (than the point of interest).
[in]c110The interpolation vector for map point more more less (than the point of interest).
[in]c111The interpolation vector for map point more more more (than the point of interest).
[in]c00Pointer to the variable where the less less second interporetation vector will be saved.
[in]c01Pointer to the variable where the less more second interporetation vector will be saved.
[in]c10Pointer to the variable where the more less second interporetation vector will be saved.
[in]c11Pointer to the variable where the more more second interporetation vector will be saved.
[in]xdThe relative distance of the point of interest to the lower map point along the x axis.

Definition at line 442 of file ProSHADE_spheres.cpp.

443 {
444  //================================================ Interpolate for the less less point
445  c00->at(0) = ( static_cast< proshade_double > ( this->xDimSampling ) * xd ) + c000.at(0);
446  c00->at(1) = c000.at(1);
447  c00->at(2) = c000.at(2);
448  c00->at(3) = ( c000.at(3) * ( 1.0 - xd ) ) + ( c100.at(3) * xd );
449 
450  //================================================ Interpolate for the less more point
451  c01->at(0) = ( static_cast< proshade_double > ( this->xDimSampling ) * xd ) + c001.at(0);
452  c01->at(1) = c001.at(1);
453  c01->at(2) = c001.at(2);
454  c01->at(3) = ( c001.at(3) * ( 1.0 - xd ) ) + ( c101.at(3) * xd );
455 
456  //================================================ Interpolate for the more less point
457  c10->at(0) = ( static_cast< proshade_double > ( this->xDimSampling ) * xd ) + c010.at(0);
458  c10->at(1) = c010.at(1);
459  c10->at(2) = c010.at(2);
460  c10->at(3) = ( c010.at(3) * ( 1.0 - xd ) ) + ( c110.at(3) * xd );
461 
462  //================================================ Interpolate for the more more point
463  c11->at(0) = ( static_cast< proshade_double > ( this->xDimSampling ) * xd ) + c011.at(0);
464  c11->at(1) = c011.at(1);
465  c11->at(2) = c011.at(2);
466  c11->at(3) = ( c011.at(3) * ( 1.0 - xd ) ) + ( c111.at(3) * xd );
467 
468  //================================================ Done
469  return ;
470 
471 }

◆ interpolateAlongSecond()

void ProSHADE_internal_spheres::ProSHADE_sphere::interpolateAlongSecond ( std::vector< proshade_double >  c00,
std::vector< proshade_double >  c01,
std::vector< proshade_double >  c10,
std::vector< proshade_double >  c11,
std::vector< proshade_double > *  c0,
std::vector< proshade_double > *  c1,
proshade_double  yd 
)
protected

This function interpolates along the second (Y) dimension.

This function takes the 4 interpolation vectors for the neighbouring map points with the X axis already interpolate (that is, as outputted from the interpolateAlongFirst() function) and proceeds to interpolate out the Y axis from all of them, thus resulting in 2 new interpolation vectors which contain the Z dimension values only. This is the second step of the tri-linear interpolation procedure.

Parameters
[in]c00The interpolation vector for map point less less (than the point of interest) as returned from interpolateAlongFirst().
[in]c01The interpolation vector for map point less more (than the point of interest) as returned from interpolateAlongFirst().
[in]c10The interpolation vector for map point more less (than the point of interest) as returned from interpolateAlongFirst().
[in]c11The interpolation vector for map point more more (than the point of interest) as returned from interpolateAlongFirst().
[in]c0Pointer to the variable where the less third interporetation vector will be saved.
[in]c1Pointer to the variable where the more third interporetation vector will be saved.
[in]ydThe relative distance of the point of interest to the lower map point along the y axis.

Definition at line 488 of file ProSHADE_spheres.cpp.

489 {
490  //================================================ Interpolate for the less point
491  c0->at(0) = c00.at(0);
492  c0->at(1) = ( static_cast< proshade_double > ( this->yDimSampling ) * yd ) + c00.at(1);
493  c0->at(2) = c00.at(2);
494  c0->at(3) = ( c00.at(3) * ( 1.0 - yd ) ) + ( c10.at(3) * yd );
495 
496  //================================================ Interpolate for the more point
497  c1->at(0) = c01.at(0);
498  c1->at(1) = ( static_cast< proshade_double > ( this->yDimSampling ) * yd ) + c01.at(1);
499  c1->at(2) = c01.at(2);
500  c1->at(3) = ( c01.at(3) * ( 1.0 - yd ) ) + ( c11.at(3) * yd );
501 
502  //================================================ Done
503  return ;
504 
505 }

◆ mapData()

void ProSHADE_internal_spheres::ProSHADE_sphere::mapData ( proshade_double *  map,
proshade_unsign  xDimMax,
proshade_unsign  yDimMax,
proshade_unsign  zDimMax 
)
protected

This function maps the internal map to the specific sphere.

This function deals with the map values mapping onto a sphere in abstract terms, or in programatical terms it simply interpolates the appropriate map data onto a spherical grid a given by the sphere object calling it. It uses the tri-linear interpolation in the order XYZ and saves all results internally.

Parameters
[in]mapThe density map pointer - the map which should be mapped to the data.
[in]xDimMaxThe internal map maximum index in the x dimension.
[in]yDimMaxThe internal map maximum index in the y dimension.
[in]zDimMaxThe internal map maximum index in the z dimension.

Definition at line 178 of file ProSHADE_spheres.cpp.

179 {
180  //================================================ Initialise local variavles
181  proshade_double x, y, z, xRelative, yRelative, zRelative;
182  proshade_signed xBottom, yBottom, zBottom, xTop, yTop, zTop;
183  std::vector<proshade_double> lonCO ( this->localAngRes + 1 );
184  std::vector<proshade_double> latCO ( this->localAngRes + 1 );
185  std::vector<proshade_double> c000 = std::vector<proshade_double> ( 4 );
186  std::vector<proshade_double> c001 = std::vector<proshade_double> ( 4 );
187  std::vector<proshade_double> c010 = std::vector<proshade_double> ( 4 );
188  std::vector<proshade_double> c011 = std::vector<proshade_double> ( 4 );
189  std::vector<proshade_double> c100 = std::vector<proshade_double> ( 4 );
190  std::vector<proshade_double> c101 = std::vector<proshade_double> ( 4 );
191  std::vector<proshade_double> c110 = std::vector<proshade_double> ( 4 );
192  std::vector<proshade_double> c111 = std::vector<proshade_double> ( 4 );
193  std::vector<proshade_double> c00 = std::vector<proshade_double> ( 4 );
194  std::vector<proshade_double> c01 = std::vector<proshade_double> ( 4 );
195  std::vector<proshade_double> c10 = std::vector<proshade_double> ( 4 );
196  std::vector<proshade_double> c11 = std::vector<proshade_double> ( 4 );
197  std::vector<proshade_double> c0 = std::vector<proshade_double> ( 4 );
198  std::vector<proshade_double> c1 = std::vector<proshade_double> ( 4 );
199 
200  //================================================ Find pixelisation cutOffs
201  this->getLongitudeCutoffs ( &lonCO );
202  this->getLattitudeCutoffs ( &latCO );
203 
204  //================================================ Interpolate the map onto this shell
205  for ( unsigned int thIt = 0; thIt < this->localAngRes; thIt++ )
206  {
207  for ( unsigned int phIt = 0; phIt < this->localAngRes; phIt++ )
208  {
209  //======================================== Get grid point x, y and z
210  this->getInterpolationXYZ ( &x, &y, &z, thIt, &lonCO, phIt, &latCO );
211 
212  //======================================== Find 8 closest point around the grid point in indices
213  this->getXYZTopBottoms ( xDimMax, yDimMax, zDimMax, x, y, z, &xBottom, &yBottom, &zBottom, &xTop, &yTop, &zTop );
214 
215  //======================================== Get the 8 closest points interpolation vectors (or set to 0 if out-of-bounds)
216  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yBottom, zBottom, &c000 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
217  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yBottom, zTop , &c001 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
218  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yTop , zBottom, &c010 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
219  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yTop , zTop , &c011 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
220  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yBottom, zBottom, &c100 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
221  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yBottom, zTop , &c101 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
222  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yTop , zBottom, &c110 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
223  if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yTop , zTop , &c111 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0; continue; }
224 
225  //======================================== Interpolate along X axis
226  xRelative = ( x - ( static_cast< proshade_double > ( xBottom - static_cast<proshade_signed> ( ( ( xDimMax ) / 2 ) ) ) * static_cast< proshade_double > ( this->xDimSampling ) ) ) / static_cast< proshade_double > ( this->xDimSampling );
227  this->interpolateAlongFirst ( c000, c001, c010, c011, c100, c101, c110, c111, &c00, &c01, &c10, &c11, xRelative );
228 
229  //======================================== Interpolate along Y axis
230  yRelative = ( y - ( static_cast< proshade_double > ( yBottom - static_cast<proshade_signed> ( ( ( yDimMax ) / 2 ) ) ) * static_cast< proshade_double > ( this->yDimSampling ) ) ) / static_cast< proshade_double > ( this->yDimSampling );
231  this->interpolateAlongSecond ( c00, c01, c10, c11, &c0, &c1, yRelative );
232 
233  //======================================== Save the resulting value
234  zRelative = ( z - ( static_cast< proshade_double > ( zBottom - static_cast<proshade_signed> ( ( ( zDimMax ) / 2 ) ) ) * static_cast< proshade_double > ( this->zDimSampling ) ) ) / static_cast< proshade_double > ( this->zDimSampling );
235  this->mappedData[phIt * this->localAngRes + thIt] = ( c0.at(3) * ( 1.0 - zRelative ) ) + ( c1.at(3) * zRelative );
236  }
237  }
238 
239  //================================================ Done
240  return ;
241 
242 }

◆ setRotatedMappedData()

void ProSHADE_internal_spheres::ProSHADE_sphere::setRotatedMappedData ( proshade_unsign  pos,
proshade_double  value 
)

This function sets the rotated mapped data value to the given position.

Parameters
[in]posThe array position to which the value will be set to.
[in]valueThe value which should be set to the given position.

Definition at line 613 of file ProSHADE_spheres.cpp.

614 {
615  //================================================ Set the value to the position
616  this->mappedDataRot[pos] = value;
617 
618  //================================================ Done
619  return ;
620 
621 }

The documentation for this class was generated from the following files:
ProSHADE_internal_spheres::ProSHADE_sphere::getInterpolationXYZ
void getInterpolationXYZ(proshade_double *x, proshade_double *y, proshade_double *z, proshade_double thetaIt, std::vector< proshade_double > *lonCO, proshade_unsign phiIt, std::vector< proshade_double > *latCO)
This function finds the x, y and z positions of supplied shell point.
Definition: ProSHADE_spheres.cpp:336
ProSHADE_internal_spheres::ProSHADE_sphere::interpolateAlongFirst
void interpolateAlongFirst(std::vector< proshade_double > c000, std::vector< proshade_double > c001, std::vector< proshade_double > c010, std::vector< proshade_double > c011, std::vector< proshade_double > c100, std::vector< proshade_double > c101, std::vector< proshade_double > c110, std::vector< proshade_double > c111, std::vector< proshade_double > *c00, std::vector< proshade_double > *c01, std::vector< proshade_double > *c10, std::vector< proshade_double > *c11, proshade_double xd)
This function interpolates along the first (X) dimension.
Definition: ProSHADE_spheres.cpp:442
ProSHADE_internal_spheres::ProSHADE_sphere::getMapPoint
bool getMapPoint(proshade_double *map, proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_signed xPos, proshade_signed yPos, proshade_signed zPos, std::vector< proshade_double > *interpVec)
This function fills in the interpolation vector for a single map point.
Definition: ProSHADE_spheres.cpp:260
ProSHADE_internal_spheres::ProSHADE_sphere::getXYZTopBottoms
void getXYZTopBottoms(proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_double x, proshade_double y, proshade_double z, proshade_signed *xBottom, proshade_signed *yBottom, proshade_signed *zBottom, proshade_signed *xTop, proshade_signed *yTop, proshade_signed *zTop)
This function fills in the interpolation vector for a single map point.
Definition: ProSHADE_spheres.cpp:367
ProSHADE_internal_spheres::ProSHADE_sphere::getMaxCircumference
proshade_unsign getMaxCircumference(proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax, proshade_single maxRange)
This function determines the maximum circumference of a shell.
Definition: ProSHADE_spheres.cpp:121
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:68
ProSHADE_internal_spheres::autoDetermineBandwidth
proshade_unsign autoDetermineBandwidth(proshade_unsign circumference)
This function determines the bandwidth for the spherical harmonics computation.
Definition: ProSHADE_spheres.cpp:515
ProSHADE_internal_misc::addToUnsignVector
void addToUnsignVector(std::vector< proshade_unsign > *vecToAddTo, proshade_unsign elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:99
ProSHADE_internal_spheres::ProSHADE_sphere::getLongitudeCutoffs
void getLongitudeCutoffs(std::vector< proshade_double > *lonCO)
This function fills in the vector of longitudal bin boarder values.
Definition: ProSHADE_spheres.cpp:287
ProSHADE_internal_spheres::ProSHADE_sphere::mapData
void mapData(proshade_double *map, proshade_unsign xDimMax, proshade_unsign yDimMax, proshade_unsign zDimMax)
This function maps the internal map to the specific sphere.
Definition: ProSHADE_spheres.cpp:178
ProSHADE_internal_spheres::ProSHADE_sphere::interpolateAlongSecond
void interpolateAlongSecond(std::vector< proshade_double > c00, std::vector< proshade_double > c01, std::vector< proshade_double > c10, std::vector< proshade_double > c11, std::vector< proshade_double > *c0, std::vector< proshade_double > *c1, proshade_double yd)
This function interpolates along the second (Y) dimension.
Definition: ProSHADE_spheres.cpp:488
ProSHADE_internal_spheres::ProSHADE_sphere::getLattitudeCutoffs
void getLattitudeCutoffs(std::vector< proshade_double > *latCO)
This function fills in the vector of lattitudal bin boarder values.
Definition: ProSHADE_spheres.cpp:308