98 eulA, eulB, eulG, settings );
142 std::max ( staticStructure->
getYDim(), movingStructure->
getYDim() ),
143 std::max ( staticStructure->
getZDim(), movingStructure->
getZDim() ) );
145 std::max ( staticStructure->
getYDim(), movingStructure->
getYDim() ),
146 std::max ( staticStructure->
getZDim(), movingStructure->
getZDim() ) );
155 proshade_double mapPeak = 0.0;
156 proshade_unsign xDimS = staticStructure->
getXDim();
157 proshade_unsign yDimS = staticStructure->
getYDim();
158 proshade_unsign zDimS = staticStructure->
getZDim();
162 if ( *trsX > (
static_cast< proshade_double
> ( xDimS ) / 2.0 ) ) { *trsX = *trsX -
static_cast< proshade_double
> ( xDimS ); }
163 if ( *trsY > (
static_cast< proshade_double
> ( yDimS ) / 2.0 ) ) { *trsY = *trsY -
static_cast< proshade_double
> ( yDimS ); }
164 if ( *trsZ > (
static_cast< proshade_double
> ( zDimS ) / 2.0 ) ) { *trsZ = *trsZ -
static_cast< proshade_double
> ( zDimS ); }
173 proshade_single xMov =
static_cast< proshade_single
> ( -(*trsX) );
174 proshade_single yMov =
static_cast< proshade_single
> ( -(*trsY) );
175 proshade_single zMov =
static_cast< proshade_single
> ( -(*trsZ) );
178 std::stringstream hlpSS;
179 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 ) );
195 static_cast< proshade_signed
> ( movingStructure->
getXDim() ),
static_cast< proshade_signed
> ( movingStructure->
getYDim() ),
196 static_cast< proshade_signed
> ( movingStructure->
getZDim() ) );
223 proshade_single xSamplRate = (
static_cast< proshade_single
> ( staticStructure->
getXDimSize() ) /
static_cast< proshade_single
> ( staticStructure->
getXDim() ) );
224 proshade_single ySamplRate = (
static_cast< proshade_single
> ( staticStructure->
getYDimSize() ) /
static_cast< proshade_single
> ( staticStructure->
getYDim() ) );
225 proshade_single zSamplRate = (
static_cast< proshade_single
> ( staticStructure->
getZDimSize() ) /
static_cast< proshade_single
> ( staticStructure->
getZDim() ) );
227 proshade_single xCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
xFrom - movingStructure->
xFrom ) * xSamplRate );
228 proshade_single yCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
yFrom - movingStructure->
yFrom ) * ySamplRate );
229 proshade_single zCor =
static_cast< proshade_single
> (
static_cast< proshade_single
> ( staticStructure->
zFrom - movingStructure->
zFrom ) * zSamplRate );
231 proshade_single xMov =
static_cast< proshade_single
> ( 0.0 -
static_cast< proshade_double
> ( xCor ) - ( *trsX *
static_cast< proshade_double
> ( xSamplRate ) ) );
232 proshade_single yMov =
static_cast< proshade_single
> ( 0.0 -
static_cast< proshade_double
> ( yCor ) - ( *trsY *
static_cast< proshade_double
> ( ySamplRate ) ) );
233 proshade_single zMov =
static_cast< proshade_single
> ( 0.0 -
static_cast< proshade_double
> ( zCor ) - ( *trsZ *
static_cast< proshade_double
> ( zSamplRate ) ) );
236 *trsX =
static_cast< proshade_double
> ( -xMov );
237 *trsY =
static_cast< proshade_double
> ( -yMov );
238 *trsZ =
static_cast< proshade_double
> ( -zMov );
253 std::vector< proshade_double > ret;
254 proshade_double mapPeak = 0.0;
255 proshade_unsign xDimS = staticStructure->
getXDim();
256 proshade_unsign yDimS = staticStructure->
getYDim();
257 proshade_unsign zDimS = staticStructure->
getZDim();
258 proshade_double trsX = 0.0, trsY = 0.0, trsZ = 0.0;
269 if ( trsX > (
static_cast< proshade_double
> ( xDimS ) / 2.0 ) ) { trsX = trsX -
static_cast< proshade_double
> ( xDimS ); }
270 if ( trsY > (
static_cast< proshade_double
> ( yDimS ) / 2.0 ) ) { trsY = trsY -
static_cast< proshade_double
> ( yDimS ); }
271 if ( trsZ > (
static_cast< proshade_double
> ( zDimS ) / 2.0 ) ) { trsZ = trsZ -
static_cast< proshade_double
> ( zDimS ); }
276 this->originalPdbTransX = trsX;
277 this->originalPdbTransY = trsY;
278 this->originalPdbTransZ = trsZ;
280 proshade_single xMov =
static_cast< proshade_single
> ( -trsX );
281 proshade_single yMov =
static_cast< proshade_single
> ( -trsY );
282 proshade_single zMov =
static_cast< proshade_single
> ( -trsZ );
290 this->mapMovFromsChangeX =
static_cast<proshade_double
> ( this->xFrom );
291 this->mapMovFromsChangeY =
static_cast<proshade_double
> ( this->yFrom );
292 this->mapMovFromsChangeZ =
static_cast<proshade_double
> ( this->zFrom );
296 this->getXFromPtr(), this->getXToPtr(),
297 this->getYFromPtr(), this->getYToPtr(),
298 this->getZFromPtr(), this->getZToPtr(),
299 this->getXAxisOrigin(), this->getYAxisOrigin(), this->getZAxisOrigin() );
302 this->getXDimSize(), this->getYDimSize(), this->getZDimSize(),
303 static_cast< proshade_signed
> ( this->getXDim() ),
static_cast< proshade_signed
> ( this->getYDim() ),
static_cast< proshade_signed
> ( this->getZDim() ) );
306 this->mapMovFromsChangeX =
static_cast<proshade_double
> ( this->xFrom ) - this->mapMovFromsChangeX;
307 this->mapMovFromsChangeY =
static_cast<proshade_double
> ( this->yFrom ) - this->mapMovFromsChangeY;
308 this->mapMovFromsChangeZ =
static_cast<proshade_double
> ( this->zFrom ) - this->mapMovFromsChangeZ;
327 fftw_complex *tmpIn1 =
nullptr, *tmpOut1 =
nullptr, *tmpIn2 =
nullptr, *tmpOut2 =
nullptr, *resOut =
nullptr;
328 fftw_plan forwardFourierObj1, forwardFourierObj2, inverseFourierCombo;
329 proshade_unsign dimMult = staticStructure->
getXDim() * staticStructure->
getYDim() * staticStructure->
getZDim();
330 ProSHADE_internal_overlay::allocateTranslationFunctionMemory ( tmpIn1, tmpOut1, tmpIn2, tmpOut2, this->translationMap, resOut, forwardFourierObj1, forwardFourierObj2, inverseFourierCombo, staticStructure->
getXDim(), staticStructure->
getYDim(), staticStructure->
getZDim() );
333 for ( proshade_unsign iter = 0; iter < dimMult; iter++ ) { tmpIn1[iter][0] = staticStructure->
getMapValue ( iter ); tmpIn1[iter][1] = 0.0; }
334 for ( proshade_unsign iter = 0; iter < dimMult; iter++ ) { tmpIn2[iter][0] = this->getMapValue ( iter ); tmpIn2[iter][1] = 0.0; }
337 fftw_execute ( forwardFourierObj1 );
338 fftw_execute ( forwardFourierObj2 );
342 fftw_execute ( inverseFourierCombo );
367 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 )
370 tmpIn1 =
new fftw_complex[xD * yD * zD];
371 tmpOut1 =
new fftw_complex[xD * yD * zD];
372 tmpIn2 =
new fftw_complex[xD * yD * zD];
373 tmpOut2 =
new fftw_complex[xD * yD * zD];
374 resIn =
new fftw_complex[xD * yD * zD];
375 resOut =
new fftw_complex[xD * yD * zD];
386 forwardFourierObj1 = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), tmpIn1, tmpOut1, FFTW_FORWARD , FFTW_ESTIMATE );
387 forwardFourierObj2 = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), tmpIn2, tmpOut2, FFTW_FORWARD , FFTW_ESTIMATE );
388 inverseFourierCombo = fftw_plan_dft_3d (
static_cast< int > ( xD ),
static_cast< int > ( yD ),
static_cast< int > ( zD ), resOut, resIn , FFTW_BACKWARD, FFTW_ESTIMATE );
409 fftw_destroy_plan ( forwardFourierObj1 );
410 fftw_destroy_plan ( forwardFourierObj2 );
411 fftw_destroy_plan ( inverseFourierCombo );
436 if ( ( this->xDimIndices > xDim ) || ( this->yDimIndices > yDim ) || ( this->zDimIndices > zDim ) )
438 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." );
442 if ( ( this->xDimIndices == xDim ) && ( this->yDimIndices == yDim ) && ( this->zDimIndices == zDim ) ) { return ; }
445 proshade_unsign addXPre, addYPre, addZPre, addXPost, addYPost, addZPost;
446 ProSHADE_internal_overlay::computeBeforeAfterZeroCounts ( &addXPre, &addYPre, &addZPre, &addXPost, &addYPost, &addZPost, xDim, yDim, zDim, this->xDimIndices, this->yDimIndices, this->zDimIndices );
449 proshade_double* newMap =
new proshade_double [xDim * yDim * zDim];
452 ProSHADE_internal_overlay::paddMapWithZeroes ( this->internalMap, newMap, xDim, yDim, zDim, this->xDimIndices, this->yDimIndices, this->zDimIndices, addXPre, addYPre, addZPre );
455 delete[] this->internalMap;
456 this->internalMap =
new proshade_double [xDim * yDim * zDim];
457 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( xDim * yDim * zDim ); iter++ ) { this->internalMap[iter] = newMap[iter]; }
463 this->xDimSize =
static_cast< proshade_single
> ( xDim ) * ( this->xDimSize /
static_cast< proshade_single
> ( this->xDimIndices ) );
464 this->yDimSize =
static_cast< proshade_single
> ( yDim ) * ( this->yDimSize /
static_cast< proshade_single
> ( this->yDimIndices ) );
465 this->zDimSize =
static_cast< proshade_single
> ( zDim ) * ( this->zDimSize /
static_cast< proshade_single
> ( this->zDimIndices ) );
466 this->xDimIndices = xDim ; this->yDimIndices = yDim ; this->zDimIndices = zDim;
467 this->xGridIndices = xDim ; this->yGridIndices = yDim ; this->zGridIndices = zDim;
468 this->xFrom -= addXPre ; this->yFrom -= addYPre ; this->zFrom -= addZPre;
469 this->xTo += addXPost; this->yTo += addYPost; this->zTo += addZPost;
470 this->xAxisOrigin -= addXPre ; this->yAxisOrigin -= addYPre ; this->zAxisOrigin -= addZPre ;
492 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 )
495 *addXPre = ( xDim - xDimIndices ) / 2;
496 *addYPre = ( yDim - yDimIndices ) / 2;
497 *addZPre = ( zDim - zDimIndices ) / 2;
498 *addXPost = *addXPre;
if ( ( xDim - xDimIndices ) % 2 == 1 ) { *addXPost += 1; }
499 *addYPost = *addYPre;
if ( ( yDim - yDimIndices ) % 2 == 1 ) { *addYPost += 1; }
500 *addZPost = *addZPre;
if ( ( zDim - zDimIndices ) % 2 == 1 ) { *addZPost += 1; }
521 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 )
524 proshade_unsign newMapIndex = 0;
525 proshade_unsign oldMapIndex = 0;
528 for ( proshade_unsign xIt = 0; xIt < xDim; xIt++ )
530 for ( proshade_unsign yIt = 0; yIt < yDim; yIt++ )
532 for ( proshade_unsign zIt = 0; zIt < zDim; zIt++ )
535 newMapIndex = zIt + zDim * ( yIt + yDim * xIt );
538 if ( xIt < addXPre ) { newMap[newMapIndex] = 0.0;
continue; }
539 if ( yIt < addYPre ) { newMap[newMapIndex] = 0.0;
continue; }
540 if ( zIt < addZPre ) { newMap[newMapIndex] = 0.0;
continue; }
543 if ( xIt >= ( addXPre + xDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
544 if ( yIt >= ( addYPre + yDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
545 if ( zIt >= ( addZPre + zDimIndices ) ) { newMap[newMapIndex] = 0.0;
continue; }
548 oldMapIndex = (zIt-addZPre) + zDimIndices * ( (yIt-addYPre) + yDimIndices * (xIt-addXPre) );
549 newMap[newMapIndex] = oldMap[oldMapIndex];
574 this->maxCompBand = this->spheres[this->noSpheres-1]->getLocalBandwidth();
577 this->findMapCOM ( );
578 this->mapCOMProcessChangeX += ( this->xCom - this->originalMapXCom );
579 this->mapCOMProcessChangeY += ( this->yCom - this->originalMapYCom );
580 this->mapCOMProcessChangeZ += ( this->zCom - this->originalMapZCom );
586 this->allocateRotatedSHMemory ( );
589 this->computeRotatedSH ( );
592 this->invertSHCoefficients ( );
595 std::vector<proshade_double> lonCO, latCO;
599 proshade_double *densityMapRotated =
new proshade_double [this->xDimIndices * this->yDimIndices * this->zDimIndices];
601 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ ) { densityMapRotated[iter] = 0.0; }
604 this->interpolateMapFromSpheres ( densityMapRotated );
607 for ( proshade_unsign iter = 0; iter < ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
609 this->internalMap[iter] = densityMapRotated[iter];
613 delete[] densityMapRotated;
635 bool withinBounds =
true;
636 proshade_double c000, c001, c010, c011, c100, c101, c110, c111, c00, c01, c10, c11, c0, c1;
638 proshade_double xCOM, yCOM, zCOM;
639 std::vector< proshade_double > ret;
642 proshade_single xSampRate = this->xDimSize /
static_cast< proshade_single
> ( this->xTo - this->xFrom );
643 proshade_single ySampRate = this->yDimSize /
static_cast< proshade_single
> ( this->yTo - this->yFrom );
644 proshade_single zSampRate = this->zDimSize /
static_cast< proshade_single
> ( this->zTo - this->zFrom );
647 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 );
650 proshade_single *mins =
new proshade_single[3];
651 proshade_single *maxs =
new proshade_single[3];
652 proshade_single *rotMat =
new proshade_single[9];
653 proshade_single *rotVec;
654 proshade_single *interpMins =
new proshade_single[3];
655 proshade_single *interpMaxs =
new proshade_single[3];
656 proshade_single *interpDiff =
new proshade_single[3];
657 proshade_single *movs =
new proshade_single[3];
658 map =
new proshade_double[ this->xDimIndices * this->yDimIndices * this->zDimIndices ];
671 for (
size_t iter = 0; iter < static_cast< size_t > ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ ) { map[iter] = 0.0; }
674 mins[0] = std::floor (
static_cast< proshade_single
> ( this->xDimIndices ) / -2.0f );
675 mins[1] = std::floor (
static_cast< proshade_single
> ( this->yDimIndices ) / -2.0f );
676 mins[2] = std::floor (
static_cast< proshade_single
> ( this->zDimIndices ) / -2.0f );
682 if ( this->xDimIndices % 2 == 0 ) { maxs[0] -= 1.0f; }
683 if ( this->yDimIndices % 2 == 0 ) { maxs[1] -= 1.0f; }
684 if ( this->zDimIndices % 2 == 0 ) { maxs[2] -= 1.0f; }
700 for ( proshade_single xIt = mins[0]; xIt <= maxs[0]; xIt += 1.0f )
702 for ( proshade_single yIt = mins[1]; yIt <= maxs[1]; yIt += 1.0f )
704 for ( proshade_single zIt = mins[2]; zIt <= maxs[2]; zIt += 1.0f )
711 for (
size_t posIt = 0; posIt < 3; posIt++ )
714 interpMins[posIt] = std::floor ( rotVec[posIt] );
715 interpMaxs[posIt] = interpMins[posIt] + 1.0f;
718 if ( ( maxs[posIt] < interpMins[posIt] ) || ( interpMins[posIt] < mins[posIt] ) || ( maxs[posIt] < interpMaxs[posIt] ) || ( interpMaxs[posIt] < mins[posIt] ) )
720 withinBounds =
false;
725 interpDiff[posIt] = rotVec[posIt] - interpMins[posIt];
727 if ( !withinBounds ) {
continue; }
730 for (
size_t posIt = 0; posIt < 3; posIt++ )
732 interpMaxs[posIt] = std::min ( maxs[posIt], std::max ( mins[posIt], interpMaxs[posIt] ) );
739 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] ) ) );
740 c000 = this->internalMap[arrPos];
742 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] ) ) );
743 c001 = this->internalMap[arrPos];
745 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] ) ) );
746 c010 = this->internalMap[arrPos];
748 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] ) ) );
749 c011 = this->internalMap[arrPos];
751 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] ) ) );
752 c100 = this->internalMap[arrPos];
754 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] ) ) );
755 c101 = this->internalMap[arrPos];
757 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] ) ) );
758 c110 = this->internalMap[arrPos];
760 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] ) ) );
761 c111 = this->internalMap[arrPos];
764 c00 = ( c000 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c100 *
static_cast< proshade_double
> ( interpDiff[0] ) );
765 c01 = ( c001 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c101 *
static_cast< proshade_double
> ( interpDiff[0] ) );
766 c10 = ( c010 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c110 *
static_cast< proshade_double
> ( interpDiff[0] ) );
767 c11 = ( c011 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[0] ) ) ) + ( c111 *
static_cast< proshade_double
> ( interpDiff[0] ) );
770 c0 = ( c00 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[1] ) ) ) + ( c10 *
static_cast< proshade_double
> ( interpDiff[1] ) );
771 c1 = ( c01 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[1] ) ) ) + ( c11 *
static_cast< proshade_double
> ( interpDiff[1] ) );
774 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] ) ) );
775 map[arrPos] = ( c0 * ( 1.0 -
static_cast< proshade_double
> ( interpDiff[2] ) ) ) + ( c1 *
static_cast< proshade_double
> ( interpDiff[2] ) );
808 proshade_double axX, axY, axZ, axAng, tmp, *rMat, *map;
811 rMat =
new proshade_double[9];
836 std::vector< proshade_double > ret = this->rotateMapRealSpace ( axX, axY, axZ, axAng, map );
839 for (
size_t iter = 0; iter < static_cast< size_t > ( this->xDimIndices * this->yDimIndices * this->zDimIndices ); iter++ )
841 this->internalMap[iter] = map[iter];
849 this->originalPdbRotCenX = ret.at(0);
850 this->originalPdbRotCenY = ret.at(1);
851 this->originalPdbRotCenZ = ret.at(2);
871 proshade_single xMov =
static_cast< proshade_single
> ( -trsX );
872 proshade_single yMov =
static_cast< proshade_single
> ( -trsY );
873 proshade_single zMov =
static_cast< proshade_single
> ( -trsZ );
877 this->getXFromPtr(), this->getXToPtr(), this->getYFromPtr(), this->getYToPtr(),
878 this->getZFromPtr(), this->getZToPtr(), this->getXAxisOrigin(), this->getYAxisOrigin(), this->getZAxisOrigin() );
882 static_cast< proshade_signed
> ( this->getXDim() ),
static_cast< proshade_signed
> ( this->getYDim() ),
883 static_cast< proshade_signed
> ( this->getZDim() ) );
895 this->rotSphericalHarmonics =
new proshade_complex* [this->noSpheres];
899 for ( proshade_unsign iter = 0; iter < this->noSpheres; iter++ )
902 this->rotSphericalHarmonics[iter] =
new proshade_complex [
static_cast<proshade_unsign
> ( pow ( (this->spheres[iter]->getLocalBandwidth() * 2), 2) )];
906 for ( proshade_unsign it = 0; it < static_cast<proshade_unsign> ( pow ( (this->spheres[iter]->getLocalBandwidth() * 2), 2) ); it++ )
908 this->rotSphericalHarmonics[iter][it][0] = 0.0;
909 this->rotSphericalHarmonics[iter][it][1] = 0.0;
923 proshade_double WigDR, WigDI, *ShR, *ShI, retR, retI;
924 proshade_unsign arrPos;
927 for ( proshade_signed shell = 0; shell < static_cast<proshade_signed> ( this->noSpheres ); shell++ )
930 for ( proshade_signed bandIter = 0; bandIter < static_cast<proshade_signed> ( this->spheres[shell]->getLocalBandwidth() ); bandIter++ )
933 for ( proshade_signed order1 = 0; order1 < ( ( bandIter * 2 ) + 1 ); order1++ )
936 ShR = getRealSphHarmValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( shell ) );
937 ShI = getImagSphHarmValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( shell ) );
940 for ( proshade_signed order2 = 0; order2 < ( ( bandIter * 2 ) + 1 ); order2++ )
943 this->getWignerMatrixValue (
static_cast< proshade_unsign
> ( bandIter ),
static_cast< proshade_unsign
> ( order1 ),
static_cast< proshade_unsign
> ( order2 ), &WigDR, &WigDI );
949 arrPos =
static_cast<proshade_unsign
> ( seanindex (
static_cast< int > ( order2-bandIter ),
static_cast< int > ( bandIter ),
950 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ) ) );
951 this->rotSphericalHarmonics[shell][arrPos][0] += retR;
952 this->rotSphericalHarmonics[shell][arrPos][1] += retI;
978 proshade_unsign oneDim = shBand * 2;
981 sigR =
new double [(oneDim * oneDim * 4)];
982 sigI = sigR + (oneDim * oneDim * 2);
983 rcoeffs =
new double [(oneDim * oneDim * 2)];
984 icoeffs = rcoeffs + (oneDim * oneDim);
985 weights =
new double [4 * shBand];
986 workspace =
new double [( 20 * shBand * shBand ) + ( 24 * shBand )];
995 idctPlan = fftw_plan_r2r_1d (
static_cast< int > ( oneDim ), weights, workspace, FFTW_REDFT01, FFTW_ESTIMATE );
998 int rank, howmany_rank;
999 fftw_iodim dims[1], howmany_dims[1];
1002 dims[0].n = 2 *
static_cast< int > ( shBand );
1003 dims[0].is = 2 *
static_cast< int > ( shBand );
1006 howmany_dims[0].n = 2 *
static_cast< int > ( shBand );
1007 howmany_dims[0].is = 1;
1008 howmany_dims[0].os = 2 *
static_cast< int > ( shBand );
1011 ifftPlan = fftw_plan_guru_split_dft ( rank, dims, howmany_rank, howmany_dims, sigR, sigI, rcoeffs, icoeffs, FFTW_ESTIMATE );
1024 double *sigR =
nullptr, *sigI =
nullptr, *rcoeffs =
nullptr, *icoeffs =
nullptr, *weights =
nullptr, *workspace =
nullptr;
1025 fftw_plan idctPlan, ifftPlan;
1028 for (
int shell = 0; shell < static_cast<int> ( this->noSpheres ); shell++ )
1031 proshade_unsign oneDim = this->spheres[shell]->getLocalBandwidth() * 2;
1037 makeweights (
static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ), weights );
1040 this->spheres[shell]->allocateRotatedMap ( );
1043 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( oneDim * oneDim ); iter++ )
1045 rcoeffs[iter] = this->rotSphericalHarmonics[shell][iter][0];
1046 icoeffs[iter] = this->rotSphericalHarmonics[shell][iter][1];
1052 InvFST_semi_fly ( rcoeffs,
1056 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ),
1059 static_cast< int > ( this->spheres[shell]->getLocalBandwidth() ),
1064 for (
unsigned int iter = 0; iter < static_cast<unsigned int> ( oneDim * oneDim ); iter++ )
1066 this->spheres[shell]->setRotatedMappedData ( iter, sigR[iter] );
1070 fftw_destroy_plan ( idctPlan );
1071 fftw_destroy_plan ( ifftPlan );
1094 for ( proshade_unsign iter = 0; iter <= angRes; iter++ )
1096 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 ) ) );
1100 for ( proshade_unsign iter = 0; iter <= angRes; iter++ )
1102 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 ) );
1117 proshade_double rad = 0.0, lon = 0.0, lat = 0.0, newU = 0.0, newV = 0.0, newW = 0.0;
1118 proshade_unsign lowerLonL = 0, upperLonL = 0, lowerLonU = 0, upperLonU = 0, lowerLatL = 0, upperLatL = 0, lowerLatU = 0, upperLatU = 0, lowerShell = 0, upperShell = 0;
1119 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;
1120 proshade_double lowerShellValue = 0.0, upperShellValue = 0.0;
1121 proshade_double xSamplingRate =
static_cast<proshade_double
> ( this->xDimSize ) /
static_cast<proshade_double
> ( this->xDimIndices );
1122 proshade_double ySamplingRate =
static_cast<proshade_double
> ( this->yDimSize ) /
static_cast<proshade_double
> ( this->yDimIndices );
1123 proshade_double zSamplingRate =
static_cast<proshade_double
> ( this->zDimSize ) /
static_cast<proshade_double
> ( this->zDimIndices );
1124 proshade_signed arrPos;
1125 std::vector<proshade_double> lonCOU, latCOU, lonCOL, latCOL;
1127 for ( proshade_signed uIt = 0; uIt < static_cast<proshade_signed> (this->xDimIndices); uIt++ )
1129 for ( proshade_signed vIt = 0; vIt < static_cast<proshade_signed> (this->yDimIndices); vIt++ )
1131 for ( proshade_signed wIt = 0; wIt < static_cast<proshade_signed> (this->zDimIndices); wIt++ )
1134 newU =
static_cast<proshade_double
> ( uIt - (
static_cast<proshade_signed
> (this->xDimIndices) / 2 ) );
1135 newV =
static_cast<proshade_double
> ( vIt - (
static_cast<proshade_signed
> (this->yDimIndices) / 2 ) );
1136 newW =
static_cast<proshade_double
> ( wIt - (
static_cast<proshade_signed
> (this->zDimIndices) / 2 ) );
1139 if ( ( newU == 0.0 ) && ( newV == 0.0 ) && ( newW == 0.0 ) )
1141 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1142 densityMapRotated[arrPos] = this->internalMap[arrPos];
1147 rad = sqrt ( pow( ( newU * xSamplingRate ), 2.0 ) +
1148 pow( ( newV * ySamplingRate ), 2.0 ) +
1149 pow( ( newW * zSamplingRate ), 2.0 ) );
1150 lon = atan2 ( ( newV * ySamplingRate ), ( newU * xSamplingRate ) );
1151 lat = asin ( ( newW * zSamplingRate ) / rad );
1154 if ( rad != rad ) { rad = 0.0; }
1155 if ( lon != lon ) { lon = 0.0; }
1156 if ( lat != lat ) { lat = 0.0; }
1161 for ( proshade_unsign iter = 0; iter < (this->noSpheres-1); iter++ )
1163 if ( (
static_cast< proshade_double
> ( this->spherePos.at(iter) ) <= rad ) && (
static_cast< proshade_double
> ( this->spherePos.at(iter+1) ) > rad ) )
1166 upperShell = iter+1;
1171 if ( upperShell == 0 )
1173 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1174 densityMapRotated[arrPos] = 0.0;
1179 lonCOL.clear(); latCOL.clear(); lonCOU.clear(); latCOU.clear();
1184 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( lonCOL.size() ); iter++ )
1186 if ( iter == (
static_cast<proshade_unsign
> ( lonCOL.size() ) - 1 ) )
1192 if ( ( std::floor(10000. * lonCOL.at(iter)) <= std::floor(10000. * lon) ) && ( std::floor(10000. * lonCOL.at(iter+1)) > std::floor(10000. * lon) ) )
1199 if ( upperLonL == this->spheres[lowerShell]->getLocalAngRes() ) { upperLonL = 0; }
1201 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( lonCOU.size() ); iter++ )
1203 if ( iter == (
static_cast<proshade_unsign
> ( lonCOU.size() ) - 1 ) )
1209 if ( ( std::floor(10000. * lonCOU.at(iter)) <= std::floor(10000. * lon) ) && ( std::floor(10000. * lonCOU.at(iter+1)) > std::floor(10000. * lon) ) )
1216 if ( upperLonU == this->spheres[upperShell]->getLocalAngRes() ) { upperLonU = 0; }
1218 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( latCOL.size() ); iter++ )
1220 if ( iter == (
static_cast<proshade_unsign
> ( latCOL.size() ) - 1 ) )
1226 if ( ( std::floor(10000. * latCOL.at(iter)) <= std::floor(10000. * lat) ) && ( std::floor(10000. * latCOL.at(iter+1)) > std::floor(10000. * lat) ) )
1233 if ( upperLatL == this->spheres[lowerShell]->getLocalAngRes() ) { upperLatL = 0; }
1235 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( latCOU.size() ); iter++ )
1237 if ( iter == (
static_cast<proshade_unsign
> ( latCOU.size() ) - 1 ) )
1243 if ( ( std::floor(10000. * latCOU.at(iter)) <= std::floor(10000. * lat) ) && ( std::floor(10000. * latCOU.at(iter+1)) > std::floor(10000. * lat) ) )
1250 if ( upperLatU == this->spheres[upperShell]->getLocalAngRes() ) { upperLatU = 0; }
1253 x00 = this->spheres[lowerShell]->getRotatedMappedData ( lowerLatL * this->spheres[lowerShell]->getLocalAngRes() + lowerLonL );
1254 x01 = this->spheres[lowerShell]->getRotatedMappedData ( lowerLatL * this->spheres[lowerShell]->getLocalAngRes() + upperLonL );
1255 x10 = this->spheres[lowerShell]->getRotatedMappedData ( upperLatL * this->spheres[lowerShell]->getLocalAngRes() + lowerLonL );
1256 x11 = this->spheres[lowerShell]->getRotatedMappedData ( upperLatL * this->spheres[lowerShell]->getLocalAngRes() + upperLonL );
1258 distLLon = std::abs ( lon - lonCOL.at(lowerLonL) ) / ( std::abs( lon - lonCOL.at(lowerLonL) ) + std::abs( lon - lonCOL.at(upperLonL) ) );
1259 valLLon = ( ( 1.0 - distLLon ) * x00 ) + ( distLLon * x01 );
1260 valULon = ( ( 1.0 - distLLon ) * x10 ) + ( distLLon * x11 );
1262 distLLat = std::abs ( lat - latCOL.at(lowerLatL) ) / ( std::abs( lat - latCOL.at(lowerLatL) ) + std::abs( lat - latCOL.at(upperLatL) ) );
1263 lowerShellValue = ( ( 1.0 - distLLat ) * valLLon ) + ( distLLat * valULon );
1266 x00 = this->spheres[upperShell]->getRotatedMappedData ( lowerLatU * this->spheres[upperShell]->getLocalAngRes() + lowerLonU );
1267 x01 = this->spheres[upperShell]->getRotatedMappedData ( lowerLatU * this->spheres[upperShell]->getLocalAngRes() + upperLonU );
1268 x10 = this->spheres[upperShell]->getRotatedMappedData ( upperLatU * this->spheres[upperShell]->getLocalAngRes() + lowerLonU );
1269 x11 = this->spheres[upperShell]->getRotatedMappedData ( upperLatU * this->spheres[upperShell]->getLocalAngRes() + upperLonU );
1271 distLLon = std::abs ( lon - lonCOU.at(lowerLonU) ) / ( std::abs( lon - lonCOU.at(lowerLonU) ) + std::abs( lon - lonCOU.at(upperLonU) ) );
1272 valLLon = ( ( 1.0 - distLLon ) * x00 ) + ( distLLon * x01 );
1273 valULon = ( ( 1.0 - distLLon ) * x10 ) + ( distLLon * x11 );
1275 distLLat = std::abs ( lat - latCOU.at(lowerLatU) ) / ( std::abs( lat - latCOU.at(lowerLatU) ) + std::abs( lat - latCOU.at(upperLatU) ) );
1276 upperShellValue = ( ( 1.0 - distLLat ) * valLLon ) + ( distLLat * valULon );
1279 distLRad = std::abs ( rad -
static_cast< proshade_double
> ( this->spherePos.at(lowerShell) ) ) / ( std::abs( rad -
static_cast< proshade_double
> ( this->spherePos.at(lowerShell) ) ) +
1280 std::abs( rad -
static_cast< proshade_double
> ( this->spherePos.at(upperShell) ) ) );
1282 arrPos = wIt +
static_cast< proshade_signed
> ( this->zDimIndices ) * ( vIt +
static_cast< proshade_signed
> ( this->yDimIndices ) * uIt );
1283 densityMapRotated[arrPos] = ( ( 1.0 - distLRad ) * lowerShellValue ) + ( distLRad * upperShellValue );
1303 std::vector < proshade_double > ret;
1304 proshade_double eulA, eulB, eulG;
1308 this->getMaxBand() * 2,
1309 &eulA, &eulB, &eulG, settings );