From 9d8a88c1a46cc95f69e9bc0e50ed1134bef6c715 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Wed, 1 Apr 2009 13:16:44 +0200 Subject: fix bug in cylindrical projection If one peak is "left" and one is "right" of north, cylindrical projection was not able to compute proper viewing parameters. This is fixed by adjusting alpha angles of known hills to be increasing with x. --- src/Hill.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Hill.cxx') diff --git a/src/Hill.cxx b/src/Hill.cxx index f45c197..b053568 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -242,6 +242,23 @@ comp_mountains_label_y(const void *n1, const void *n2) { } } +static int +comp_mountains_x(const void *n1, const void *n2) { + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + if (m2->x < m1->x) + return 1; + else if (m2->x > m1->x) + return -1; + else + return 0; + } else { + return 0; + } +} + void Hills::sort(SortType t) { int (*cmp)(const void *, const void *); @@ -262,6 +279,9 @@ Hills::sort(SortType t) { case SORT_LABEL_Y: cmp = comp_mountains_label_y; break; + case SORT_X: + cmp = comp_mountains_x; + break; default: fprintf(stderr, "ERROR: Unknown sort type %d\n", t); return; -- cgit v1.2.3