diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-11-14 23:14:58 +0100 | 
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-11-14 23:14:58 +0100 | 
| commit | 2658022a5f71690c18478d94c64d445aa38a68ee (patch) | |
| tree | 4434ca3aeda58364c8a9932010ae03d6aa097aa1 /src/ProjectionTangential.cxx | |
| parent | 7bf6b08fcda6c2fc37405e4a77f23b73191bd671 (diff) | |
fix wrap-around bug in ProjectionTangential
Diffstat (limited to 'src/ProjectionTangential.cxx')
| -rw-r--r-- | src/ProjectionTangential.cxx | 25 | 
1 files changed, 23 insertions, 2 deletions
diff --git a/src/ProjectionTangential.cxx b/src/ProjectionTangential.cxx index 8297ee4..032005d 100644 --- a/src/ProjectionTangential.cxx +++ b/src/ProjectionTangential.cxx @@ -76,6 +76,27 @@ ProjectionTangential::comp_params(const Hill *m1, const Hill *m2, ViewParams *pa    }  } +double  +ProjectionTangential::angle_dist(double a1, double a2) { +  double ret; + +  a1 = fmod(a1, 2.0 * pi_d);  +  if (a1 < 0.0) { +    a1 = a1 + 2.0 * pi_d; +  } +  a2 = fmod(a2, 2.0 * pi_d);  +  if (a2 < 0.0) { +    a2 = a2 + 2.0 * pi_d; +  } + +  ret = fabs(a1 - a2); +  if (ret > pi_d) { +    ret = 2.0 * pi_d - ret; +  }  + +  return ret; +} +  int  ProjectionTangential::optimize(const Hill *m1, const Hill *m2, ViewParams *parms) {    int i; @@ -118,10 +139,10 @@ ProjectionTangential::optimize(const Hill *m1, const Hill *m2, ViewParams *parms    // atan(tan_dir_view) is not the only possible solution.    // Choose the one which is close to m1->alph. -  if (fabs(parms->a_center - m1->alph) > pi_d/2.0) { +  if (angle_dist(parms->a_center, m1->alph) > pi_d/2.0) {     parms->a_center = parms->a_center + pi_d;    } -   +    parms->scale = n_scale;    // use the point with greater distance from center for tilt computation   | 
