]> Pileus Git - grits/commitdiff
Start work on lle2ned for finding coords of cursor ned
authorAndy Spencer <andy753421@gmail.com>
Wed, 23 May 2012 04:38:54 +0000 (04:38 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 23 May 2012 04:38:54 +0000 (04:38 +0000)
src/grits-opengl.c
src/grits-util.c
src/grits-util.h

index a2dce843fd2049a1460aa341580ebf2479533393..dacca98fbadd6ed5e591853791aca0b725723ecb 100644 (file)
@@ -275,9 +275,9 @@ static gboolean on_motion_notify(GritsOpenGL *opengl, GdkEventMotion *event, gpo
 
 
        /* Test unproject */
-       //gdouble lat, lon, elev;
-       //grits_viewer_unproject(GRITS_VIEWER(opengl),
-       //              gl_x, gl_y, -1, &lat, &lon, &elev);
+       gdouble lat, lon, elev;
+       grits_viewer_unproject(GRITS_VIEWER(opengl),
+                       gl_x, gl_y, -1, &lat, &lon, &elev);
 
        /* Cleanup */
        glMatrixMode(GL_PROJECTION); glPopMatrix();
@@ -549,11 +549,11 @@ static void grits_opengl_unproject(GritsViewer *_opengl,
                opengl->sphere->view->view,
                &x, &y, &z);
        xyz2lle(x, y, z, lat, lon, elev);
-       //g_message("GritsOpenGL: unproject - "
-       //              "%4.0lf,%4.0lf,(%5.3lf) -> "
-       //              "%8.0lf,%8.0lf,%8.0lf -> "
-       //              "%6.2lf,%7.2lf,%4.0lf",
-       //      px, py, pz, x, y, z, *lat, *lon, *elev);
+       g_message("GritsOpenGL: unproject - "
+                       "%4.0lf,%4.0lf,(%5.3lf) -> "
+                       "%8.0lf,%8.0lf,%8.0lf -> "
+                       "%6.2lf,%7.2lf,%4.0lf",
+               px, py, pz, x, y, z, *lat, *lon, *elev);
 }
 
 static void grits_opengl_set_height_func(GritsViewer *_opengl, GritsBounds *bounds,
index ab795f9b15ae41c7e1c86884e2655ca8383371c1..a8d5a29ada519c4f02d85fd881a408aaacb749a5 100644 (file)
@@ -181,6 +181,39 @@ void xyz2ll(gdouble x, gdouble y, gdouble z,
        *lon = azim2lon(atan2(x,z));
 }
 
+/**
+ * lle2ned:
+ * @lat:   the latitude
+ * @lon:   the longitude
+ * @elev:  the elevation
+ * @rlat:  the reference latitude
+ * @rlon:  the reference longitude
+ * @relev: the reference elevation
+ * @n:     the north distance
+ * @e:     the east distance
+ * @d:     the down distance
+ *
+ * Get the north, east, and down distance from the reference point to a given
+ * location
+ */
+void lle2ned(gdouble lat, gdouble lon, gdouble elev,
+               gdouble rlat, gdouble rlon, gdouble relev,
+               gdouble *n, gdouble *e, gdouble *d)
+{
+       //gdouble px,py,pz, rx,ry,rz, dx,dy,dz;
+
+       //lle2xyz(lat, lon, elev, &px, &py, &pz);
+       //lle2xyz(rlat, rlon, relev, &px, &py, &pz);
+
+       //dx = px - rx;
+       //dy = py - ry;
+       //dz = pz - rz;
+
+       //gdouble rad = sqrt(x*x + y*y + z*z);
+       //*lat = incl2lat(acos(y / rad));
+       //*lon = azim2lon(atan2(x,z));
+}
+
 /**
  * ll2m:
  * @lon_dist: the distance in degrees of longitude
index 9a22ab519e06c08163d63c89944269500332cd66..0e5b00e8d0926ced9cb0c59c9a151081582d1196 100644 (file)
@@ -201,6 +201,10 @@ void xyz2lle(gdouble x, gdouble y, gdouble z,
 void xyz2ll(gdouble x, gdouble y, gdouble z,
                gdouble *lat, gdouble *lon);
 
+void lle2ned(gdouble lat, gdouble lon, gdouble elev,
+               gdouble rlat, gdouble rlon, gdouble relev,
+               gdouble *x, gdouble *y, gdouble *z);
+
 gdouble ll2m(gdouble lon_dist, gdouble lat);
 
 gdouble distd(gdouble *a, gdouble *b);