71 proshade_double xSamplRate =
static_cast<proshade_double
> ( this->xDimSizeOriginal /
static_cast< proshade_single
> ( this->xDimIndicesOriginal ) );
72 proshade_double ySamplRate =
static_cast<proshade_double
> ( this->yDimSizeOriginal /
static_cast< proshade_single
> ( this->yDimIndicesOriginal ) );
73 proshade_double zSamplRate =
static_cast<proshade_double
> ( this->zDimSizeOriginal /
static_cast< proshade_single
> ( this->zDimIndicesOriginal ) );
76 proshade_double xRotPos = (
static_cast<proshade_double
> ( this->xFrom ) - this->mapMovFromsChangeX ) * xSamplRate +
77 ( ( (
static_cast<proshade_double
> ( this->xTo ) -
static_cast<proshade_double
> ( this->xFrom ) ) / 2.0 ) * xSamplRate );
79 proshade_double yRotPos = (
static_cast<proshade_double
> ( this->yFrom ) - this->mapMovFromsChangeY ) * ySamplRate +
80 ( ( (
static_cast<proshade_double
> ( this->yTo ) -
static_cast<proshade_double
> ( this->yFrom ) ) / 2.0 ) * ySamplRate );
82 proshade_double zRotPos = (
static_cast<proshade_double
> ( this->zFrom ) - this->mapMovFromsChangeZ ) * zSamplRate +
83 ( ( (
static_cast<proshade_double
> ( this->zTo ) -
static_cast<proshade_double
> ( this->zFrom ) ) / 2.0 ) * zSamplRate );
86 this->originalPdbRotCenX = xRotPos - ( this->mapCOMProcessChangeX / 2.0 );
87 this->originalPdbRotCenY = yRotPos - ( this->mapCOMProcessChangeY / 2.0 );
88 this->originalPdbRotCenZ = zRotPos - ( this->mapCOMProcessChangeZ / 2.0 );
112 this->originalPdbTransX = 0.0;
113 this->originalPdbTransY = 0.0;
114 this->originalPdbTransZ = 0.0;
117 if ( ( eulA != 0.0 ) || ( eulB != 0.0 ) || ( eulG != 0.0 ) )
125 this->originalPdbTransX = this->mapCOMProcessChangeX;
126 this->originalPdbTransY = this->mapCOMProcessChangeY;
127 this->originalPdbTransZ = this->mapCOMProcessChangeZ;
131 this->originalPdbTransX +=
static_cast< proshade_double
> ( trsX );
132 this->originalPdbTransY +=
static_cast< proshade_double
> ( trsY );
133 this->originalPdbTransZ +=
static_cast< proshade_double
> ( trsZ );
178 eulA, eulB, eulG, settings );
218 std::max ( staticStructure->
getYDim(), movingStructure->
getYDim() ),
219 std::max ( staticStructure->
getZDim(), movingStructure->
getZDim() ) );
221 std::max ( staticStructure->
getYDim(), movingStructure->
getYDim() ),
222 std::max ( staticStructure->
getZDim(), movingStructure->
getZDim() ) );
231 proshade_double mapPeak = 0.0;
232 proshade_unsign xDimS = staticStructure->
getXDim();
233 proshade_unsign yDimS = staticStructure->
getYDim();
234 proshade_unsign zDimS = staticStructure->
getZDim();
238 if ( *trsX > (
static_cast< proshade_double
> ( xDimS ) / 2.0 ) ) { *trsX = *trsX -
static_cast< proshade_double
> ( xDimS ); }
239 if ( *trsY > (
static_cast< proshade_double
> ( yDimS ) / 2.0 ) ) { *trsY = *trsY -
static_cast< proshade_double
> ( yDimS ); }
240 if ( *trsZ > (
static_cast< proshade_double
> ( zDimS ) / 2.0 ) ) { *trsZ = *trsZ -
static_cast< proshade_double
> ( zDimS ); }
243 proshade_single xCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
xFrom - movingStructure->
xFrom ) *
244 (
static_cast< proshade_single
> ( staticStructure->
getXDimSize() ) /
245 static_cast< proshade_single
> ( staticStructure->
getXDim() ) ) );
246 proshade_single yCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
yFrom - movingStructure->
yFrom ) *
247 (
static_cast< proshade_single
> ( staticStructure->
getYDimSize() ) /
248 static_cast< proshade_single
> ( staticStructure->
getYDim() ) ) );
249 proshade_single zCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
zFrom - movingStructure->
zFrom ) *
250 (
static_cast< proshade_single
> ( staticStructure->
getZDimSize() ) /
251 static_cast< proshade_single
> ( staticStructure->
getZDim() ) ) );
252 proshade_single xMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeX -
static_cast< proshade_double
> ( xCor ) -
253 ( *trsX *
static_cast< proshade_double
> ( staticStructure->
getXDimSize() ) /
254 static_cast< proshade_double
> ( staticStructure->
getXDim() ) ) );
255 proshade_single yMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeY -
static_cast< proshade_double
> ( yCor ) -
256 ( *trsY *
static_cast< proshade_double
> ( staticStructure->
getYDimSize() ) /
257 static_cast< proshade_double
> ( staticStructure->
getYDim() ) ) );
258 proshade_single zMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeZ -
static_cast< proshade_double
> ( zCor ) -
259 ( *trsZ *
static_cast< proshade_double
> ( staticStructure->
getZDimSize() ) /
260 static_cast< proshade_double
> ( staticStructure->
getZDim() ) ) );
263 *trsX =
static_cast< proshade_double
> ( -xMov );
264 *trsY =
static_cast< proshade_double
> ( -yMov );
265 *trsZ =
static_cast< proshade_double
> ( -zMov );
268 std::stringstream hlpSS;
269 hlpSS <<
"Optimal map translation distances are " << *trsX <<
" ; " << *trsY <<
" ; " << *trsZ <<
" Angstroms with peak height " << mapPeak / (
static_cast< proshade_double
> ( xDimS ) *
static_cast< proshade_double
> ( yDimS ) *
static_cast< proshade_double
> ( zDimS ) );
285 static_cast< proshade_signed
> ( movingStructure->
getXDim() ),
static_cast< proshade_signed
> ( movingStructure->
getYDim() ),
286 static_cast< proshade_signed
> ( movingStructure->
getZDim() ) );
299 movingStructure->
computeOptimalTranslation ( eulA, eulB, eulG,
static_cast< proshade_single
> ( *trsX ),
static_cast< proshade_single
> ( *trsY ),
static_cast< proshade_single
> ( *trsZ ) );
314 std::vector< proshade_double > ret;
315 proshade_double mapPeak = 0.0;
316 proshade_double trsX = 0.0, trsY = 0.0, trsZ = 0.0;
327 if ( trsX > (
static_cast< proshade_double
> ( staticStructure->
getXDim() ) / 2.0 ) ) { trsX = trsX -
static_cast< proshade_double
> ( this->getXDim() ); }
328 if ( trsY > (
static_cast< proshade_double
> ( staticStructure->
getYDim() ) / 2.0 ) ) { trsY = trsY -
static_cast< proshade_double
> ( this->getYDim() ); }
329 if ( trsZ > (
static_cast< proshade_double
> ( staticStructure->
getZDim() ) / 2.0 ) ) { trsZ = trsZ -
static_cast< proshade_double
> ( this->getZDim() ); }
332 proshade_single xCor =
static_cast< proshade_single
> (
static_cast< proshade_double
> ( staticStructure->
xFrom - this->xFrom ) *
333 (
static_cast< proshade_double
> ( staticStructure->
getXDimSize() ) /
334 static_cast< proshade_double
> ( staticStructure->
getXDim() ) ) );
335 proshade_single yCor =
static_cast< proshade_single
> (
static_cast< proshade_double
> ( staticStructure->
yFrom - this->yFrom ) *
336 (
static_cast< proshade_double
> ( staticStructure->
getYDimSize() ) /
337 static_cast< proshade_double
> ( staticStructure->
getYDim() ) ) );
338 proshade_single zCor =
static_cast< proshade_single
> (
static_cast< proshade_double
> ( staticStructure->
zFrom - this->zFrom ) *
339 (
static_cast< proshade_double
> ( staticStructure->
getZDimSize() ) /
340 static_cast< proshade_double
> ( staticStructure->
getZDim() ) ) );
341 proshade_single xMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeX -
static_cast< proshade_double
> ( xCor ) -
342 ( trsX *
static_cast<proshade_double
> ( staticStructure->
getXDimSize() ) /
343 static_cast<proshade_double
> ( staticStructure->
getXDim() ) ) );
344 proshade_single yMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeY -
static_cast< proshade_double
> ( yCor ) -
345 ( trsY *
static_cast<proshade_double
> ( staticStructure->
getYDimSize() ) /
346 static_cast<proshade_double
> ( staticStructure->
getYDim() ) ) );
347 proshade_single zMov =
static_cast< proshade_single
> ( staticStructure->
mapCOMProcessChangeZ -
static_cast< proshade_double
> ( zCor ) -
348 ( trsZ *
static_cast<proshade_double
> ( staticStructure->
getZDimSize() ) /
349 static_cast<proshade_double
> ( staticStructure->
getZDim() ) ) );
350 proshade_single modXMov = xMov;
351 proshade_single modYMov = yMov;
352 proshade_single modZMov = zMov;
360 this->mapMovFromsChangeX =
static_cast<proshade_double
> ( this->xFrom );
361 this->mapMovFromsChangeY =
static_cast<proshade_double
> ( this->yFrom );
362 this->mapMovFromsChangeZ =
static_cast<proshade_double
> ( this->zFrom );
366 this->getXFromPtr(), this->getXToPtr(),
367 this->getYFromPtr(), this->getYToPtr(),
368 this->getZFromPtr(), this->getZToPtr(),
369 this->getXAxisOrigin(), this->getYAxisOrigin(), this->getZAxisOrigin() );
372 this->getXDimSize(), this->getYDimSize(), this->getZDimSize(),
373 static_cast< proshade_signed
> ( this->getXDim() ),
static_cast< proshade_signed
> ( this->getYDim() ),
static_cast< proshade_signed
> ( this->getZDim() ) );
376 this->mapMovFromsChangeX =
static_cast<proshade_double
> ( this->xFrom ) - this->mapMovFromsChangeX;
377 this->mapMovFromsChangeY =
static_cast<proshade_double
> ( this->yFrom ) - this->mapMovFromsChangeY;
378 this->mapMovFromsChangeZ =
static_cast<proshade_double
> ( this->zFrom ) - this->mapMovFromsChangeZ;
381 this->computePdbRotationCentre ( );
382 this->computeOptimalTranslation ( eulA, eulB, eulG, -xMov, -yMov, -zMov );
401 fftw_complex *tmpIn1 =
nullptr, *tmpOut1 =
nullptr, *tmpIn2 =
nullptr, *tmpOut2 =
nullptr, *resOut =
nullptr;
402 fftw_plan forwardFourierObj1, forwardFourierObj2, inverseFourierCombo;
403 proshade_unsign dimMult = staticStructure->
getXDim() * staticStructure->
getYDim() * staticStructure->
getZDim();
404 ProSHADE_internal_overlay::allocateTranslationFunctionMemory ( tmpIn1, tmpOut1, tmpIn2, tmpOut2, this->translationMap, resOut, forwardFourierObj1, forwardFourierObj2, inverseFourierCombo, staticStructure->
getXDim(), staticStructure->
getYDim(), staticStructure->
getZDim() );
407 for ( proshade_unsign iter = 0; iter < dimMult; iter++ ) { tmpIn1[iter][0] = staticStructure->
getMapValue ( iter ); tmpIn1[iter][1] = 0.0; }
408 for ( proshade_unsign iter = 0; iter < dimMult; iter++ ) { tmpIn2[iter][0] = this->getMapValue ( iter ); tmpIn2[iter][1] = 0.0; }
411 fftw_execute ( forwardFourierObj1 );
412 fftw_execute ( forwardFourierObj2 );
416 fftw_execute ( inverseFourierCombo );
441 void ProSHADE_internal_overlay::allocateTranslationFunctionMemory ( fftw_complex*& tmpIn1, fftw_complex*& tmpOut1, fftw_complex*& tmpIn2, fftw_complex*& tmpOut2, fftw_complex*& resIn, fftw_complex*& resOut, fftw_plan& forwardFourierObj1, fftw_plan& forwardFourierObj2, fftw_plan& inverseFourierCombo, proshade_unsign xD, proshade_unsign yD, proshade_unsign zD )
444 tmpIn1 =
new fftw_complex[xD * yD * zD];
445 tmpOut1 =
new fftw_complex[xD * yD * zD];
446 tmpIn2 =
new fftw_complex[xD * yD * zD];
447 tmpOut2 =
new fftw_complex[xD * yD * zD];
448 resIn =
new fftw_complex[xD * yD * zD];
449 resOut =
new fftw_complex[xD * yD * zD];
460 forwardFourierObj1 = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), tmpIn1, tmpOut1, FFTW_FORWARD , FFTW_ESTIMATE );
461 forwardFourierObj2 = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), tmpIn2, tmpOut2, FFTW_FORWARD , FFTW_ESTIMATE );
462 inverseFourierCombo = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), resOut, resIn , FFTW_BACKWARD, FFTW_ESTIMATE );
483 fftw_destroy_plan ( forwardFourierObj1 );
484 fftw_destroy_plan ( forwardFourierObj2 );
485 fftw_destroy_plan ( inverseFourierCombo );
509 double normFactor =
static_cast<double> ( xD * yD * zD );
510 proshade_signed arrPos;
513 proshade_single *mins =
new proshade_single[3];
514 proshade_single *maxs =
new proshade_single[3];
521 mins[0] = std::floor (
static_cast< proshade_single
> ( xD ) / -2.0f );
522 mins[1] = std::floor (
static_cast< proshade_single
> ( yD ) / -2.0f );
523 mins[2] = std::floor (
static_cast< proshade_single
> ( zD ) / -2.0f );
529 if ( xD % 2 == 0 ) { mins[0] += 1.0f; }
530 if ( yD % 2 == 0 ) { mins[1] += 1.0f; }
531 if ( zD % 2 == 0 ) { mins[2] += 1.0f; }
534 for ( proshade_signed xIt = 0; xIt < static_cast< proshade_signed > ( xD ); xIt++ )
536 for ( proshade_signed yIt = 0; yIt < static_cast< proshade_signed > ( yD ); yIt++ )
538 for ( proshade_signed zIt = 0; zIt < static_cast< proshade_signed > ( zD / 2 ) + 1; zIt++ )
541 arrPos = zIt +
static_cast< proshade_signed
> ( zD ) * ( yIt +
static_cast< proshade_signed
> ( yD ) * xIt );
549 &resOut[arrPos][1] );
552 resOut[arrPos][0] /= normFactor;
553 resOut[arrPos][1] /= normFactor;
581 proshade_signed arrPos;
585 for ( proshade_signed uIt = 0; uIt < static_cast<proshade_signed> ( xD ); uIt++ )
587 for ( proshade_signed vIt = 0; vIt < static_cast<proshade_signed> ( yD ); vIt++ )
589 for ( proshade_signed wIt = 0; wIt < static_cast<proshade_signed> ( zD ); wIt++ )
591 arrPos = wIt +
static_cast< proshade_signed
> ( zD ) * ( vIt +
static_cast< proshade_signed
> ( yD ) * uIt );
592 if ( resIn[arrPos][0] > *mapPeak )
594 *mapPeak = resIn[arrPos][0];
595 *trsX =
static_cast< proshade_double
> ( uIt );
596 *trsY =
static_cast< proshade_double
> ( vIt );
597 *trsZ =
static_cast< proshade_double
> ( wIt );
621 if ( ( this->xDimIndices > xDim ) || ( this->yDimIndices > yDim ) || ( this->zDimIndices > zDim ) )
623 throw ProSHADE_exception (
"Cannot zero-pad in negative direction.",
"EO00034", __FILE__, __LINE__, __func__,
"The requested padded size of a structure is smaller than\n : the current size. If the user sees this error, there is\n : likely a considerable bug. Please report this error." );
627 if ( ( this->xDimIndices == xDim ) && ( this->yDimIndices == yDim ) && ( this->zDimIndices == zDim ) ) { return ; }
630 proshade_unsign addXPre, addYPre, addZPre, addXPost, addYPost, addZPost;
631 ProSHADE_internal_overlay::computeBeforeAfterZeroCounts ( &addXPre, &addYPre, &addZPre, &addXPost, &addYPost, &addZPost, xDim, yDim, zDim, this->xDimIndices, this->yDimIndices, this->zDimIndices );
634 proshade_double* newMap =
new proshade_double [xDim * yDim * zDim];
637 ProSHADE_internal_overlay::paddMapWithZeroes ( this->internalMap, newMap, xDim, yDim, zDim, this->xDimIndices, this->yDimIndices, this->zDimIndices, addXPre, addYPre, addZPre );
640 delete[] this->internalMap;
641 this->internalMap =
new proshade_double [xDim * yDim * zDim];
642 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( xDim * yDim * zDim ); iter++ ) { this->internalMap[iter] = newMap[iter]; }
648 this->xDimSize =
static_cast< proshade_single
> ( xDim ) * ( this->xDimSize /
static_cast< proshade_single
> ( this->xDimIndices ) );
649 this->yDimSize =
static_cast< proshade_single
> ( yDim ) * ( this->yDimSize /
static_cast< proshade_single
> ( this->yDimIndices ) );
650 this->zDimSize =
static_cast< proshade_single
> ( zDim ) * ( this->zDimSize /
static_cast< proshade_single
> ( this->zDimIndices ) );
651 this->xDimIndices = xDim ; this->yDimIndices = yDim ; this->zDimIndices = zDim;
652 this->xGridIndices = xDim ; this->yGridIndices = yDim ; this->zGridIndices = zDim;
653 this->xFrom -= addXPre ; this->yFrom -= addYPre ; this->zFrom -= addZPre;
654 this->xTo += addXPost; this->yTo += addYPost; this->zTo += addZPost;
655 this->xAxisOrigin -= addXPre ; this->yAxisOrigin -= addYPre ; this->zAxisOrigin -= addZPre ;
677 void ProSHADE_internal_overlay::computeBeforeAfterZeroCounts ( proshade_unsign* addXPre, proshade_unsign* addYPre, proshade_unsign* addZPre, proshade_unsign* addXPost, proshade_unsign* addYPost, proshade_unsign* addZPost, proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim, proshade_unsign xDimIndices, proshade_unsign yDimIndices, proshade_unsign zDimIndices )
680 *addXPre = ( xDim - xDimIndices ) / 2;
681 *addYPre = ( yDim - yDimIndices ) / 2;
682 *addZPre = ( zDim - zDimIndices ) / 2;
683 *addXPost = *addXPre;
if ( ( xDim - xDimIndices ) % 2 == 1 ) { *addXPost += 1; }
684 *addYPost = *addYPre;
if ( ( yDim - yDimIndices ) % 2 == 1 ) { *addYPost += 1; }
685 *addZPost = *addZPre;
if ( ( zDim - zDimIndices ) % 2 == 1 ) { *addZPost += 1; }
706 void ProSHADE_internal_overlay::paddMapWithZeroes ( proshade_double* oldMap, proshade_double*& newMap, proshade_unsign xDim, proshade_unsign yDim, proshade_unsign zDim, proshade_unsign xDimIndices, proshade_unsign yDimIndices, proshade_unsign zDimIndices, proshade_unsign addXPre, proshade_unsign addYPre, proshade_unsign addZPre )
709 proshade_unsign newMapIndex = 0;
710 proshade_unsign oldMapIndex = 0;
713 for ( proshade_unsign xIt = 0; xIt < xDim; xIt++ )
715 for ( proshade_unsign yIt = 0; yIt < yDim; yIt++ )
717 for ( proshade_unsign zIt = 0; zIt < zDim; zIt++ )
720 newMapIndex = zIt + zDim * ( yIt + yDim * xIt );
723 if ( xIt < addXPre ) { newMap[newMapIndex] = 0.0;
continue; }
724 if ( yIt < addYPre ) { newMap[newMapIndex] = 0.0;
continue; }
725 if ( zIt < addZPre ) { newMap[newMapIndex] = 0.0;
continue; }
728 if ( xIt >= ( addXPre + xDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
729 if ( yIt >= ( addYPre + yDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
730 if ( zIt >= ( addZPre + zDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
733 oldMapIndex = (zIt-addZPre) + zDimIndices * ( (yIt-addYPre) + yDimIndices * (xIt-addXPre) );
734 newMap[newMapIndex] = oldMap[oldMapIndex];
759 this->maxCompBand = this->spheres[this->noSpheres-1]->getLocalBandwidth();
762 this->findMapCOM ( );
763 this->mapCOMProcessChangeX += ( this->xCom - this->originalMapXCom );
764 this->mapCOMProcessChangeY += ( this->yCom - this->originalMapYCom );
765 this->mapCOMProcessChangeZ += ( this->zCom - this->originalMapZCom );
771 this->allocateRotatedSHMemory ( );
774 this->computeRotatedSH ( );
777 this->invertSHCoefficients ( );
780 std::vector<proshade_double> lonCO, latCO;
784 proshade_double *densityMapRotated =
new proshade_double [this->xDimIndices * this->yDimIndices * this->zDimIndices];
786 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ ) { densityMapRotated[iter] = 0.0; }
789 this->interpolateMapFromSpheres ( densityMapRotated );
792 for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
794 this->internalMap[iter] = densityMapRotated[iter];
798 delete[] densityMapRotated;
819 bool withinBounds =
true;
820 proshade_double c000, c001, c010, c011, c100, c101, c110, c111, c00, c01, c10, c11, c0, c1;
822 proshade_double xCOM, yCOM, zCOM;
825 proshade_single xSampRate = this->xDimSize /
static_cast< proshade_single
> ( this->xTo - this->xFrom );
826 proshade_single ySampRate = this->yDimSize /
static_cast< proshade_single
> ( this->yTo - this->yFrom );
827 proshade_single zSampRate = this->zDimSize /
static_cast< proshade_single
> ( this->zTo - this->zFrom );
830 ProSHADE_internal_mapManip::findMAPCOMValues ( this->internalMap, &xCOM, &yCOM, &zCOM, this->xDimSize, this->yDimSize, this->zDimSize, this->xFrom, this->xTo, this->yFrom, this->yTo, this->zFrom, this->zTo );
833 proshade_single *mins =
new proshade_single[3];
834 proshade_single *maxs =
new proshade_single[3];
835 proshade_single *rotMat =
new proshade_single[9];
836 proshade_single *rotVec;
837 proshade_single *interpMins =
new proshade_single[3];
838 proshade_single *interpMaxs =
new proshade_single[3];
839 proshade_single *interpDiff =
new proshade_single[3];
840 proshade_single *movs =
new proshade_single[3];
841 map =
new proshade_double[ this->xDimIndices * this->yDimIndices * this->zDimIndices ];
854 for (
size_t iter = 0; iter < static_cast< size_t > ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ ) { map[iter] = 0.0; }
857 mins[0] = std::floor (
static_cast< proshade_single
> ( this->xDimIndices ) / -2.0f );
858 mins[1] = std::floor (
static_cast< proshade_single
> ( this->yDimIndices ) / -2.0f );
859 mins[2] = std::floor (
static_cast< proshade_single
> ( this->zDimIndices ) / -2.0f );
865 if ( this->xDimIndices % 2 == 0 ) { maxs[0] -= 1.0f; }
866 if ( this->yDimIndices % 2 == 0 ) { maxs[1] -= 1.0f; }
867 if ( this->zDimIndices % 2 == 0 ) { maxs[2] -= 1.0f; }
870 movs[0] = (
static_cast< proshade_single
> ( xCOM ) / xSampRate ) + ( mins[0] -
static_cast< proshade_single
> ( this->xFrom ) );
871 movs[1] = (
static_cast< proshade_single
> ( yCOM ) / ySampRate ) + ( mins[1] -
static_cast< proshade_single
> ( this->yFrom ) );
872 movs[2] = (
static_cast< proshade_single
> ( zCOM ) / zSampRate ) + ( mins[2] -
static_cast< proshade_single
> ( this->zFrom ) );
878 for ( proshade_single xIt = mins[0]; xIt <= maxs[0]; xIt += 1.0f )
880 for ( proshade_single yIt = mins[1]; yIt <= maxs[1]; yIt += 1.0f )
882 for ( proshade_single zIt = mins[2]; zIt <= maxs[2]; zIt += 1.0f )
889 for (
size_t posIt = 0; posIt < 3; posIt++ )
892 interpMins[posIt] = std::floor ( rotVec[posIt] );
893 interpMaxs[posIt] = interpMins[posIt] + 1.0f;
896 if ( ( maxs[posIt] < interpMins[posIt] ) || ( interpMins[posIt] < mins[posIt] ) || ( maxs[posIt] < interpMaxs[posIt] ) || ( interpMaxs[posIt] < mins[posIt] ) )
898 withinBounds =
false;
903 interpDiff[posIt] = rotVec[posIt] - interpMins[posIt];
905 if ( !withinBounds ) {
continue; }
908 for (
size_t posIt = 0; posIt < 3; posIt++ )
910 interpMaxs[posIt] = std::min ( maxs[posIt], std::max ( mins[posIt], interpMaxs[posIt] ) );
917 arrPos =
static_cast< size_t > ( ( interpMins[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMins[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMins[0] - mins[0] ) ) );
918 c000 = this->internalMap[arrPos];
920 arrPos =
static_cast< size_t > ( ( interpMaxs[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMins[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMins[0] - mins[0] ) ) );
921 c001 = this->internalMap[arrPos];
923 arrPos =
static_cast< size_t > ( ( interpMins[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMaxs[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMins[0] - mins[0] ) ) );
924 c010 = this->internalMap[arrPos];
926 arrPos =
static_cast< size_t > ( ( interpMaxs[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMaxs[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMins[0] - mins[0] ) ) );
927 c011 = this->internalMap[arrPos];
929 arrPos =
static_cast< size_t > ( ( interpMins[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMins[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMaxs[0] - mins[0] ) ) );
930 c100 = this->internalMap[arrPos];
932 arrPos =
static_cast< size_t > ( ( interpMaxs[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMins[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMaxs[0] - mins[0] ) ) );
933 c101 = this->internalMap[arrPos];
935 arrPos =
static_cast< size_t > ( ( interpMins[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMaxs[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMaxs[0] - mins[0] ) ) );
936 c110 = this->internalMap[arrPos];
938 arrPos =
static_cast< size_t > ( ( interpMaxs[2] - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( interpMaxs[1] - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( interpMaxs[0] - mins[0] ) ) );
939 c111 = this->internalMap[arrPos];
942 c00 = ( c000 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c100 *
static_cast< proshade_double
> ( interpDiff[0] ) );
943 c01 = ( c001 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c101 *
static_cast< proshade_double
> ( interpDiff[0] ) );
944 c10 = ( c010 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c110 *
static_cast< proshade_double
> ( interpDiff[0] ) );
945 c11 = ( c011 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c111 *
static_cast< proshade_double
> ( interpDiff[0] ) );
948 c0 = ( c00 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[1] ) ) ) + ( c10 *
static_cast< proshade_double
> ( interpDiff[1] ) );
949 c1 = ( c01 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[1] ) ) ) + ( c11 *
static_cast< proshade_double
> ( interpDiff[1] ) );
952 arrPos =
static_cast< size_t > ( ( zIt - mins[2] ) +
static_cast< proshade_single
> ( this->zDimIndices ) * ( ( yIt - mins[1] ) +
static_cast< proshade_single
> ( this->yDimIndices ) * ( xIt - mins[0] ) ) );
953 map[arrPos] = ( c0 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[2] ) ) ) + ( c1 *
static_cast< proshade_double
> ( interpDiff[2] ) );
985 proshade_double axX, axY, axZ, axAng, tmp, *rMat, *map;
988 rMat =
new proshade_double[9];
1013 this->rotateMapRealSpace ( axX, axY, axZ, axAng, map );
1016 for (
size_t iter = 0; iter < static_cast< size_t > ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
1018 this->internalMap[iter] = map[iter];
1043 proshade_single xMov =
static_cast< proshade_single
> ( -trsX );
1044 proshade_single yMov =
static_cast< proshade_single
> ( -trsY );
1045 proshade_single zMov =
static_cast< proshade_single
> ( -trsZ );
1049 this->getXFromPtr(), this->getXToPtr(), this->getYFromPtr(), this->getYToPtr(),
1050 this->getZFromPtr(), this->getZToPtr(), this->getXAxisOrigin(), this->getYAxisOrigin(), this->getZAxisOrigin() );
1054 static_cast< proshade_signed
> ( this->getXDim() ),
static_cast< proshade_signed
> ( this->getYDim() ),
1055 static_cast< proshade_signed
> ( this->getZDim() ) );
1067 this->rotSphericalHarmonics =
new proshade_complex* [this->noSpheres];
1071 for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
1074 this->rotSphericalHarmonics[iter] =
new proshade_complex [
static_cast<proshade_unsign
> ( pow ( (this->spheres[iter]->getLocalBandwidth() * 2), 2) )];
1078 for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( pow ( (this->spheres[iter]->getLocalBandwidth() * 2), 2) ); it++ )
1080 this->rotSphericalHarmonics[iter][it][0] = 0.0;
1081 this->rotSphericalHarmonics[iter][it][1] = 0.0;
1095 proshade_double WigDR, WigDI, *ShR, *ShI, retR, retI;
1096 proshade_unsign arrPos;
1099 for ( proshade_signed shell = 0; shell < static_cast<proshade_signed> ( this->noSpheres ); shell++ )
1102 for ( proshade_signed bandIter = 0; bandIter < static_cast<proshade_signed> ( this->spheres[shell]->getLocalBandwidth() ); bandIter++ )
1105 for ( proshade_signed order1 = 0; order1 < ( ( bandIter * 2 ) + 1 ); order1++ )
1108 ShR = getRealSphHarmValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( shell ) );
1109 ShI = getImagSphHarmValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( shell ) );
1112 for ( proshade_signed order2 = 0; order2 < ( ( bandIter * 2 ) + 1 ); order2++ )
1115 this->getWignerMatrixValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( order2 ), &WigDR, &WigDI );
1121 arrPos =
static_cast<proshade_unsign
> ( seanindex (
static_cast< int > ( order2-bandIter ),
static_cast< int > ( bandIter ),
1122 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ) ) );
1123 this->rotSphericalHarmonics[shell][arrPos][0] += retR;
1124 this->rotSphericalHarmonics[shell][arrPos][1] += retI;
1150 proshade_unsign oneDim = shBand * 2;
1153 sigR =
new double [(oneDim * oneDim * 4)];
1154 sigI = sigR + (oneDim * oneDim * 2);
1155 rcoeffs =
new double [(oneDim * oneDim * 2)];
1156 icoeffs = rcoeffs + (oneDim * oneDim);
1157 weights =
new double [4 * shBand];
1158 workspace =
new double [( 20 * shBand * shBand ) + ( 24 * shBand )];
1167 idctPlan = fftw_plan_r2r_1d (
static_cast< int > ( oneDim ), weights, workspace, FFTW_REDFT01, FFTW_ESTIMATE );
1170 int rank, howmany_rank;
1171 fftw_iodim dims[1], howmany_dims[1];
1174 dims[0].n = 2 *
static_cast< int > ( shBand );
1175 dims[0].is = 2 *
static_cast< int > ( shBand );
1178 howmany_dims[0].n = 2 *
static_cast< int > ( shBand );
1179 howmany_dims[0].is = 1;
1180 howmany_dims[0].os = 2 *
static_cast< int > ( shBand );
1183 ifftPlan = fftw_plan_guru_split_dft ( rank, dims, howmany_rank, howmany_dims, sigR, sigI, rcoeffs, icoeffs, FFTW_ESTIMATE );
1196 double *sigR =
nullptr, *sigI =
nullptr, *rcoeffs =
nullptr, *icoeffs =
nullptr, *weights =
nullptr, *workspace =
nullptr;
1197 fftw_plan idctPlan, ifftPlan;
1200 for (
int shell = 0; shell < static_cast<int> ( this->noSpheres ); shell++ )
1203 proshade_unsign oneDim = this->spheres[shell]->getLocalBandwidth() * 2;
1209 makeweights (
static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ), weights );
1212 this->spheres[shell]->allocateRotatedMap ( );
1215 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( oneDim * oneDim ); iter++ )
1217 rcoeffs[iter] = this->rotSphericalHarmonics[shell][iter][0];
1218 icoeffs[iter] = this->rotSphericalHarmonics[shell][iter][1];
1224 InvFST_semi_fly ( rcoeffs,
1228 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ),
1231 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ),
1236 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( oneDim * oneDim ); iter++ )
1238 this->spheres[shell]->setRotatedMappedData ( iter, sigR[iter] );
1242 fftw_destroy_plan ( idctPlan );
1243 fftw_destroy_plan ( ifftPlan );
1266 for ( proshade_unsign iter = 0; iter <= angRes; iter++ )
1268 ProSHADE_internal_misc::addToDoubleVector ( lonCO,
static_cast<proshade_double
> ( iter ) * ( (
static_cast<proshade_double
> ( M_PI ) * 2.0 ) /
static_cast<proshade_double
> ( angRes ) ) - (
static_cast<double> ( M_PI ) ) );
1272 for ( proshade_unsign iter = 0; iter <= angRes; iter++ )
1274 ProSHADE_internal_misc::addToDoubleVector ( latCO,
static_cast<proshade_double
> ( iter ) * (
static_cast<proshade_double
> ( M_PI ) /
static_cast<proshade_double
> ( angRes ) ) - (
static_cast<proshade_double
> ( M_PI ) / 2.0 ) );
1289 proshade_double rad = 0.0, lon = 0.0, lat = 0.0, newU = 0.0, newV = 0.0, newW = 0.0;
1290 proshade_unsign lowerLonL = 0, upperLonL = 0, lowerLonU = 0, upperLonU = 0, lowerLatL = 0, upperLatL = 0, lowerLatU = 0, upperLatU = 0, lowerShell = 0, upperShell = 0;
1291 proshade_double x00 = 0.0, x01 = 0.0, x10 = 0.0, x11 = 0.0, distLLon = 0.0, distLLat = 0.0, distLRad = 0.0, valLLon = 0.0, valULon = 0.0;
1292 proshade_double lowerShellValue = 0.0, upperShellValue = 0.0;
1293 proshade_double xSamplingRate =
static_cast<proshade_double
> ( this->xDimSize ) /
static_cast<proshade_double
> ( this->xDimIndices );
1294 proshade_double ySamplingRate =
static_cast<proshade_double
> ( this->yDimSize ) /
static_cast<proshade_double
> ( this->yDimIndices );
1295 proshade_double zSamplingRate =
static_cast<proshade_double
> ( this->zDimSize ) /
static_cast<proshade_double
> ( this->zDimIndices );
1296 proshade_signed arrPos;
1297 std::vector<proshade_double> lonCOU, latCOU, lonCOL, latCOL;
1299 for ( proshade_signed uIt = 0; uIt < static_cast<proshade_signed> (this->xDimIndices); uIt++ )
1301 for ( proshade_signed vIt = 0; vIt < static_cast<proshade_signed> (this->yDimIndices); vIt++ )
1303 for ( proshade_signed wIt = 0; wIt < static_cast<proshade_signed> (this->zDimIndices); wIt++ )
1306 newU =
static_cast<proshade_double
> ( uIt - (
static_cast<proshade_signed
> (this->xDimIndices) / 2 ) );
1307 newV =
static_cast<proshade_double
> ( vIt - (
static_cast<proshade_signed
> (this->yDimIndices) / 2 ) );
1308 newW =
static_cast<proshade_double
> ( wIt - (
static_cast<proshade_signed
> (this->zDimIndices) / 2 ) );
1311 if ( ( newU == 0.0 ) && ( newV == 0.0 ) && ( newW == 0.0 ) )
1313 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1314 densityMapRotated[arrPos] = this->internalMap[arrPos];
1319 rad = sqrt ( pow( ( newU * xSamplingRate ), 2.0 ) +
1320 pow( ( newV * ySamplingRate ), 2.0 ) +
1321 pow( ( newW * zSamplingRate ), 2.0 ) );
1322 lon = atan2 ( ( newV * ySamplingRate ), ( newU * xSamplingRate ) );
1323 lat = asin ( ( newW * zSamplingRate ) / rad );
1326 if ( rad != rad ) { rad = 0.0; }
1327 if ( lon != lon ) { lon = 0.0; }
1328 if ( lat != lat ) { lat = 0.0; }
1333 for ( proshade_unsign iter = 0; iter < (this->noSpheres-1); iter++ )
1335 if ( (
static_cast< proshade_double
> ( this->spherePos.at(iter) ) <= rad ) && (
static_cast< proshade_double
> ( this->spherePos.at(iter+1) ) > rad ) )
1338 upperShell = iter+1;
1343 if ( upperShell == 0 )
1345 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1346 densityMapRotated[arrPos] = 0.0;
1351 lonCOL.clear(); latCOL.clear(); lonCOU.clear(); latCOU.clear();
1356 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( lonCOL.size() ); iter++ )
1358 if ( iter == (
static_cast<proshade_unsign
> ( lonCOL.size() ) - 1 ) )
1364 if ( ( std::floor(10000. * lonCOL.at(iter)) <= std::floor(10000. * lon) ) && ( std::floor(10000. * lonCOL.at(iter+1)) > std::floor(10000. * lon) ) )
1371 if ( upperLonL == this->spheres[lowerShell]->getLocalAngRes() ) { upperLonL = 0; }
1373 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( lonCOU.size() ); iter++ )
1375 if ( iter == (
static_cast<proshade_unsign
> ( lonCOU.size() ) - 1 ) )
1381 if ( ( std::floor(10000. * lonCOU.at(iter)) <= std::floor(10000. * lon) ) && ( std::floor(10000. * lonCOU.at(iter+1)) > std::floor(10000. * lon) ) )
1388 if ( upperLonU == this->spheres[upperShell]->getLocalAngRes() ) { upperLonU = 0; }
1390 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( latCOL.size() ); iter++ )
1392 if ( iter == (
static_cast<proshade_unsign
> ( latCOL.size() ) - 1 ) )
1398 if ( ( std::floor(10000. * latCOL.at(iter)) <= std::floor(10000. * lat) ) && ( std::floor(10000. * latCOL.at(iter+1)) > std::floor(10000. * lat) ) )
1405 if ( upperLatL == this->spheres[lowerShell]->getLocalAngRes() ) { upperLatL = 0; }
1407 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( latCOU.size() ); iter++ )
1409 if ( iter == (
static_cast<proshade_unsign
> ( latCOU.size() ) - 1 ) )
1415 if ( ( std::floor(10000. * latCOU.at(iter)) <= std::floor(10000. * lat) ) && ( std::floor(10000. * latCOU.at(iter+1)) > std::floor(10000. * lat) ) )
1422 if ( upperLatU == this->spheres[upperShell]->getLocalAngRes() ) { upperLatU = 0; }
1425 x00 = this->spheres[lowerShell]->getRotatedMappedData ( lowerLatL * this->spheres[lowerShell]->getLocalAngRes() + lowerLonL );
1426 x01 = this->spheres[lowerShell]->getRotatedMappedData ( lowerLatL * this->spheres[lowerShell]->getLocalAngRes() + upperLonL );
1427 x10 = this->spheres[lowerShell]->getRotatedMappedData ( upperLatL * this->spheres[lowerShell]->getLocalAngRes() + lowerLonL );
1428 x11 = this->spheres[lowerShell]->getRotatedMappedData ( upperLatL * this->spheres[lowerShell]->getLocalAngRes() + upperLonL );
1430 distLLon = std::abs ( lon - lonCOL.at(lowerLonL) ) / ( std::abs( lon - lonCOL.at(lowerLonL) ) + std::abs( lon - lonCOL.at(upperLonL) ) );
1431 valLLon = ( ( 1.0 - distLLon ) * x00 ) + ( distLLon * x01 );
1432 valULon = ( ( 1.0 - distLLon ) * x10 ) + ( distLLon * x11 );
1434 distLLat = std::abs ( lat - latCOL.at(lowerLatL) ) / ( std::abs( lat - latCOL.at(lowerLatL) ) + std::abs( lat - latCOL.at(upperLatL) ) );
1435 lowerShellValue = ( ( 1.0 - distLLat ) * valLLon ) + ( distLLat * valULon );
1438 x00 = this->spheres[upperShell]->getRotatedMappedData ( lowerLatU * this->spheres[upperShell]->getLocalAngRes() + lowerLonU );
1439 x01 = this->spheres[upperShell]->getRotatedMappedData ( lowerLatU * this->spheres[upperShell]->getLocalAngRes() + upperLonU );
1440 x10 = this->spheres[upperShell]->getRotatedMappedData ( upperLatU * this->spheres[upperShell]->getLocalAngRes() + lowerLonU );
1441 x11 = this->spheres[upperShell]->getRotatedMappedData ( upperLatU * this->spheres[upperShell]->getLocalAngRes() + upperLonU );
1443 distLLon = std::abs ( lon - lonCOU.at(lowerLonU) ) / ( std::abs( lon - lonCOU.at(lowerLonU) ) + std::abs( lon - lonCOU.at(upperLonU) ) );
1444 valLLon = ( ( 1.0 - distLLon ) * x00 ) + ( distLLon * x01 );
1445 valULon = ( ( 1.0 - distLLon ) * x10 ) + ( distLLon * x11 );
1447 distLLat = std::abs ( lat - latCOU.at(lowerLatU) ) / ( std::abs( lat - latCOU.at(lowerLatU) ) + std::abs( lat - latCOU.at(upperLatU) ) );
1448 upperShellValue = ( ( 1.0 - distLLat ) * valLLon ) + ( distLLat * valULon );
1451 distLRad = std::abs ( rad -
static_cast< proshade_double
> ( this->spherePos.at(lowerShell) ) ) / ( std::abs( rad -
static_cast< proshade_double
> ( this->spherePos.at(lowerShell) ) ) +
1452 std::abs( rad -
static_cast< proshade_double
> ( this->spherePos.at(upperShell) ) ) );
1454 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1455 densityMapRotated[arrPos] = ( ( 1.0 - distLRad ) * lowerShellValue ) + ( distLRad * upperShellValue );
1475 std::vector < proshade_double > ret;
1476 proshade_double eulA, eulB, eulG;
1480 this->getMaxBand() * 2,
1481 &eulA, &eulB, &eulG, settings );