diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2007-03-06 19:19:46 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2007-03-06 19:19:46 +0100 |
commit | 4671827b2408eccd6e457660b5817b5f9ae81569 (patch) | |
tree | 8b94ea04277853e9428ddad1aea1aac0ac7bd802 | |
parent | a1da5cacc005ff26d3d711fcef13c5f013258b8a (diff) |
implement initial main point adjustment (x-axis only)
-rw-r--r-- | src/GipfelWidget.cxx | 2 | ||||
-rw-r--r-- | src/ProjectionCylindrical.H | 2 | ||||
-rw-r--r-- | src/ProjectionLSQ.H | 4 | ||||
-rw-r--r-- | src/ProjectionLSQ.cxx | 27 | ||||
-rw-r--r-- | src/ProjectionRectilinear.H | 4 | ||||
-rw-r--r-- | src/ProjectionRectilinear.cxx | 1 | ||||
-rw-r--r-- | src/ViewParams.H | 1 | ||||
-rw-r--r-- | src/lsq_cylindrical.mac | 2 | ||||
-rw-r--r-- | src/lsq_rectilinear.mac | 6 |
9 files changed, 34 insertions, 15 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index a8efa97..53fc25b 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -802,6 +802,7 @@ GipfelWidget::load_distortion_params(const char *prof_name) { Fl_Preferences prof(dist_prefs, prof_name); ret += prof.get("k0", pan->parms.k0, pan->parms.k0); ret += prof.get("k1", pan->parms.k1, pan->parms.k1); + ret += prof.get("x0", pan->parms.k1, pan->parms.x0); return !ret; } @@ -812,6 +813,7 @@ GipfelWidget::save_distortion_params(const char *prof_name) { Fl_Preferences prof(dist_prefs, prof_name); prof.set("k0", pan->parms.k0); prof.set("k1", pan->parms.k1); + prof.set("x0", pan->parms.x0); return 0; } diff --git a/src/ProjectionCylindrical.H b/src/ProjectionCylindrical.H index 432d868..2cb9687 100644 --- a/src/ProjectionCylindrical.H +++ b/src/ProjectionCylindrical.H @@ -14,7 +14,7 @@ class ProjectionCylindrical : public ProjectionLSQ { virtual double get_view_angle() {return 6.2831853;}; /* 360 deg */ -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick +#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick virtual double mac_x(ARGS); virtual double mac_y(ARGS); virtual double mac_x_dc_view(ARGS); diff --git a/src/ProjectionLSQ.H b/src/ProjectionLSQ.H index 54ab641..273585f 100644 --- a/src/ProjectionLSQ.H +++ b/src/ProjectionLSQ.H @@ -34,7 +34,7 @@ class ProjectionLSQ { virtual double get_view_angle(); -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick +#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick virtual double mac_x(ARGS); virtual double mac_y(ARGS); virtual double mac_x_dc_view(ARGS); @@ -43,12 +43,14 @@ class ProjectionLSQ { virtual double mac_x_dscale(ARGS); virtual double mac_x_dk0(ARGS); virtual double mac_x_dk1(ARGS); + virtual double mac_x_dx0(ARGS); virtual double mac_y_dc_view(ARGS); virtual double mac_y_dc_nick(ARGS); virtual double mac_y_dc_tilt(ARGS); virtual double mac_y_dscale(ARGS); virtual double mac_y_dk0(ARGS); virtual double mac_y_dk1(ARGS); + virtual double mac_y_dx0(ARGS); #undef ARGS }; diff --git a/src/ProjectionLSQ.cxx b/src/ProjectionLSQ.cxx index 077641b..da5b3da 100644 --- a/src/ProjectionLSQ.cxx +++ b/src/ProjectionLSQ.cxx @@ -45,6 +45,7 @@ ProjectionLSQ::comp_params(const Hills *h, ViewParams *parms) { distortion_correct = 1; parms->k0 = 0.0; parms->k1 = 0.0; + parms->x0 = 0.0; } m1 = h->get(0); @@ -68,7 +69,7 @@ ProjectionLSQ::comp_params(const Hills *h, ViewParams *parms) { if (distortion_correct) { lsq(h, parms, 1); } - +fprintf(stderr, "===> x0 %f\n", parms->x0); return 0; } @@ -79,12 +80,12 @@ struct data { const ViewParams *old_params; }; -#define CALL(A) dat->p->A(c_view, c_nick, c_tilt, scale, k0, k1, m->alph, m->a_nick) +#define CALL(A) dat->p->A(c_view, c_nick, c_tilt, scale, k0, k1, x0, m->alph, m->a_nick) static int lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { struct data *dat = (struct data *) data; - double c_view, c_nick, c_tilt, scale, k0, k1; + double c_view, c_nick, c_tilt, scale, k0, k1, x0; c_view = gsl_vector_get (x, 0); c_nick = gsl_vector_get (x, 1); @@ -93,9 +94,11 @@ lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { if (dat->distortion_correct) { k0 = gsl_vector_get (x, 4); k1 = gsl_vector_get (x, 5); + x0 = gsl_vector_get (x, 6); } else { k0 = dat->old_params->k0; k1 = dat->old_params->k1; + x0 = dat->old_params->x0; } for (int i=0; i<dat->h->get_num(); i++) { @@ -115,7 +118,7 @@ lsq_f (const gsl_vector * x, void *data, gsl_vector * f) { static int lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { struct data *dat = (struct data *) data; - double c_view, c_nick, c_tilt, scale, k0, k1; + double c_view, c_nick, c_tilt, scale, k0, k1, x0; c_view = gsl_vector_get (x, 0); c_nick = gsl_vector_get (x, 1); @@ -124,9 +127,11 @@ lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { if (dat->distortion_correct) { k0 = gsl_vector_get (x, 4); k1 = gsl_vector_get (x, 5); + x0 = gsl_vector_get (x, 6); } else { k0 = dat->old_params->k0; k1 = dat->old_params->k1; + x0 = dat->old_params->x0; } for (int i=0; i<dat->h->get_num(); i++) { @@ -139,6 +144,7 @@ lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { if (dat->distortion_correct) { gsl_matrix_set (J, 2*i, 4, CALL(mac_x_dk0)); gsl_matrix_set (J, 2*i, 5, CALL(mac_x_dk1)); + gsl_matrix_set (J, 2*i, 6, CALL(mac_x_dx0)); } gsl_matrix_set (J, 2*i+1, 0, CALL(mac_y_dc_view)); @@ -148,6 +154,7 @@ lsq_df (const gsl_vector * x, void *data, gsl_matrix * J) { if (dat->distortion_correct) { gsl_matrix_set (J, 2*i+1, 4, CALL(mac_y_dk0)); gsl_matrix_set (J, 2*i+1, 5, CALL(mac_y_dk1)); + gsl_matrix_set (J, 2*i+1, 6, CALL(mac_y_dx0)); } } @@ -173,7 +180,7 @@ ProjectionLSQ::lsq(const Hills *h, ViewParams *parms, double x_init[8]; gsl_vector_view x; int status; - int num_params = distortion_correct?6:4; + int num_params = distortion_correct?7:4; dat.p = this; dat.distortion_correct = distortion_correct; @@ -186,6 +193,7 @@ ProjectionLSQ::lsq(const Hills *h, ViewParams *parms, x_init[3] = parms->scale; x_init[4] = parms->k0; x_init[5] = parms->k1; + x_init[6] = parms->x0; x = gsl_vector_view_array (x_init, num_params); @@ -216,6 +224,7 @@ ProjectionLSQ::lsq(const Hills *h, ViewParams *parms, if (distortion_correct) { parms->k0 = gsl_vector_get(s->x, 4); parms->k1 = gsl_vector_get(s->x, 5); + parms->x0 = gsl_vector_get(s->x, 6); } gsl_multifit_fdfsolver_free (s); @@ -228,9 +237,9 @@ ProjectionLSQ::get_coordinates(double alph, double a_nick, const ViewParams *parms, double *x, double *y) { *x = mac_x(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale, - parms->k0, parms->k1, alph, a_nick); + parms->k0, parms->k1, parms->x0, alph, a_nick); *y = mac_y(parms->a_center, parms->a_nick, parms->a_tilt, parms->scale, - parms->k0, parms->k1, alph, a_nick); + parms->k0, parms->k1, parms->x0, alph, a_nick); } double @@ -238,7 +247,7 @@ ProjectionLSQ::comp_scale(double a1, double a2, double d1, double d2) { return (fabs(d1 - d2) / fabs(a1 - a2)); } -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick +#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick double ProjectionLSQ::mac_x(ARGS) {return NAN;} double ProjectionLSQ::mac_y(ARGS) {return NAN;} @@ -248,9 +257,11 @@ double ProjectionLSQ::mac_x_dc_tilt(ARGS) {return NAN;} double ProjectionLSQ::mac_x_dscale(ARGS) {return NAN;} double ProjectionLSQ::mac_x_dk0(ARGS) {return NAN;} double ProjectionLSQ::mac_x_dk1(ARGS) {return NAN;} +double ProjectionLSQ::mac_x_dx0(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dc_view(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dc_nick(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dc_tilt(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dscale(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dk0(ARGS) {return NAN;} double ProjectionLSQ::mac_y_dk1(ARGS) {return NAN;} +double ProjectionLSQ::mac_y_dx0(ARGS) {return NAN;} diff --git a/src/ProjectionRectilinear.H b/src/ProjectionRectilinear.H index e68851e..f3f16bb 100644 --- a/src/ProjectionRectilinear.H +++ b/src/ProjectionRectilinear.H @@ -14,7 +14,7 @@ class ProjectionRectilinear : public ProjectionLSQ { virtual double get_view_angle() {return 1.0471976;}; /* 60 deg */ -#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick +#define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick virtual double mac_x(ARGS); virtual double mac_y(ARGS); virtual double mac_x_dc_view(ARGS); @@ -23,12 +23,14 @@ class ProjectionRectilinear : public ProjectionLSQ { virtual double mac_x_dscale(ARGS); virtual double mac_x_dk0(ARGS); virtual double mac_x_dk1(ARGS); + virtual double mac_x_dx0(ARGS); virtual double mac_y_dc_view(ARGS); virtual double mac_y_dc_nick(ARGS); virtual double mac_y_dc_tilt(ARGS); virtual double mac_y_dscale(ARGS); virtual double mac_y_dk0(ARGS); virtual double mac_y_dk1(ARGS); + virtual double mac_y_dx0(ARGS); #undef ARGS }; diff --git a/src/ProjectionRectilinear.cxx b/src/ProjectionRectilinear.cxx index fd64b7c..a6ec6d1 100644 --- a/src/ProjectionRectilinear.cxx +++ b/src/ProjectionRectilinear.cxx @@ -10,4 +10,3 @@ #include "ProjectionRectilinear.H" #include "ProjectionRectilinear_funcs.cxx" - diff --git a/src/ViewParams.H b/src/ViewParams.H index 2048fe2..44462c0 100644 --- a/src/ViewParams.H +++ b/src/ViewParams.H @@ -15,6 +15,7 @@ class ViewParams { double a_tilt; double k0; double k1; + double x0; }; #endif diff --git a/src/lsq_cylindrical.mac b/src/lsq_cylindrical.mac index 0bf9499..a88a2e2 100644 --- a/src/lsq_cylindrical.mac +++ b/src/lsq_cylindrical.mac @@ -18,7 +18,7 @@ load("expr2c.mac")$ x_expand : trigexpand(x_scale)$ y_expand : trigexpand(y_scale)$ -args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick"$ +args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick"$ expr2c("ProjectionCylindrical::mac_x", args, x_expand)$ expr2c("ProjectionCylindrical::mac_y", args, y_expand)$ diff --git a/src/lsq_rectilinear.mac b/src/lsq_rectilinear.mac index 69980c0..5bd7ac9 100644 --- a/src/lsq_rectilinear.mac +++ b/src/lsq_rectilinear.mac @@ -4,7 +4,7 @@ x : tan(m_view - c_view)$ y : tan(c_nick - m_nick)$ -x_rot : y * sin(c_tilt) + x * cos(c_tilt)$ +x_rot : y * sin(c_tilt) + x * cos(c_tilt)+x0$ y_rot : y * cos(c_tilt) - x * sin(c_tilt)$ d : x_rot ^ 2 + y_rot ^ 2$ dist_fact : d ^ 2 * k1 + d * k0$ @@ -20,7 +20,7 @@ load("expr2c.mac")$ x_expand : trigexpand(x_dist)$ y_expand : trigexpand(y_dist)$ -args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double m_view, double m_nick"$ +args: "double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick"$ expr2c("ProjectionRectilinear::mac_x", args, x_expand)$ expr2c("ProjectionRectilinear::mac_y", args, y_expand)$ @@ -31,9 +31,11 @@ expr2c("ProjectionRectilinear::mac_x_dc_tilt", args, diff(x_expand, c_tilt))$ expr2c("ProjectionRectilinear::mac_x_dscale", args, diff(x_expand, scale))$ expr2c("ProjectionRectilinear::mac_x_dk0", args, diff(x_expand, k0))$ expr2c("ProjectionRectilinear::mac_x_dk1", args, diff(x_expand, k1))$ +expr2c("ProjectionRectilinear::mac_x_dx0", args, diff(x_expand, x0))$ expr2c("ProjectionRectilinear::mac_y_dc_view", args, diff(y_expand, c_view))$ expr2c("ProjectionRectilinear::mac_y_dc_nick", args, diff(y_expand, c_nick))$ expr2c("ProjectionRectilinear::mac_y_dc_tilt", args, diff(y_expand, c_tilt))$ expr2c("ProjectionRectilinear::mac_y_dscale", args, diff(y_expand, scale))$ expr2c("ProjectionRectilinear::mac_y_dk0", args, diff(y_expand, k0))$ expr2c("ProjectionRectilinear::mac_y_dk1", args, diff(y_expand, k1))$ +expr2c("ProjectionRectilinear::mac_y_dx0", args, diff(y_expand, x0))$ |