]> git.mxchange.org Git - flightgear.git/blobdiff - SplitTris/splittris.c
Converting to polar3d.h routines.
[flightgear.git] / SplitTris / splittris.c
index 827e267465b2eee7dc87945d2bc72a584813aba3..c40000794b66c8f01d34ede279aef92b981a066c 100644 (file)
 
 #include <Include/fg_constants.h>
 #include <Include/fg_types.h>
+#include <Bucket/bucketutils.h>
+
 #include <Math/fg_geodesy.h>
 #include <Math/mat3.h>
-#include <Math/polar.h>
-#include <Scenery/bucketutils.h>
-
+#include <Math/polar3d.h>
 
 int nodecount, tricount;
 double xmin, xmax, ymin, ymax;
 
-double nodes_orig[MAX_NODES][3];
-int tris[MAX_TRIS][3];
-int new_tris[MAX_TRIS][3];
+static double nodes_orig[MAX_NODES][3];
+static int tris[MAX_TRIS][3];
+/* static int new_tris[MAX_TRIS][3]; */
 
-struct fgCartesianPoint nodes_cart[MAX_NODES];
+static fgCartesianPoint3d nodes_cart[MAX_NODES];
 
 struct fgBUCKET ne_index, nw_index, sw_index, se_index;
 struct fgBUCKET north_index, south_index, east_index, west_index;
 
 /* convert a geodetic point lon(arcsec), lat(arcsec), elev(meter) to
  * a cartesian point */
-struct fgCartesianPoint geod_to_cart(double geod[3]) {
-    struct fgCartesianPoint p;
+fgCartesianPoint3d geod_to_cart(double geod[3]) {
+    fgCartesianPoint3d cp;
+    fgPolarPoint3d pp;
     double gc_lon, gc_lat, sl_radius;
 
     /* printf("A geodetic point is (%.2f, %.2f, %.2f)\n", 
@@ -69,20 +70,23 @@ struct fgCartesianPoint geod_to_cart(double geod[3]) {
     /* printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, 
           gc_lat, sl_radius+geod[2]); */
 
-    p = fgPolarToCart(gc_lon, gc_lat, sl_radius+geod[2]);
+    pp.lon = gc_lon;
+    pp.lat = gc_lat;
+    pp.radius = sl_radius+geod[2];
+    cp = fgPolarToCart3d(pp);
     
-    /* printf("A cart point is (%.8f, %.8f, %.8f)\n", p.x, p.y, p.z); */
+    /* printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z); */
 
-    return(p);
+    return(cp);
 }
 
 
 /* given three points defining a triangle, calculate the normal */
-void calc_normal(struct fgCartesianPoint p1, struct fgCartesianPoint p2, 
-                struct fgCartesianPoint p3, double normal[3])
+void calc_normal(fgCartesianPoint3d p1, fgCartesianPoint3d p2, 
+                fgCartesianPoint3d p3, double normal[3])
 {
     double v1[3], v2[3];
-    float temp;
+    double temp;
 
     v1[0] = p2.x - p1.x; v1[1] = p2.y - p1.y; v1[2] = p2.z - p1.z;
     v2[0] = p3.x - p1.x; v2[1] = p3.y - p1.y; v2[2] = p3.z - p1.z;
@@ -456,8 +460,11 @@ void dump_obj(char *basename, char *basepath) {
        } else {
            fp = body;
        }
-       fprintf(fp, "gdn %.2f %.2f %.2f\n", 
-               nodes_orig[i][0], nodes_orig[i][1], nodes_orig[i][2]);
+
+       if ( fp != NULL ) {
+           fprintf(fp, "gdn %.2f %.2f %.2f\n", 
+                   nodes_orig[i][0], nodes_orig[i][1], nodes_orig[i][2]);
+       }
     }
 
     printf("  calculating and writing normals\n");
@@ -541,17 +548,17 @@ void dump_obj(char *basename, char *basepath) {
        }
     }
 
-    fclose(sw);
-    fclose(se);
-    fclose(ne);
-    fclose(nw);
+    if ( sw ) { fclose(sw); }
+    if ( se ) { fclose(se); }
+    if ( ne ) { fclose(ne); }
+    if ( nw ) { fclose(nw); }
 
-    fclose(north);
-    fclose(south);
-    fclose(east);
-    fclose(west);
+    if ( north ) { fclose(north); }
+    if ( south ) { fclose(south); }
+    if ( east ) { fclose(east); }
+    if ( west ) { fclose(west); }
 
-    fclose(body);
+    if ( body ) { fclose(body); }
 }
 
 
@@ -609,9 +616,30 @@ int main(int argc, char **argv) {
 
 
 /* $Log$
-/* Revision 1.3  1998/01/27 18:37:04  curt
-/* Lots of updates to get back in sync with changes made over in .../Src/
+/* Revision 1.10  1998/05/02 01:54:37  curt
+/* Converting to polar3d.h routines.
 /*
+ * Revision 1.9  1998/04/18 04:01:20  curt
+ * Now use libMath rather than having local copies of math routines.
+ *
+ * Revision 1.8  1998/04/14 02:26:08  curt
+ * Code reorganizations.  Added a Lib/ directory for more general libraries.
+ *
+ * Revision 1.7  1998/04/08 23:21:13  curt
+ * Adopted Gnu automake/autoconf system.
+ *
+ * Revision 1.6  1998/03/03 15:36:13  curt
+ * Tweaks for compiling with g++
+ *
+ * Revision 1.5  1998/03/03 03:37:04  curt
+ * Cumulative tweaks.
+ *
+ * Revision 1.4  1998/01/31 00:41:26  curt
+ * Made a few changes converting floats to doubles.
+ *
+ * Revision 1.3  1998/01/27 18:37:04  curt
+ * Lots of updates to get back in sync with changes made over in .../Src/
+ *
  * Revision 1.2  1998/01/14 15:54:43  curt
  * Initial revision completed.
  *