From 554299503aa2ae4d7896d59bf35f8eff169f02b9 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 3 Jan 2007 23:37:46 +0100 Subject: use WGS84 elipsoid --- src/Panorama.cxx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 38cbd8c..fbbdac3 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -327,7 +327,7 @@ Panorama::update_angles() { if (m->phi != view_phi || m->lam != view_lam) { m->alph = alpha(m->phi, m->lam); - m->a_nick = nick(m->dist, m->height); + m->a_nick = nick(m); } } @@ -393,7 +393,7 @@ Panorama::update_close_mountains() { if (m->flags & Hill::TRACK_POINT || ((m->phi != view_phi || m->lam != view_lam) && - (m->height / (m->dist * get_earth_radius(m->phi)) + (m->height / (m->dist * EARTH_RADIUS) > height_dist_ratio))) { close_mountains->add(m); @@ -455,29 +455,39 @@ Panorama::alpha(double phi, double lam) { double -Panorama::nick(double dist, double height) { +Panorama::nick(Hill *m) { double a, b, c; double beta; - b = height + get_earth_radius(view_phi); + b = m->height + get_earth_radius(m->phi); c = view_height + get_earth_radius(view_phi); - a = pow(((b * (b - (2.0 * c * cos(dist)))) + (c * c)), (1.0 / 2.0)); + a = pow(((b * (b - (2.0 * c * cos(m->dist)))) + (c * c)), (1.0 / 2.0)); beta = acos((-(b*b) + (a*a) + (c*c))/(2 * a * c)); return beta - pi_d / 2.0; } double -Panorama::get_earth_radius(double latitude) { - return EARTH_RADIUS; +Panorama::get_earth_radius(double phi) { + double a = 6378137.000; + double b = 6356752.315; + double x, y, r; + + x = a*b*pow(pow(a,2)*pow(tan(phi),2)+pow(b,2),-1.0/2.0); + y = a*b*tan(phi)*pow(pow(a,2)*pow(tan(phi),2)+pow(b,2),-1.0/2.0); + + r = sqrt(pow(x, 2) + pow(y, 2)); + + fprintf(stderr, "==> %f %f %f %f\n", phi, x, y, r); + return r; } double Panorama::get_real_distance(Hill *m) { double a, b, c, gam; - a = view_height + get_earth_radius(m->phi); + a = view_height + get_earth_radius(view_phi); b = m->height + get_earth_radius(m->phi); gam = m->dist; -- cgit v1.2.3 From d5f04f65ca793753ed8dc5ad31c99b30dee863f8 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 16 Jan 2007 15:30:02 +0100 Subject: add comment --- src/Panorama.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index fbbdac3..27e4ab0 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -468,6 +468,7 @@ Panorama::nick(Hill *m) { return beta - pi_d / 2.0; } +// return local distance to center of WGS84 ellipsoid double Panorama::get_earth_radius(double phi) { double a = 6378137.000; -- cgit v1.2.3 From 469983dbc81c46c552a460e82c5c2443fef0658a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 16 Jan 2007 19:39:28 +0100 Subject: simplify get_earth_radius() --- src/Panorama.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index b1d42d3..cfdfb22 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -35,6 +35,9 @@ Panorama::Panorama() { view_height = 0.0; proj = NULL; set_projection(ProjectionLSQ::RECTILINEAR); + + +fprintf(stderr, "=> %f, %f\n", get_earth_radius(0.0), get_earth_radius(pi_d/2.0)); } Panorama::~Panorama() { @@ -474,14 +477,11 @@ double Panorama::get_earth_radius(double phi) { double a = 6378137.000; double b = 6356752.315; - double x, y, r; - - x = a*b*pow(pow(a,2)*pow(tan(phi),2)+pow(b,2),-1.0/2.0); - y = a*b*tan(phi)*pow(pow(a,2)*pow(tan(phi),2)+pow(b,2),-1.0/2.0); + double r; + double ata = tan(phi); - r = sqrt(pow(x, 2) + pow(y, 2)); + r = a*pow(pow(ata,2)+1,1.0/2.0)*fabs(b)*pow(pow(b,2)+pow(a,2)*pow(ata,2),-1.0/2.0); - fprintf(stderr, "==> %f %f %f %f\n", phi, x, y, r); return r; } -- cgit v1.2.3 From c972f4a2023f94cd837c001e34715ab924745eb6 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 16 Jan 2007 19:40:14 +0100 Subject: remove unused Panorama::get_value() method --- src/Panorama.cxx | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index cfdfb22..bcf42b1 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -132,34 +132,6 @@ Panorama::get_visible_mountains() { return visible_mountains; } -double -Panorama::get_value(Hills *p) { - int i, j; - double v = 0.0, d_min, d; - - if (isnan(parms.scale) || isnan(parms.a_center) || isnan(parms.a_tilt) || isnan(parms.a_nick) || - parms.scale < 500.0 || parms.scale > 100000.0 || - parms.a_nick > pi_d/4.0 || parms.a_nick < - pi_d/4.0 || - parms.a_tilt > pi_d/16.0 || parms.a_tilt < - pi_d/16.0) { - return 10000000.0; - } - - - for (i=0; iget_num(); i++) { - d_min = 1000.0; - for (j=0; jget_num(); j++) { - d = pow(p->get(i)->x - visible_mountains->get(j)->x, 2.0) + - pow(p->get(i)->y - visible_mountains->get(j)->y, 2.0); - if (d < d_min) { - d_min = d; - } - } - v = v + d_min; - } - - return v; -} - int Panorama::comp_params(Hills *h) { int ret; -- cgit v1.2.3 From 0a3622f770ab24251bfb0e9f6d7927429323d07f Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 17 Jan 2007 10:01:34 +0100 Subject: whitespace --- src/Panorama.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index bcf42b1..839d70c 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -483,8 +483,6 @@ Panorama::is_visible(double a_alph) { int Panorama::get_coordinates(double a_alph, double a_nick, double *x, double *y) { - - if (is_visible(a_alph)) { proj->get_coordinates(a_alph, a_nick, &parms, x, y); return 0; -- cgit v1.2.3 From c00e603b4bfe336683c713cca80cbba47e639678 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 7 Mar 2007 22:25:03 +0100 Subject: add GUI stuff for x0 --- src/Panorama.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Panorama.cxx') diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 839d70c..7b1529b 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -166,15 +166,17 @@ Panorama::set_scale(double s) { } void -Panorama::get_distortion_params(double *k0, double *k1) { +Panorama::get_distortion_params(double *k0, double *k1, double *x0) { *k0 = parms.k0; *k1 = parms.k1; + *x0 = parms.x0; } void -Panorama::set_distortion_params(double k0, double k1) { +Panorama::set_distortion_params(double k0, double k1, double x0) { parms.k0 = k0; parms.k1 = k1; + parms.x0 = x0; update_coordinates(); } @@ -451,7 +453,7 @@ Panorama::get_earth_radius(double phi) { double b = 6356752.315; double r; double ata = tan(phi); - +return EARTH_RADIUS; r = a*pow(pow(ata,2)+1,1.0/2.0)*fabs(b)*pow(pow(b,2)+pow(a,2)*pow(ata,2),-1.0/2.0); return r; -- cgit v1.2.3