47 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, proshade_unsign* maxCompBand )
50 this->shellOrder = shOrder;
51 this->sphereWidth =
static_cast< proshade_single
> ( ( spherePos->at(0) + spherePos->at(1) ) / 2.0f );
52 this->sphereRadius =
static_cast< proshade_double
> ( spherePos->at(shOrder) );
55 proshade_double maxDist = 0.0;
56 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) ) ); }
57 else { maxDist =
static_cast<proshade_double
> ( ( spherePos->at(shOrder) + spherePos->at(shOrder+1) ) / 2.0f ); }
60 this->maxSphereRange =
static_cast<proshade_single
> ( 2.0 * maxDist );
63 this->xDimSampling = xSize /
static_cast<proshade_single
> (xDimMax);
64 this->yDimSampling = ySize /
static_cast<proshade_single
> (yDimMax);
65 this->zDimSampling = zSize /
static_cast<proshade_single
> (zDimMax);
68 proshade_unsign maxCircumference = this->
getMaxCircumference ( xDimMax, yDimMax, zDimMax, this->maxSphereRange );
71 if ( progressiveMapping )
74 this->localAngRes = this->localBandwidth * 2;
78 this->localBandwidth = band;
79 this->localAngRes = this->localBandwidth * 2;
83 if ( *maxShellBand < this->localBandwidth ) { *maxShellBand = this->localBandwidth; *maxCompBand = this->localBandwidth; }
86 this->mappedData =
new proshade_double[this->localAngRes * this->localAngRes];
90 this->mappedDataRot =
nullptr;
93 this->
mapData ( map, xDimMax, yDimMax, zDimMax );
105 delete[] this->mappedData;
107 if ( this->mappedDataRot !=
nullptr )
109 delete[] this->mappedDataRot;
125 proshade_signed xFromInd =
static_cast<proshade_signed
> ( xDimMax / 2 ) -
126 static_cast<proshade_signed
> ( (maxRange/2) / this->xDimSampling );
127 proshade_signed yFromInd =
static_cast<proshade_signed
> ( yDimMax / 2 ) -
128 static_cast<proshade_signed
> ( (maxRange/2) / this->yDimSampling );
129 proshade_signed zFromInd =
static_cast<proshade_signed
> ( zDimMax / 2 ) -
130 static_cast<proshade_signed
> ( (maxRange/2) / this->zDimSampling );
132 proshade_signed xToInd =
static_cast<proshade_signed
> ( xDimMax / 2 ) +
133 static_cast<proshade_signed
> ( (maxRange/2) / this->xDimSampling );
134 proshade_signed yToInd =
static_cast<proshade_signed
> ( yDimMax / 2 ) +
135 static_cast<proshade_signed
> ( (maxRange/2) / this->yDimSampling );
136 proshade_signed zToInd =
static_cast<proshade_signed
> ( zDimMax / 2 ) +
137 static_cast<proshade_signed
> ( (maxRange/2) / this->zDimSampling );
140 if ( xFromInd < 0 ) { xFromInd = 0; }
141 if ( yFromInd < 0 ) { yFromInd = 0; }
142 if ( zFromInd < 0 ) { zFromInd = 0; }
143 if ( xToInd >
static_cast<proshade_signed
> ( xDimMax ) ) { xToInd =
static_cast<proshade_signed
> ( xDimMax ); }
144 if ( yToInd >
static_cast<proshade_signed
> ( yDimMax ) ) { yToInd =
static_cast<proshade_signed
> ( yDimMax ); }
145 if ( zToInd >
static_cast<proshade_signed
> ( zDimMax ) ) { zToInd =
static_cast<proshade_signed
> ( zDimMax ); }
148 proshade_unsign xDimSZ =
static_cast< proshade_unsign
> ( xToInd - xFromInd );
149 proshade_unsign yDimSZ =
static_cast< proshade_unsign
> ( yToInd - yFromInd );
150 proshade_unsign zDimSZ =
static_cast< proshade_unsign
> ( zToInd - zFromInd );
153 if ( ( xDimSZ == 0 ) && ( yDimSZ == 0 ) && ( zDimSZ == 0 ) ) { xDimSZ = 1; yDimSZ = 1; zDimSZ = 1; }
156 std::vector<proshade_unsign> dimSizes;
160 std::sort ( dimSizes.begin(), dimSizes.end() );
161 proshade_unsign maxDim = dimSizes.at(2);
162 proshade_unsign midDim = dimSizes.at(1);
165 return ( maxDim + midDim );
182 proshade_double x, y, z, xRelative, yRelative, zRelative;
183 proshade_signed xBottom, yBottom, zBottom, xTop, yTop, zTop;
184 std::vector<proshade_double> lonCO ( this->localAngRes + 1 );
185 std::vector<proshade_double> latCO ( this->localAngRes + 1 );
186 std::vector<proshade_double> c000 = std::vector<proshade_double> ( 4 );
187 std::vector<proshade_double> c001 = std::vector<proshade_double> ( 4 );
188 std::vector<proshade_double> c010 = std::vector<proshade_double> ( 4 );
189 std::vector<proshade_double> c011 = std::vector<proshade_double> ( 4 );
190 std::vector<proshade_double> c100 = std::vector<proshade_double> ( 4 );
191 std::vector<proshade_double> c101 = std::vector<proshade_double> ( 4 );
192 std::vector<proshade_double> c110 = std::vector<proshade_double> ( 4 );
193 std::vector<proshade_double> c111 = std::vector<proshade_double> ( 4 );
194 std::vector<proshade_double> c00 = std::vector<proshade_double> ( 4 );
195 std::vector<proshade_double> c01 = std::vector<proshade_double> ( 4 );
196 std::vector<proshade_double> c10 = std::vector<proshade_double> ( 4 );
197 std::vector<proshade_double> c11 = std::vector<proshade_double> ( 4 );
198 std::vector<proshade_double> c0 = std::vector<proshade_double> ( 4 );
199 std::vector<proshade_double> c1 = std::vector<proshade_double> ( 4 );
202 this->getLongitudeCutoffs ( &lonCO );
203 this->getLattitudeCutoffs ( &latCO );
206 for (
unsigned int thIt = 0; thIt < this->localAngRes; thIt++ )
208 for (
unsigned int phIt = 0; phIt < this->localAngRes; phIt++ )
211 this->getInterpolationXYZ ( &x, &y, &z, thIt, &lonCO, phIt, &latCO );
214 this->getXYZTopBottoms ( xDimMax, yDimMax, zDimMax, x, y, z, &xBottom, &yBottom, &zBottom, &xTop, &yTop, &zTop );
217 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yBottom, zBottom, &c000 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
218 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yBottom, zTop , &c001 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
219 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yTop , zBottom, &c010 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
220 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xBottom, yTop , zTop , &c011 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
221 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yBottom, zBottom, &c100 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
222 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yBottom, zTop , &c101 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
223 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yTop , zBottom, &c110 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
224 if ( !getMapPoint ( map, xDimMax, yDimMax, zDimMax, xTop , yTop , zTop , &c111 ) ) { this->mappedData[phIt * this->localAngRes + thIt] = 0.0;
continue; }
227 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 );
228 this->interpolateAlongFirst ( c000, c001, c010, c011, c100, c101, c110, c111, &c00, &c01, &c10, &c11, xRelative );
231 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 );
232 this->interpolateAlongSecond ( c00, c01, c10, c11, &c0, &c1, yRelative );
235 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 );
236 this->mappedData[phIt * this->localAngRes + thIt] = ( c0.at(3) * ( 1.0 - zRelative ) ) + ( c1.at(3) * zRelative );
264 proshade_signed posIter = zPos +
static_cast<proshade_signed
> ( zDimMax ) * ( yPos +
static_cast<proshade_signed
> ( yDimMax ) * xPos );
267 if ( ( xPos < 0 ) || ( xPos >=
static_cast<proshade_signed
> ( xDimMax ) ) ) {
return (
false ); }
268 if ( ( yPos < 0 ) || ( yPos >=
static_cast<proshade_signed
> ( yDimMax ) ) ) {
return (
false ); }
269 if ( ( zPos < 0 ) || ( zPos >=
static_cast<proshade_signed
> ( zDimMax ) ) ) {
return (
false ); }
272 interpVec->at(0) =
static_cast<proshade_double
> ( xPos ) *
static_cast<proshade_double
> ( this->xDimSampling );
273 interpVec->at(1) =
static_cast<proshade_double
> ( yPos ) *
static_cast<proshade_double
> ( this->yDimSampling );
274 interpVec->at(2) =
static_cast<proshade_double
> ( zPos ) *
static_cast<proshade_double
> ( this->zDimSampling );
275 interpVec->at(3) = map[posIter];
291 for ( proshade_unsign iter = 0; iter <= this->localAngRes; iter++ )
293 lonCO->at(iter) =
static_cast<proshade_double
> ( iter ) *
294 ( (
static_cast<proshade_double
> ( M_PI ) * 2.0 ) /
static_cast<proshade_double
> ( this->localAngRes ) ) -
295 (
static_cast<proshade_double
> ( M_PI ) );
312 for ( proshade_unsign iter = 0; iter <= this->localAngRes; iter++ )
314 latCO->at(iter) = (
static_cast<proshade_double
> ( iter ) *
315 (
static_cast<proshade_double
> ( M_PI ) /
static_cast<proshade_double
> ( this->localAngRes ) ) -
316 (
static_cast<proshade_double
> ( M_PI ) / 2.0 ) );
340 *x = this->sphereRadius * std::cos ( ( lonCO->at(
static_cast<proshade_unsign
> ( thetaIt ) ) + lonCO->at(
static_cast<proshade_unsign
> ( thetaIt+1 ) ) ) / 2.0 ) *
341 std::cos ( ( latCO->at(
static_cast<proshade_unsign
> ( phiIt ) ) + latCO->at(
static_cast<proshade_unsign
> ( phiIt+1 ) ) ) / 2.0 );
342 *y = this->sphereRadius * std::sin ( ( lonCO->at(
static_cast<proshade_unsign
> ( thetaIt ) ) + lonCO->at(
static_cast<proshade_unsign
> ( thetaIt+1 ) ) ) / 2.0 ) *
343 std::cos ( ( latCO->at(
static_cast<proshade_unsign
> ( phiIt ) ) + latCO->at(
static_cast<proshade_unsign
> ( phiIt+1 ) ) ) / 2.0 );
344 *z = this->sphereRadius * std::sin ( ( latCO->at(
static_cast<proshade_unsign
> ( phiIt ) ) + latCO->at(
static_cast<proshade_unsign
> ( phiIt+1 ) ) ) / 2.0 );
368 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 )
371 *xBottom =
static_cast< proshade_signed
> ( std::floor ( ( x /
static_cast< proshade_double
> ( this->xDimSampling ) ) ) + (
static_cast< proshade_double
> ( xDimMax ) / 2.0 ) );
372 *yBottom =
static_cast< proshade_signed
> ( std::floor ( ( y /
static_cast< proshade_double
> ( this->yDimSampling ) ) ) + (
static_cast< proshade_double
> ( yDimMax ) / 2.0 ) );
373 *zBottom =
static_cast< proshade_signed
> ( std::floor ( ( z /
static_cast< proshade_double
> ( this->zDimSampling ) ) ) + (
static_cast< proshade_double
> ( zDimMax ) / 2.0 ) );
375 *xTop = *xBottom + 1;
376 *yTop = *yBottom + 1;
377 *zTop = *zBottom + 1;
394 return ( this->localBandwidth );
407 return ( this->localAngRes );
420 return ( this->mappedData );
443 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 )
446 c00->at(0) = (
static_cast< proshade_double
> ( this->xDimSampling ) * xd ) + c000.at(0);
447 c00->at(1) = c000.at(1);
448 c00->at(2) = c000.at(2);
449 c00->at(3) = ( c000.at(3) * ( 1.0 - xd ) ) + ( c100.at(3) * xd );
452 c01->at(0) = (
static_cast< proshade_double
> ( this->xDimSampling ) * xd ) + c001.at(0);
453 c01->at(1) = c001.at(1);
454 c01->at(2) = c001.at(2);
455 c01->at(3) = ( c001.at(3) * ( 1.0 - xd ) ) + ( c101.at(3) * xd );
458 c10->at(0) = (
static_cast< proshade_double
> ( this->xDimSampling ) * xd ) + c010.at(0);
459 c10->at(1) = c010.at(1);
460 c10->at(2) = c010.at(2);
461 c10->at(3) = ( c010.at(3) * ( 1.0 - xd ) ) + ( c110.at(3) * xd );
464 c11->at(0) = (
static_cast< proshade_double
> ( this->xDimSampling ) * xd ) + c011.at(0);
465 c11->at(1) = c011.at(1);
466 c11->at(2) = c011.at(2);
467 c11->at(3) = ( c011.at(3) * ( 1.0 - xd ) ) + ( c111.at(3) * xd );
492 c0->at(0) = c00.at(0);
493 c0->at(1) = (
static_cast< proshade_double
> ( this->yDimSampling ) * yd ) + c00.at(1);
494 c0->at(2) = c00.at(2);
495 c0->at(3) = ( c00.at(3) * ( 1.0 - yd ) ) + ( c10.at(3) * yd );
498 c1->at(0) = c01.at(0);
499 c1->at(1) = (
static_cast< proshade_double
> ( this->yDimSampling ) * yd ) + c01.at(1);
500 c1->at(2) = c01.at(2);
501 c1->at(3) = ( c01.at(3) * ( 1.0 - yd ) ) + ( c11.at(3) * yd );
519 if (
static_cast<proshade_unsign
> ( std::ceil ( circumference / 2 ) ) % 2 == 0 )
521 return (
static_cast<proshade_unsign
> ( std::ceil ( circumference / 2 ) ) );
525 return (
static_cast<proshade_unsign
> ( std::ceil ( circumference / 2 ) ) + 1 );
541 proshade_single ret = resolution / 2.0f;
544 while ( std::floor ( maxMapRange / ret ) < 10 )
565 proshade_double sphereDistanceAsFractionOfTotal =
static_cast<proshade_double
> ( sphereDist / ( maxMapRange / 2.0f ) );
566 proshade_unsign ret = 0;
569 for ( proshade_unsign iter = 2; iter < static_cast<proshade_unsign> ( 10000 ); iter++ )
571 if ( ProSHADE_internal_precomputedVals::glIntMaxDists[iter] >= sphereDistanceAsFractionOfTotal )
578 if ( ret < 5 ) { ret = 5; }
594 return ( this->sphereRadius );
603 this->mappedDataRot =
nullptr;
604 this->mappedDataRot =
new proshade_double[this->localAngRes * this->localAngRes];
620 this->mappedDataRot[pos] = value;
634 return ( this->mappedDataRot[pos] );
654 this->angularDim = dim;
655 this->rotFunDim = rfDim;
656 this->radiusMin = this->radius - ( radRange / 2.0 );
657 this->radiusMax = this->radius + ( radRange / 2.0 );
658 this->representedAngle = repAng;
659 this->sphereNumber = sphNo;
662 this->axesValues =
new proshade_double[dim*dim];
666 for ( proshade_unsign iter = 0; iter < ( dim * dim ); iter++ ) { this->axesValues[iter] = 0.0; }
677 if ( this->axesValues !=
nullptr )
679 delete[] this->axesValues;
690 return ( this->radius );
700 return ( this->radiusMax );
711 return ( this->rotFunDim );
722 return ( this->angularDim );
733 return ( this->radiusMin );
744 return ( this->representedAngle );
755 return ( this->sphereNumber );
766 return ( this->peaks );
782 proshade_double lonSampling = ( M_PI ) /
static_cast< proshade_double
> ( this->angularDim );
783 proshade_double latSampling = ( M_PI * 2.0 ) /
static_cast< proshade_double
> ( this->angularDim );
785 proshade_double lat, lon, cX, cY, cZ, c000, c001, c010, c011, c100, c101, c110, c111, c00, c01, c10, c11, c0, c1, xRelative, yRelative, zRelative, eulerAlpha, eulerBeta, eulerGamma, mapX, mapY, mapZ;
786 proshade_signed xBottom, xTop, yBottom, yTop, zBottom, zTop, mapIndex;
789 for ( proshade_signed lonIt = 0; lonIt < static_cast<proshade_signed> ( this->angularDim ); lonIt++ )
791 for ( proshade_signed latIt = 0; latIt < static_cast<proshade_signed> ( this->angularDim ); latIt++ )
794 lon =
static_cast<proshade_double
> ( lonIt ) * lonSampling;
795 lat =
static_cast<proshade_double
> ( latIt ) * latSampling;
796 cX = 1.0 * std::sin ( lon ) * std::cos ( lat );
797 cY = 1.0 * std::sin ( lon ) * std::sin ( lat );
798 cZ = 1.0 * std::cos ( lon );
807 xBottom =
static_cast< proshade_signed
> ( std::floor ( mapX ) );
if ( xBottom < 0 ) { xBottom = 0; }
if ( xBottom >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { xBottom =
static_cast<proshade_signed
> ( this->rotFunDim - 2 ); }
808 yBottom =
static_cast< proshade_signed
> ( std::floor ( mapY ) );
if ( yBottom < 0 ) { yBottom = 0; }
if ( yBottom >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { yBottom =
static_cast<proshade_signed
> ( this->rotFunDim - 2 ); }
809 zBottom =
static_cast< proshade_signed
> ( std::floor ( mapZ ) );
if ( zBottom < 0 ) { zBottom = 0; }
if ( zBottom >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { zBottom =
static_cast<proshade_signed
> ( this->rotFunDim - 2 ); }
810 xTop =
static_cast< proshade_signed
> ( std::ceil ( mapX ) );
if ( xTop < 1 ) { xTop = 1; }
if ( xTop >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { xTop =
static_cast<proshade_signed
> ( this->rotFunDim - 1 ); }
811 yTop =
static_cast< proshade_signed
> ( std::ceil ( mapY ) );
if ( yTop < 1 ) { yTop = 1; }
if ( yTop >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { yTop =
static_cast<proshade_signed
> ( this->rotFunDim - 1 ); }
812 zTop =
static_cast< proshade_signed
> ( std::ceil ( mapZ ) );
if ( zTop < 1 ) { zTop = 1; }
if ( zTop >=
static_cast< proshade_signed
> ( this->rotFunDim ) ) { zTop =
static_cast<proshade_signed
> ( this->rotFunDim - 1 ); }
815 mapIndex = zBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * xBottom );
816 c000 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
819 mapIndex = zTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * xBottom );
820 c001 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
823 mapIndex = zBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * xBottom );
824 c010 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
827 mapIndex = zTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * xBottom );
828 c011 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
831 mapIndex = zBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * xTop );
832 c100 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
835 mapIndex = zTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * xTop );
836 c101 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
839 mapIndex = zBottom +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * xTop );
840 c110 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
843 mapIndex = zTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * ( yTop +
static_cast< proshade_signed
> ( this->rotFunDim ) * xTop );
844 c111 = pow( rotFun[mapIndex][0], 2.0 ) + pow( rotFun[mapIndex][1], 2.0 );
847 xRelative = mapX - std::floor( mapX );
848 c00 = ( c000 * ( 1.0 - xRelative ) ) + ( c100 * xRelative );
849 c01 = ( c001 * ( 1.0 - xRelative ) ) + ( c101 * xRelative );
850 c10 = ( c010 * ( 1.0 - xRelative ) ) + ( c110 * xRelative );
851 c11 = ( c011 * ( 1.0 - xRelative ) ) + ( c111 * xRelative );
854 yRelative = mapY - std::floor( mapY );
855 c0 = ( c00 * ( 1.0 - yRelative ) ) + ( c10 * yRelative );
856 c1 = ( c01 * ( 1.0 - yRelative ) ) + ( c11 * yRelative );
859 zRelative = mapZ - std::floor( mapZ );
862 mapIndex = lonIt + ( latIt *
static_cast< proshade_signed
> ( this->angularDim ) );
863 this->axesValues[mapIndex] = ( c0 * ( 1.0 - zRelative ) ) + ( c1 * zRelative );
880 return ( this->axesValues[longitude + ( lattitude *
static_cast<proshade_unsign
> ( this->angularDim ) )] );
894 proshade_double c00, c01, c10, c11, c0, c1, latRelative, lonRelative;
895 proshade_signed latTop, latBottom, lonTop, lonBottom, gridIndex;
898 latBottom =
static_cast< proshade_signed
> ( std::floor ( lattitude ) );
if ( latBottom < 0 ) { latBottom += this->angularDim; }
if ( latBottom >=
static_cast<proshade_signed
> ( this->angularDim ) ) { latBottom -= this->angularDim; }
899 lonBottom =
static_cast< proshade_signed
> ( std::floor ( longitude ) );
if ( lonBottom < 0 ) { lonBottom += this->angularDim; }
if ( lonBottom >=
static_cast<proshade_signed
> ( this->angularDim ) ) { lonBottom -= this->angularDim; }
900 latTop =
static_cast< proshade_signed
> ( std::ceil ( lattitude ) );
if ( latTop < 0 ) { latTop += this->angularDim; }
if ( latTop >=
static_cast<proshade_signed
> ( this->angularDim ) ) { latTop -= this->angularDim; }
901 lonTop =
static_cast< proshade_signed
> ( std::ceil ( longitude ) );
if ( lonTop < 0 ) { lonTop += this->angularDim; }
if ( lonTop >=
static_cast<proshade_signed
> ( this->angularDim ) ) { lonTop -= this->angularDim; }
904 gridIndex = lonBottom + ( latBottom *
static_cast< proshade_signed
> ( this->angularDim ) );
905 c00 = this->axesValues[gridIndex];
907 gridIndex = lonBottom + ( latTop *
static_cast< proshade_signed
> ( this->angularDim ) );
908 c01 = this->axesValues[gridIndex];
910 gridIndex = lonTop + ( latBottom *
static_cast< proshade_signed
> ( this->angularDim ) );
911 c10 = this->axesValues[gridIndex];
913 gridIndex = lonTop + ( latTop *
static_cast< proshade_signed
> ( this->angularDim ) );
914 c11 = this->axesValues[gridIndex];
917 lonRelative = longitude - std::floor( longitude );
918 c0 = ( c00 * ( 1.0 - lonRelative ) ) + ( c10 * lonRelative );
919 c1 = ( c01 * ( 1.0 - lonRelative ) ) + ( c11 * lonRelative );
922 latRelative = lattitude - std::floor ( lattitude );
923 proshade_double res = ( c0 * ( 1.0 - latRelative ) ) + ( c1 * latRelative );
939 std::vector< std::vector< proshade_double > > ret ( this->angularDim );
940 std::vector< proshade_double > retHlp ( this->angularDim, 0.0 );
943 for (
size_t lonIt = 0; lonIt < this->angularDim; lonIt++ )
945 for (
size_t latIt = 0; latIt < this->angularDim; latIt++ )
947 retHlp.at(latIt) = this->getSphereLatLonPosition (
static_cast< proshade_unsign
> ( latIt ),
static_cast< proshade_unsign
> ( lonIt ) );
950 ret.at(lonIt) = retHlp;
968 proshade_double currentHeight;
969 proshade_signed nbLat, nbLon;
973 for ( proshade_signed latIt = 0; latIt < static_cast<proshade_signed> ( this->angularDim ); latIt++ )
975 for ( proshade_signed lonIt = 0; lonIt < static_cast<proshade_signed> ( this->angularDim ); lonIt++ )
978 currentHeight = this->getSphereLatLonPosition (
static_cast< proshade_unsign
> ( latIt ),
static_cast< proshade_unsign
> ( lonIt ) );
982 for ( proshade_signed latRound = -noSmNeighbours; latRound <= noSmNeighbours; latRound++ )
984 for ( proshade_signed lonRound = -noSmNeighbours; lonRound <= noSmNeighbours; lonRound++ )
987 if ( latRound == 0 && lonRound == 0 ) {
continue; }
990 nbLat = latIt + latRound;
991 nbLon = lonIt + lonRound;
992 if ( nbLat < 0 ) { nbLat += this->angularDim; }
if ( nbLat >=
static_cast<proshade_signed
> ( this->angularDim ) ) { nbLat -= this->angularDim; }
993 if ( nbLon < 0 ) {
continue; }
if ( nbLon >=
static_cast<proshade_signed
> ( this->angularDim ) ) {
continue; }
996 if ( this->getSphereLatLonPosition (
static_cast< proshade_unsign
> ( nbLat ),
static_cast< proshade_unsign
> ( nbLon ) ) > currentHeight ) { isPeak =
false;
break; }
999 if ( !isPeak ) {
break; }
1005 this->peaks.emplace_back ( std::pair<proshade_unsign,proshade_unsign> ( latIt, lonIt ) );
1030 proshade_double curHeight;
1031 std::vector< proshade_unsign > dels ( 0,
static_cast< proshade_unsign
> ( this->peaks.size() ) );
1034 for ( proshade_unsign peakIt = 0; peakIt < static_cast<proshade_unsign> ( this->peaks.size() ); peakIt++ )
1037 curHeight = this->getSphereLatLonPosition ( this->peaks.at(peakIt).first, this->peaks.at(peakIt).second );
1040 if ( curHeight < peakThres )
1047 std::sort ( dels.begin(), dels.end(), std::greater <proshade_unsign>() );
1050 for ( proshade_unsign delIt = 0; delIt < static_cast< proshade_unsign > ( dels.size() ); delIt++ )
1052 this->peaks.erase ( this->peaks.begin() +
static_cast< long int > ( dels.at(delIt) ) );
1073 this->dimension = angDim;
1074 this->lonSampling = ( M_PI ) /
static_cast<proshade_double
> ( this->dimension );
1075 this->latSampling = ( M_PI * 2.0 ) /
static_cast<proshade_double
> ( this->dimension );
1078 this->latFrom =
static_cast<proshade_double
> ( lat ) * this->latSampling;
1079 this->latTo =
static_cast<proshade_double
> ( lat ) * this->latSampling;
1080 this->lonFrom =
static_cast<proshade_double
> ( lon ) * this->lonSampling;
1081 this->lonTo =
static_cast<proshade_double
> ( lon ) * this->lonSampling;
1082 this->latFromInds = lat;
1083 this->latToInds = lat;
1084 this->lonFromInds = lon;
1085 this->lonToInds = lon;
1089 this->latMinLonMinXYZ =
new proshade_double[3];
1090 this->latMaxLonMinXYZ =
new proshade_double[3];
1091 this->latMinLonMaxXYZ =
new proshade_double[3];
1092 this->latMaxLonMaxXYZ =
new proshade_double[3];
1099 this->computeCornerPositions ( );
1112 delete[] this->latMinLonMinXYZ;
1113 delete[] this->latMaxLonMinXYZ;
1114 delete[] this->latMinLonMaxXYZ;
1115 delete[] this->latMaxLonMaxXYZ;
1123 this->latMinLonMinXYZ[0] = 1.0 * std::sin ( this->lonFrom ) * std::cos ( this->latFrom );
1124 this->latMinLonMinXYZ[1] = 1.0 * std::sin ( this->lonFrom ) * std::sin ( this->latFrom );
1125 this->latMinLonMinXYZ[2] = 1.0 * std::cos ( this->lonFrom );
1127 this->latMaxLonMinXYZ[0] = 1.0 * std::sin ( this->lonFrom ) * std::cos ( this->latTo );
1128 this->latMaxLonMinXYZ[1] = 1.0 * std::sin ( this->lonFrom ) * std::sin ( this->latTo );
1129 this->latMaxLonMinXYZ[2] = 1.0 * std::cos ( this->lonFrom );
1131 this->latMinLonMaxXYZ[0] = 1.0 * std::sin ( this->lonTo ) * std::cos ( this->latFrom );
1132 this->latMinLonMaxXYZ[1] = 1.0 * std::sin ( this->lonTo ) * std::sin ( this->latFrom );
1133 this->latMinLonMaxXYZ[2] = 1.0 * std::cos ( this->lonTo );
1135 this->latMaxLonMaxXYZ[0] = 1.0 * std::sin ( this->lonTo ) * std::cos ( this->latTo );
1136 this->latMaxLonMaxXYZ[1] = 1.0 * std::sin ( this->lonTo ) * std::sin ( this->latTo );
1137 this->latMaxLonMaxXYZ[2] = 1.0 * std::cos ( this->lonTo );
1153 proshade_signed smallerAngul = newAngul -
static_cast< proshade_signed
> ( this->dimension );
1154 proshade_signed largerAngul = newAngul +
static_cast< proshade_signed
> ( this->dimension );
1157 proshade_signed ret = std::min ( std::abs ( currentAngul - newAngul ), std::min ( std::abs ( currentAngul - smallerAngul ), std::abs ( currentAngul - largerAngul ) ) );
1183 bool peakAdded =
false;
1184 std::stringstream hlpSS;
1185 std::stringstream hlpSS2;
1188 proshade_double xPos = 1.0 * std::sin ( lon * this->lonSampling ) * std::cos ( lat * this->latSampling );
1189 proshade_double yPos = 1.0 * std::sin ( lon * this->lonSampling ) * std::sin ( lat * this->latSampling );
1190 proshade_double zPos = 1.0 * std::cos ( lon * this->lonSampling );
1191 hlpSS2 <<
"Peak " << xPos <<
" ; " << yPos <<
" ; " << zPos <<
" is close enough to group with corner ";
1194 if (
ProSHADE_internal_maths::vectorOrientationSimilaritySameDirection ( xPos, yPos, zPos, this->latMaxLonMinXYZ[0], this->latMaxLonMinXYZ[1], this->latMaxLonMinXYZ[2], cosTol ) && !peakAdded ) { peakAdded =
true; hlpSS2 << this->latMaxLonMinXYZ[0] <<
" ; " << this->latMaxLonMinXYZ[1] <<
" ; " << this->latMaxLonMinXYZ[2]; }
1195 if (
ProSHADE_internal_maths::vectorOrientationSimilaritySameDirection ( xPos, yPos, zPos, this->latMinLonMaxXYZ[0], this->latMinLonMaxXYZ[1], this->latMinLonMaxXYZ[2], cosTol ) && !peakAdded ) { peakAdded =
true; hlpSS2 << this->latMinLonMaxXYZ[0] <<
" ; " << this->latMinLonMaxXYZ[1] <<
" ; " << this->latMinLonMaxXYZ[2]; }
1196 if (
ProSHADE_internal_maths::vectorOrientationSimilaritySameDirection ( xPos, yPos, zPos, this->latMaxLonMaxXYZ[0], this->latMaxLonMaxXYZ[1], this->latMaxLonMaxXYZ[2], cosTol ) && !peakAdded ) { peakAdded =
true; hlpSS2 << this->latMaxLonMaxXYZ[0] <<
" ; " << this->latMaxLonMaxXYZ[1] <<
" ; " << this->latMaxLonMaxXYZ[2]; }
1201 proshade_double lenPos = std::sqrt ( std::pow ( xPos, 2.0 ) + std::pow ( yPos, 2.0 ) + std::pow( zPos, 2.0 ) );
1202 proshade_double minMinPos = std::sqrt ( std::pow ( this->latMinLonMinXYZ[0], 2.0 ) + std::pow ( this->latMinLonMinXYZ[1], 2.0 ) + std::pow( this->latMinLonMinXYZ[2], 2.0 ) );
1203 proshade_double minMaxPos = std::sqrt ( std::pow ( this->latMinLonMaxXYZ[0], 2.0 ) + std::pow ( this->latMinLonMaxXYZ[1], 2.0 ) + std::pow( this->latMinLonMaxXYZ[2], 2.0 ) );
1204 proshade_double maxMinPos = std::sqrt ( std::pow ( this->latMaxLonMinXYZ[0], 2.0 ) + std::pow ( this->latMaxLonMinXYZ[1], 2.0 ) + std::pow( this->latMaxLonMinXYZ[2], 2.0 ) );
1205 proshade_double maxMaxPos = std::sqrt ( std::pow ( this->latMaxLonMaxXYZ[0], 2.0 ) + std::pow ( this->latMaxLonMaxXYZ[1], 2.0 ) + std::pow( this->latMaxLonMaxXYZ[2], 2.0 ) );
1207 if ( ( std::acos ( ( xPos * this->latMinLonMinXYZ[0] + yPos * this->latMinLonMinXYZ[1] + zPos * this->latMinLonMinXYZ[2] ) / ( lenPos * minMinPos ) ) > allowedAngle ) ||
1208 ( std::acos ( ( xPos * this->latMinLonMaxXYZ[0] + yPos * this->latMinLonMaxXYZ[1] + zPos * this->latMinLonMaxXYZ[2] ) / ( lenPos * minMaxPos ) ) > allowedAngle ) ||
1209 ( std::acos ( ( xPos * this->latMaxLonMinXYZ[0] + yPos * this->latMaxLonMinXYZ[1] + zPos * this->latMaxLonMinXYZ[2] ) / ( lenPos * maxMinPos ) ) > allowedAngle ) ||
1210 ( std::acos ( ( xPos * this->latMaxLonMaxXYZ[0] + yPos * this->latMaxLonMaxXYZ[1] + zPos * this->latMaxLonMaxXYZ[2] ) / ( lenPos * maxMaxPos ) ) > allowedAngle ) )
1220 hlpSS <<
"Peak group dimensions changed from LAT " << this->latFromInds <<
" - " << this->latToInds <<
" and LON " << this->lonFromInds <<
" - " << this->lonToInds <<
" to ";
1224 proshade_signed largerCorner, smallerCorner;
1225 bool latCornersDone =
false;
1226 bool lonCornersDone =
false;
1229 if ( ( this->latFromInds <= this->latToInds ) && !( ( lat >= this->latFromInds ) && ( lat <= this->latToInds ) ) )
1232 smallerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lat ),
static_cast< proshade_signed
> ( this->latFromInds ) );
1233 largerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lat ),
static_cast< proshade_signed
> ( this->latToInds ) );
1235 if ( smallerCorner < largerCorner )
1237 this->latFromInds = lat;
1238 latCornersDone =
true;
1240 if ( smallerCorner > largerCorner )
1242 this->latToInds = lat;
1243 latCornersDone =
true;
1245 if ( smallerCorner == largerCorner )
1247 if ( lat < this->latFromInds ) { this->latFromInds = lat; latCornersDone =
true; }
1248 else if ( lat > this->latToInds ) { this->latToInds = lat; latCornersDone =
true; }
1252 if ( ( this->latFromInds > this->latToInds ) && !( ( lat >= this->latFromInds ) || ( lat <= this->latToInds ) ) )
1255 smallerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lat ),
static_cast< proshade_signed
> ( this->latFromInds ) );
1256 largerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lat ),
static_cast< proshade_signed
> ( this->latToInds ) );
1258 if ( smallerCorner < largerCorner )
1260 this->latFromInds = lat;
1261 latCornersDone =
true;
1263 if ( smallerCorner > largerCorner )
1265 this->latToInds = lat;
1266 latCornersDone =
true;
1268 if ( smallerCorner == largerCorner )
1270 if ( lat < this->latFromInds ) { this->latFromInds = lat; latCornersDone =
true; }
1271 else if ( lat > this->latToInds ) { this->latToInds = lat; latCornersDone =
true; }
1277 if ( ( this->lonFromInds <= this->lonToInds ) && !( ( lon >= this->lonFromInds ) && ( lon <= this->lonToInds ) ) )
1280 smallerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lon ),
static_cast< proshade_signed
> ( this->lonFromInds ) );
1281 largerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lon ),
static_cast< proshade_signed
> ( this->lonToInds ) );
1283 if ( smallerCorner < largerCorner )
1285 this->lonFromInds = lon;
1286 lonCornersDone =
true;
1288 if ( smallerCorner > largerCorner )
1290 this->lonToInds = lon;
1291 lonCornersDone =
true;
1293 if ( smallerCorner == largerCorner )
1295 if ( lon < this->lonFromInds ) { this->lonFromInds = lon; lonCornersDone =
true; }
1296 else if ( lon > this->lonToInds ) { this->lonToInds = lon; lonCornersDone =
true; }
1300 if ( ( this->lonFromInds > this->lonToInds ) && !( ( lon >= this->lonFromInds ) || ( lon <= this->lonToInds ) ) )
1303 smallerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lon ),
static_cast< proshade_signed
> ( this->lonFromInds ) );
1304 largerCorner = angularDistanceWithBorders (
static_cast< proshade_signed
> ( lon ),
static_cast< proshade_signed
> ( this->lonToInds ) );
1306 if ( smallerCorner < largerCorner )
1308 this->lonFromInds = lon;
1309 lonCornersDone =
true;
1311 if ( smallerCorner > largerCorner )
1313 this->lonToInds = lon;
1314 lonCornersDone =
true;
1316 if ( smallerCorner == largerCorner )
1318 if ( lon < this->lonFromInds ) { this->lonFromInds = lon; lonCornersDone =
true; }
1319 else if ( lon > this->lonToInds ) { this->lonToInds = lon; lonCornersDone =
true; }
1324 if ( latCornersDone )
1326 this->latFrom =
static_cast<proshade_double
> ( this->latFromInds ) * this->latSampling;
1327 this->latTo =
static_cast<proshade_double
> ( this->latToInds ) * this->latSampling;
1330 if ( lonCornersDone )
1332 this->lonFrom =
static_cast<proshade_double
> ( this->lonFromInds ) * this->lonSampling;
1333 this->lonTo =
static_cast<proshade_double
> ( this->lonToInds ) * this->lonSampling;
1337 this->computeCornerPositions ( );
1338 hlpSS <<
"LAT " << this->latFromInds <<
" - " << this->latToInds <<
" and LON " << this->lonFromInds <<
" - " << this->lonToInds <<
" ( peak position LAT " << lat <<
" LON " << lon <<
" )";
1342 bool isSphereNew =
true;
1343 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( this->spherePositions.size() ); iter++ ) {
if ( this->spherePositions.at(iter) == sphPos ) { isSphereNew =
false; } }
1348 return ( peakAdded );
1359 return ( this->latFromInds );
1370 return ( this->latToInds );
1381 return ( this->lonFromInds );
1392 return ( this->lonToInds );
1403 return ( this->spherePositions );
1430 proshade_double bestPosVal, bestLatInd, bestLonInd;
1431 std::vector< proshade_unsign > spheresFormingFold;
1434 for ( proshade_unsign shIt = 0; shIt < static_cast<proshade_unsign> ( sphereVals.size() ); shIt++ )
1440 this->getBestIndexForFold ( &bestPosVal, &bestLatInd, &bestLonInd, &spheresFormingFold, sphereVals );
1443 if ( bicubicInterp )
1449 proshade_double* detectedSymmetry =
new proshade_double[7];
1452 detectedSymmetry[0] =
static_cast<proshade_double
> ( fold );
1453 detectedSymmetry[1] = 1.0 * std::sin ( bestLonInd * this->lonSampling ) * std::cos ( bestLatInd * this->latSampling );
1454 detectedSymmetry[2] = 1.0 * std::sin ( bestLonInd * this->lonSampling ) * std::sin ( bestLatInd * this->latSampling );
1455 detectedSymmetry[3] = 1.0 * std::cos ( bestLonInd * this->lonSampling );
1456 detectedSymmetry[4] = ( 2.0 * M_PI ) / detectedSymmetry[0];
1457 detectedSymmetry[5] = std::min ( ( bestPosVal - 1.0 ) / ( detectedSymmetry[0] - 1 ), 1.0 );
1458 detectedSymmetry[6] = -std::numeric_limits < proshade_double >::infinity();
1461 const FloatingPoint< proshade_double > lhs1 ( std::max ( std::abs ( detectedSymmetry[1] ), std::max ( std::abs ( detectedSymmetry[2] ), std::abs ( detectedSymmetry[3] ) ) ) );
1462 const FloatingPoint< proshade_double > rhs1 ( std::abs ( detectedSymmetry[1] ) );
1463 const FloatingPoint< proshade_double > rhs2 ( std::abs ( detectedSymmetry[2] ) );
1464 const FloatingPoint< proshade_double > rhs3 ( std::abs ( detectedSymmetry[3] ) );
1465 if ( ( lhs1.AlmostEquals ( rhs1 ) && ( detectedSymmetry[1] < 0.0 ) ) ||
1466 ( lhs1.AlmostEquals ( rhs2 ) && ( detectedSymmetry[2] < 0.0 ) ) ||
1467 ( lhs1.AlmostEquals ( rhs3 ) && ( detectedSymmetry[3] < 0.0 ) ) )
1469 detectedSymmetry[1] *= -1.0;
1470 detectedSymmetry[2] *= -1.0;
1471 detectedSymmetry[3] *= -1.0;
1472 detectedSymmetry[4] *= -1.0;
1476 const FloatingPoint< proshade_double > llhs1 ( detectedSymmetry[1] ), llhs2 ( detectedSymmetry[2] ), llhs3 ( detectedSymmetry[3] ), rrhs1 ( 0.0 );
1477 if ( llhs1.AlmostEquals ( rrhs1 ) ) { detectedSymmetry[1] = 0.0; }
1478 if ( llhs2.AlmostEquals ( rrhs1 ) ) { detectedSymmetry[2] = 0.0; }
1479 if ( llhs3.AlmostEquals ( rrhs1 ) ) { detectedSymmetry[3] = 0.0; }
1485 std::stringstream hlpSS;
1486 hlpSS <<
"Detected group with fold " << detectedSymmetry[0] <<
" along axis " << detectedSymmetry[1] <<
" ; " << detectedSymmetry[2] <<
" ; " << detectedSymmetry[3] <<
" and with peak height " << detectedSymmetry[5];
1502 std::vector< proshade_double > angs;
1505 for ( proshade_unsign shPos = 0; shPos < static_cast<proshade_unsign> ( this->spherePositions.size() ); shPos++ )
1511 for ( proshade_unsign ang1It = 0; ang1It < static_cast<proshade_unsign> ( angs.size() ); ang1It++ )
1513 for ( proshade_unsign ang2It = 1; ang2It < static_cast<proshade_unsign> ( angs.size() ); ang2It++ )
1516 if ( ang1It >= ang2It ) {
continue; }
1524 std::sort ( (*angDiffs).begin(), (*angDiffs).end() );
1525 (*angDiffs).erase ( std::unique ( (*angDiffs).begin(), (*angDiffs).end() ), (*angDiffs).end() );
1544 proshade_double divRem, divBasis, symmErr, angTolerance, angToleranceNext;
1545 proshade_double peakErr = ( M_PI * 2.0 ) / (
static_cast<proshade_double
> ( this->dimension ) );
1548 for ( proshade_unsign diffIt = 0; diffIt < static_cast<proshade_unsign> ( angDiffs->size() ); diffIt++ )
1551 divRem = std::modf (
static_cast<proshade_double
> ( ( 2.0 * M_PI ) / std::abs ( angDiffs->at(diffIt) ) ), &divBasis );
1561 const FloatingPoint< proshade_double > lhs1 ( divBasis ), rhs1 ( 1.0 );
1562 if ( lhs1.AlmostEquals ( rhs1 ) ) {
continue; }
1565 if (
static_cast< proshade_double
> ( this->spherePositions.size() ) < ( divBasis - 1.0 ) ) {
continue; }
1568 symmErr = divRem * ( ( 2.0 * M_PI ) /
static_cast<proshade_double
> ( divBasis ) );
1569 angTolerance = std::abs( symmErr / peakErr );
1570 angToleranceNext = ( ( ( 2.0 * M_PI ) /
static_cast<proshade_double
> ( divBasis ) ) - ( ( 2.0 * M_PI ) /
static_cast<proshade_double
> ( divBasis + 1 ) ) ) / peakErr;
1573 if ( angTolerance < std::max ( 3.0, ( 0.1 / peakErr ) ) )
1576 if ( angToleranceNext < std::max ( 1.5, ( 0.1 / peakErr ) ) )
1589 std::sort ( (*foldsToTry).begin(), (*foldsToTry).end(), std::greater <proshade_unsign>() );
1590 foldsToTry->erase ( std::unique ( (*foldsToTry).begin(), (*foldsToTry).end() ), (*foldsToTry).end() );
1607 proshade_double soughtAngle, minSphereVal;
1608 proshade_unsign minSpherePos = 0;
1611 for ( proshade_double fIt = 1.0; fIt < static_cast<proshade_double> ( foldToTry ); fIt += 1.0 )
1614 minSphereVal = 999.9;
1615 soughtAngle = fIt * ( 2.0 * M_PI /
static_cast<proshade_double
> ( foldToTry ) );
1618 for ( proshade_unsign angsIt = 0; angsIt < static_cast<proshade_unsign> ( this->spherePositions.size() ); angsIt++ )
1620 if ( std::abs ( sphereVals.at(this->spherePositions.at(angsIt))->getRepresentedAngle() - soughtAngle ) < sphereAngleTolerance )
1622 if ( minSphereVal > 1.0 - std::cos ( std::abs ( sphereVals.at(this->spherePositions.at(angsIt))->getRepresentedAngle() - soughtAngle ) ) )
1624 minSphereVal = 1.0 - std::cos ( std::abs ( sphereVals.at(this->spherePositions.at(angsIt))->getRepresentedAngle() - soughtAngle ) );
1625 minSpherePos = angsIt;
1631 const FloatingPoint< proshade_double > lhs1 ( minSphereVal ), rhs1 ( 999.9 );
1632 if ( lhs1.AlmostEquals ( rhs1 ) ) {
break; }
1655 proshade_double curPosVal;
1657 if ( this->latFromInds > this->latToInds ) { this->latToInds +=
static_cast< proshade_double
> ( this->dimension ); }
1658 if ( this->lonFromInds > this->lonToInds ) { this->lonToInds +=
static_cast< proshade_double
> ( this->dimension ); }
1661 for ( proshade_unsign latIt =
static_cast< proshade_unsign
> ( this->latFromInds ); latIt <= static_cast< proshade_unsign > ( this->latToInds ); latIt++ )
1664 if ( latIt >= this->dimension ) { latIt -= this->dimension; this->latToInds -=
static_cast< proshade_double
> ( this->dimension ); }
1666 for ( proshade_unsign lonIt =
static_cast< proshade_unsign
> ( this->lonFromInds ); lonIt <= static_cast< proshade_unsign > ( this->lonToInds ); lonIt++ )
1669 if ( lonIt >= this->dimension ) { lonIt -= this->dimension; this->lonToInds -=
static_cast< proshade_double
> ( this->dimension ); }
1675 for ( proshade_unsign sphIt = 0; sphIt < static_cast<proshade_unsign> ( spheresFormingFold->size() ); sphIt++ )
1677 curPosVal += sphereVals.at(spheresFormingFold->at(sphIt))->getSphereLatLonPosition ( latIt, lonIt );
1681 if ( curPosVal > *bestPosVal )
1683 *bestPosVal = curPosVal;
1684 *bestLatInd =
static_cast< proshade_double
> ( latIt );
1685 *bestLonInd =
static_cast< proshade_double
> ( lonIt );