Well I cannot rate whether it is too difficult to fix this. I'm too old :-) and have know overview knowledge about lib's or hugin's sources. I simply follow the approach to narrow a crash down and I wanted to avoid double effort.
I digged some hours in the code and hopefully found the reason for the crash. For Albers Equal Area projection there are some parameter combinations that are prohibited, phi1 = phi1 = 0 and phi1 = -phi2. The later one is not handled correctly. First of all, the calculation of precomputed values does not handle these combinations. I implemented checks and simplyfied the calculation. Additionally the distance calculation does not catch the second combination. I removed the error message because many many dialogs appear. It is better to catch the prohibited combinations directly in Hugin with only one dialog rather than in the lib. Please find attached a patch for review. I tested it on Win32 (MSVC) and no crash occured any more. Comments are highly appreciated, Guido Yuval Levy schrieb: > Guido Kohlmeyer wrote: >>> A simple division by zero error in libpano13: >>> >>> http://sourceforge.net/tracker/?func=detail&aid=2002617&group_id=96188&atid=613954 >>> >> I'm currently working on a fix. Maybe it's not wise to do the same. > > do you mean it is too difficult for a student, or are you worried about > duplicate effort? > > no worries about duplicate efforts. > > for you it is a bug hunt, for the students it is about showing us that > they can hack the code base. There is no requirement for the student > patch to be useful or to be applied to the code base when considering > them for GSoC. > > Yuv > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group. A list of frequently asked questions is available at: http://wiki.panotools.org/Hugin_FAQ To post to this group, send email to hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/hugin-ptx -~----------~----~----~----~------~----~------~--~---
Index: math.c =================================================================== --- math.c (revision 955) +++ math.c (working copy) @@ -1036,7 +1036,12 @@ { //Parameters: phi1, phi2, phi0, n, C, rho0, yoffset - double phi1, phi2, n, C, rho0, phi0, y1, y2, y, twiceN; + double phi1, phi2, n, C, rho0, phi0, y1, y2, y; + double Aux_2N; + double Aux_sin_phi0; /* value of sinus(phi0) */ + double Aux_sin_phi1; /* value of sinus(phi1) */ + double Aux_sin_phi2; /* value of sinus(phi2) */ + double Aux_1; /* auxiliary variables */ double phi[] = {-PI/2, 0, PI/2}; double lambda[] = {-PI, 0, PI}; int i, j, first; @@ -1090,11 +1095,21 @@ // The stability of these operations should be improved phi0 = 0; - twiceN = sin(phi1) + sin(phi2); - n = twiceN /2.0; - C = cos(phi1) * cos(phi1) + 2.0 * n * sin(phi1); - rho0 = sqrt(C - 2.0 * n * sin(phi0)) / n; + // precompute sinus functions + Aux_sin_phi0 = sin(phi0); + Aux_sin_phi1 = sin(phi1); + Aux_sin_phi2 = sin(phi2); + Aux_2N = Aux_sin_phi1 + Aux_sin_phi2; + n = Aux_2N / 2.0; + + // C = cos(phi1) * cos(phi1) + 2.0 * n * sin(phi1); + C = 1.0 + Aux_sin_phi1 * Aux_sin_phi2; + // rho0 = sqrt(C - 2.0 * n * sin(phi0)) / n; + Aux_1 = (C - (Aux_2N * Aux_sin_phi0)); + Aux_1 = ( (Aux_1 > 0) ? (sqrt(Aux_1)) : (0.0) ); + rho0 = ( (n != 0) ? (Aux_1 / n) : (1.7E+308) ); + im->precomputedValue[0] = phi1; im->precomputedValue[1] = phi2; im->precomputedValue[2] = phi0; @@ -1103,8 +1118,8 @@ im->precomputedValue[5] = rho0; im->precomputedValue[6] = y; im->precomputedValue[7] = n*n; - im->precomputedValue[8] = sin(phi1) + sin(phi2); - im->precomputedValue[9] = twiceN; + im->precomputedValue[8] = Aux_2N; + im->precomputedValue[9] = Aux_2N; // printf("Parms phi1 %f phi2 %f pho0 %f, n %f, C %f, rho0 %f, %f\n", // phi1, phi2, phi0, n, C, rho0, y); @@ -1258,13 +1273,14 @@ phi2 = mp->pn->precomputedValue[1]; //lambda where x is a maximum. - if (phi1 == phi2 && - phi1 == 0.0) { + if ( (phi1 == phi2 && phi1 == 0.0) + || (phi1 == -phi2) ) + { // THIS IS A HACK...it needs to further studied // why this when phi1==phi2==0 // this functions return 0 // Avoid approximation error - PrintError("The Albers projection cannot be used for phi1==phi2==0. Use Lambert Cylindrical Equal Area instead"); + // PrintError("The Albers projection cannot be used for phi1==phi2==0. Use Lambert Cylindrical Equal Area instead"); *x_src = PI; return 0;