From 3e39224bdd65b8a49de44f007add854dc626a209 Mon Sep 17 00:00:00 2001 From: ultramn Date: Thu, 9 Mar 2017 17:35:53 -0800 Subject: Added loop to try all z values --- dave/AffineSolve.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 5 deletions(-) (limited to 'dave') diff --git a/dave/AffineSolve.c b/dave/AffineSolve.c index f29e29e..1c1d0f1 100644 --- a/dave/AffineSolve.c +++ b/dave/AffineSolve.c @@ -206,8 +206,8 @@ printf("fhat %f %f (len %f)\n", fhat[0][0], fhat[1][0], fhat_len); printf("uhat %f %f (len %f)\n", uhat[0][0], uhat[1][0], uhat_len); printf("rhat %f %f (len %f)\n", rhat[0][0], rhat[1][0], rhat_len); */ - FLOAT ydist1 = 1.0 / uhat_len; //0.25*PI / uhat_len; - FLOAT ydist2 = 1.0 / rhat_len; //0.25*PI / rhat_len; +// FLOAT ydist1 = 1.0 / uhat_len; //0.25*PI / uhat_len; +// FLOAT ydist2 = 1.0 / rhat_len; //0.25*PI / rhat_len; FLOAT ydist = 1.0 / urhat_len; // printf("ydist1 %f ydist2 %f ydist %f\n", ydist1, ydist2, ydist); @@ -223,7 +223,7 @@ printf("rhat %f %f (len %f)\n", rhat[0][0], rhat[1][0], rhat_len); FLOAT x_y = sqrt(1.0 - x[0][0]*x[0][0] - x[2][0]*x[2][0]); FLOAT y_y = sqrt(1.0 - y[0][0]*y[0][0] - y[2][0]*y[2][0]); FLOAT z_y = sqrt(1.0 - z[0][0]*z[0][0] - z[2][0]*z[2][0]); - +/* // Exhaustively flip the minus sign of the z axis until we find the right one . . . FLOAT bestErr = 9999.0; FLOAT xy_dot2 = x[0][0]*y[0][0] + x[2][0]*y[2][0]; @@ -243,7 +243,7 @@ printf("rhat %f %f (len %f)\n", rhat[0][0], rhat[1][0], rhat_len); FLOAT cx,cy,cz; CrossProduct(cx,cy,cz,x[0][0],x_y,x[2][0],y[0][0],y_y,y[2][0]); FLOAT hand = cx*z[0][0] + cy*z_y + cz*z[2][0]; -// printf("err %f hand %f\n", err, hand); + printf("err %f hand %f\n", err, hand); // If we are the best right-handed frame so far if (hand > 0 && err < bestErr) { x[1][0]=x_y; y[1][0]=y_y; z[1][0]=z_y; bestErr=err; } @@ -253,7 +253,66 @@ printf("rhat %f %f (len %f)\n", rhat[0][0], rhat[1][0], rhat_len); } x_y = -x_y; } -// printf("bestErr %f\n", bestErr); + printf("bestErr %f\n", bestErr); +*/ + + //------------------------- + // A test version of the rescaling to the proper length + //------------------------- + FLOAT ydist2; + FLOAT bestBestErr = 9999.0; + for (ydist2=ydist-0.1; ydist2 0 && err < bestErr) { x2[1][0]=x_y; y2[1][0]=y_y; z2[1][0]=z_y; bestErr=err; } + z_y = -z_y; + } + y_y = -y_y; + } + x_y = -x_y; + } + printf("ydist2 %f bestErr %f\n",ydist2,bestErr); + + if (bestErr < bestBestErr) { + memcpy(x,x2,3*sizeof(FLOAT)); + memcpy(y,y2,3*sizeof(FLOAT)); + memcpy(z,z2,3*sizeof(FLOAT)); + bestBestErr = bestErr; + } + } + + /* for (i=0; i