]> Pileus Git - grits/blobdiff - src/gis-util.c
Document GisOpenGL
[grits] / src / gis-util.c
index 3bd5246002e134843c7c8c2a13726dbc8e05c653..c25b57c4ed0116902b7a06457d60a76011ab401c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
+ * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -65,3 +65,16 @@ gdouble distd(gdouble *a, gdouble *b)
                    (a[1]-b[1])*(a[1]-b[1]) +
                    (a[2]-b[2])*(a[2]-b[2]));
 }
+
+gdouble lon_avg(gdouble a, gdouble b)
+{
+       gdouble diff = ABS(a-b);
+       gdouble avg  = (a+b)/2;
+       if (diff > 180) {
+               if (avg >= 0)
+                       avg -= 180;
+               else
+                       avg += 180;
+       }
+       return avg;
+}