diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Panorama.H | 4 | ||||
-rw-r--r-- | src/Panorama.cxx | 57 |
2 files changed, 20 insertions, 41 deletions
diff --git a/src/Panorama.H b/src/Panorama.H index 651fe8e..3d5b260 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -41,7 +41,7 @@ class Panorama { double alpha(double phi, double lam); - double nick(double dist, double height); + double nick(Hill *m); double comp_center_angle(double alph_a, double alph_b, double d1, double d2); @@ -51,8 +51,6 @@ class Panorama { int optimize(Hill *m1, Hill *m2); - double get_value(Hills *p); - int is_visible(double a_alph); double pi_d, deg2rad; diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 1e3015a..839d70c 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() { @@ -129,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; i<p->get_num(); i++) { - d_min = 1000.0; - for (j=0; j<visible_mountains->get_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; @@ -328,7 +303,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); } } @@ -394,7 +369,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); @@ -456,29 +431,37 @@ 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; } +// return local distance to center of WGS84 ellipsoid 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 r; + double ata = tan(phi); + + 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; } 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; @@ -500,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; |