diff options
| author | Johannes Hofmann <johannes.hofmann@gmx.de> | 2005-05-03 18:29:59 +0000 | 
|---|---|---|
| committer | Johannes Hofmann <johannes.hofmann@gmx.de> | 2005-05-03 18:29:59 +0000 | 
| commit | ea841707d7403224065239fe4f382c3407e1ca46 (patch) | |
| tree | 40af90ab7e4d0b2e0aa983d5d6af35e48ed60779 | |
| parent | b03d66723210ae436b08f433848e1ae72361e916 (diff) | |
split up update_visible_mountains 
split up update_visible_mountains
| -rw-r--r-- | src/Panorama.H | 6 | ||||
| -rw-r--r-- | src/Panorama.cxx | 80 | 
2 files changed, 58 insertions, 28 deletions
| diff --git a/src/Panorama.H b/src/Panorama.H index 06d8c8f..dfb5695 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -1,5 +1,5 @@  //  -// "$Id: Panorama.H,v 1.11 2005/05/03 20:04:14 hofmann Exp $" +// "$Id: Panorama.H,v 1.12 2005/05/03 20:29:59 hofmann Exp $"  //  // X11 header file for the Fast Light Tool Kit (FLTK).  // @@ -41,6 +41,10 @@ class Panorama {    int get_pos(const char *name, double *phi, double *lam, double *height); +  void update_angles(); + +  void update_coordinates(); +    void update_visible_mountains();    double distance(double phi, double lam); diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 095db14..1267470 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -1,5 +1,5 @@  //  -// "$Id: Panorama.cxx,v 1.22 2005/05/03 20:16:40 hofmann Exp $" +// "$Id: Panorama.cxx,v 1.23 2005/05/03 20:29:59 hofmann Exp $"  //  // PSEditWidget routines.  // @@ -109,7 +109,7 @@ Panorama::load_file(const char *name) {    fclose(fp); -  update_visible_mountains(); +  update_angles();    return 0;  } @@ -120,7 +120,7 @@ Panorama::set_viewpoint(const char *name) {      return 1;    } -  update_visible_mountains(); +  update_angles();    return 0;  } @@ -242,7 +242,7 @@ Panorama::guess(Mountains *p) {    scale = scale_best;    fprintf(stderr, "best %f\n", best);    fprintf(stderr, "center = %f, scale = %f, nick=%f\n", a_center /deg2rad, scale, a_nick/deg2rad); -  update_visible_mountains(); +  update_coordinates();    return 0;  } @@ -269,7 +269,7 @@ Panorama::comp_params() {    optimize(); -  update_visible_mountains(); +  update_coordinates();    return 0;  } @@ -340,27 +340,27 @@ Panorama::optimize() {  void  Panorama::set_center_angle(double a) {    a_center = a; -  update_visible_mountains(); +  update_coordinates();  }  void  Panorama::set_nick_angle(double a) {    a_nick = a;    fprintf(stderr, "-->nick%f\n", a_nick/deg2rad); -  update_visible_mountains(); +  update_coordinates();  }  void  Panorama::set_tilt_angle(double a) {    a_tilt = a;    fprintf(stderr, "-->tilt%f\n", a_tilt/deg2rad); -  update_visible_mountains(); +  update_coordinates();  }  void  Panorama::set_scale(double s) {    scale = s; -  update_visible_mountains(); +  update_coordinates();  }  void @@ -399,9 +399,27 @@ Panorama::get_pos(const char *name, double *phi, double *lam, double *height) {  }  void  +Panorama::update_angles() { +  int i; +  Mountain *m; + +  for (i=0; i<mountains->get_num(); i++) { +    m = mountains->get(i); +  +    m->dist = distance(m->phi, m->lam); +    if (m->phi != view_phi || m->lam != view_lam) { +       +      m->alph = alpha(m->phi, m->lam); +      m->a_nick = nick(m->dist, m->height); +    } +  } +   +  update_visible_mountains(); +} + +void   Panorama::update_visible_mountains() {    int i; -  double x_tmp, y_tmp;    Mountain *m;    visible_mountains->clear(); @@ -409,34 +427,42 @@ Panorama::update_visible_mountains() {    for (i=0; i<mountains->get_num(); i++) {      m = mountains->get(i); -    m->dist = distance(m->phi, m->lam);      if ((m->phi != view_phi || m->lam != view_lam) &&  	(m->height / (m->dist * EARTH_RADIUS)   	 > height_dist_ratio)) { -      m->alph = alpha(m->phi, m->lam); -      m->a_view = m->alph - a_center; -      if (m->a_view > pi_d) { -	m->a_view -= 2.0*pi_d; -      } else if (m->a_view < -pi_d) { -	m->a_view += 2.0*pi_d; -      } -              if (m->a_view < pi_d / 2.0 && m->a_view > - pi_d / 2.0) { -	m->a_nick = nick(m->dist, m->height); -	x_tmp = tan(m->a_view) * scale; -	y_tmp = - (tan(m->a_nick - a_nick) * scale); -	// rotate by a_tilt; -	m->x = (int) rint(x_tmp * cos(a_tilt) - y_tmp * sin(a_tilt)); -	m->y = (int) rint(x_tmp * sin(a_tilt) + y_tmp * cos(a_tilt)); - -  	visible_mountains->add(m);        }      }    }    visible_mountains->sort(); +  update_coordinates(); +} + +void  +Panorama::update_coordinates() { +  int i; +  double x_tmp, y_tmp; +  Mountain *m; + +  for (i=0; i<visible_mountains->get_num(); i++) { +    m = visible_mountains->get(i); +         +    m->a_view = m->alph - a_center; +    if (m->a_view > pi_d) { +      m->a_view -= 2.0*pi_d; +    } else if (m->a_view < -pi_d) { +      m->a_view += 2.0*pi_d; +    } +     +    x_tmp = tan(m->a_view) * scale; +    y_tmp = - (tan(m->a_nick - a_nick) * scale); +    // rotate by a_tilt; +    m->x = (int) rint(x_tmp * cos(a_tilt) - y_tmp * sin(a_tilt)); +    m->y = (int) rint(x_tmp * sin(a_tilt) + y_tmp * cos(a_tilt)); +  }  }  double  | 
