--- parser.c 2006-04-21 19:40:42.000000000 +0100 +++ parser.c.new 2006-05-09 22:41:54.000000000 +0100 @@ -88,6 +88,15 @@ #define LINE_LENGTH 65536 +// To determine if the x-coordinate of one control point of a CP pair is e.g. at -179 deg. and the other' +// x-coordinate is at +179 deg. we need to define an overlapping seam on the left and right sides of the +// pano where this is allowed. +// If both control points fall into different regions there is a special treatment in WriteResults(...) +// because otherwise the resulting points (e.g. used for morph to fit) would be located at the median +// value, which is 0 deg. +// This is not the best solution but it works. +#define SEAM_OVERLAP_FRACTION 4 + // Optimizer Script parser; fill global info structure int ParseScript( char* script, AlignInfo *gl ) @@ -799,6 +808,9 @@ { sprintf( line, "# Control Point No %d: %g\n", i , sqrt ( ds(i)) );strcat( res, line ); } + double allowedLeftSeamOverlap = g->pano.width / SEAM_OVERLAP_FRACTION; + double allowedRightSeamOverlap = g->pano.width - ( g->pano.width / SEAM_OVERLAP_FRACTION ); + // Print optimum positions for points in panorama for( i=0; inumPts; i++ ) { @@ -812,7 +824,17 @@ if( x[0] >= 0.0 && x[0] < g->pano.width && x[1] >= 0.0 && x[1] < g->pano.width && y[0] >= 0.0 && y[0] < g->pano.height && y[1] >= 0.0 && y[1] < g->pano.height) { - xd = (x[0]+x[1]) / 2.0; + // special treatment for points where x[0] is on one side of the pano and x[1] on the other one + // => don't use their median value as xd! + // => todo: adapt the width of the overlapping region to y-coordinate (zenith/nadir: larger, middle smaller) + if ( g->pano.hfov==360.0 && ( ( ( x[0] < allowedLeftSeamOverlap ) && ( x[1] > allowedRightSeamOverlap ) ) || + ( ( x[1] < allowedLeftSeamOverlap ) && ( x[0] > allowedRightSeamOverlap ) ) ) ) + xd = ( x[0] + x[1] + g->pano.width ) / 2.0; + else + xd = ( x[0] + x[1] ) / 2.0; + while ( xd >= g->pano.width ) + xd -= g->pano.width; + yd = (y[0]+y[1]) / 2.0; sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[0] , x[0], y[0], xd, yd );strcat( res, line ); sprintf( line, "C i%d x%g y%g X%g Y%g\n", g->cpt[i].num[1] , x[1], y[1], xd, yd );strcat( res, line );