static GLfloat fogColor[4] = {0.65, 0.65, 0.85, 1.0};
glEnable( GL_DEPTH_TEST );
- glFrontFace(GL_CW);
+ /* glFrontFace(GL_CW); */
glEnable( GL_CULL_FACE );
/* If enabled, normal vectors specified with glNormal are scaled
printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
FG_Altitude * FEET_TO_METER);
- gluLookAt(view_pos.y, view_pos.z, FG_Altitude * FEET_TO_METER * 0.001,
+ gluLookAt(view_pos.y, view_pos.z, (FG_Altitude+3.0)*FEET_TO_METER * 0.0011,
view_pos.y + fwrd_view[0], view_pos.z + fwrd_view[1],
- FG_Altitude * FEET_TO_METER * 0.001 + fwrd_view[2],
+ (FG_Altitude+3.0)*FEET_TO_METER * 0.001 + fwrd_view[2],
up[0], up[1], up[2]);
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
/* $Log$
-/* Revision 1.29 1997/07/09 21:31:12 curt
-/* Working on making the ground "hard."
+/* Revision 1.30 1997/07/10 04:26:37 curt
+/* We now can interpolated ground elevation for any position in the grid. We
+/* can use this to enforce a "hard" ground. We still need to enforce some
+/* bounds checking so that we don't try to lookup data points outside the
+/* grid data set.
/*
+ * Revision 1.29 1997/07/09 21:31:12 curt
+ * Working on making the ground "hard."
+ *
* Revision 1.28 1997/07/08 18:20:12 curt
* Working on establishing a hard ground.
*
double mesh_altitude(double lon, double lat) {
/* we expect incoming (lon,lat) to be in arcsec for now */
- double xlocal, ylocal, dx, dy;
+ double xlocal, ylocal, dx, dy, zA, zB, elev;
int x1, y1, z1, x2, y2, z2, x3, y3, z3;
int xindex, yindex;
- double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9, tmp10;
- double a, b, c;
/* determine if we are in the lower triangle or the upper triangle
______
dx = xlocal - xindex;
dy = ylocal - yindex;
- x1 = xindex;
- y1 = yindex;
- z1 = eg.mesh_data[x1 * eg.rows + y1];
+ if ( dx > dy ) {
+ /* lower triangle */
+ printf(" Lower triangle\n");
+
+ x1 = xindex;
+ y1 = yindex;
+ z1 = eg.mesh_data[x1 * eg.rows + y1];
- x2 = xindex + eg.col_step;
- y2 = yindex + eg.row_step;
- z2 = eg.mesh_data[x2 * eg.rows + y2];
+ x2 = xindex + eg.col_step;
+ y2 = yindex;
+ z2 = eg.mesh_data[x2 * eg.rows + y2];
- if ( dx > dy ) {
x3 = xindex + eg.col_step;
- y3 = yindex;
+ y3 = yindex + eg.row_step;
z3 = eg.mesh_data[x3 * eg.rows + y3];
+
+ printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
+ printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
+ printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
+
+ zA = dx * (z2 - z1) / eg.col_step + z1;
+ zB = dx * (z3 - z1) / eg.col_step + z1;
+
+ printf(" zA = %.2f zB = %.2f\n", zA, zB);
+
+ elev = dy * (zB - zA) * eg.col_step / (eg.row_step * dx) + zA;
} else {
- x3 = xindex;
+ /* upper triangle */
+ printf(" Upper triangle\n");
+
+ x1 = xindex;
+ y1 = yindex;
+ z1 = eg.mesh_data[x1 * eg.rows + y1];
+
+ x2 = xindex;
+ y2 = yindex + eg.row_step;
+ z2 = eg.mesh_data[x2 * eg.rows + y2];
+
+ x3 = xindex + eg.col_step;
y3 = yindex + eg.row_step;
z3 = eg.mesh_data[x3 * eg.rows + y3];
- }
- /* given (x1, y1, z1) (x2, y2, z2) and (x3, y3, z3) calculate (a,
- * b, c) such that z = ax + by + c is the equation of the plane
- * intersecting the three given points */
-
- tmp1 = (x2 * z1 / x1 - z2);
- tmp2 = (y2 - x2 * y1 / x1);
- tmp3 = (x2 * y1 / x1 - y2);
- tmp4 = (1 - x2 / x1);
- tmp5 = (x3*(z1 + y1*tmp1 / tmp2) / x1 - z3 + y3*tmp1 / tmp3);
- tmp6 = x3*(y1*tmp4 / tmp2 - 1);
- tmp7 = tmp5 / (y3*tmp4 / tmp2 - tmp6 / x1 - 1);
- tmp8 = (tmp6 / x1 + y3*tmp4 / tmp3 + 1);
- tmp9 = (z1 + tmp5 / tmp8);
- tmp10 = (tmp7 + x2*tmp9 / x1 - z2);
-
- a = (tmp9 + y1*tmp10 / tmp2) / x1;
-
- b = tmp10 / tmp3;
-
- c = tmp7;
-
- /* Then, given a position we can calculate the current ground elevation */
-
- printf("Our true ground elevation is %.2f\n", a*lon + b*lat + c);
-
- if ( (xindex >= 0) && (xindex < eg.cols) ) {
- if ( (yindex >= 0) && (yindex < eg.rows) ) {
- return( eg.mesh_data[xindex * eg.rows + yindex] );
- }
+ printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
+ printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
+ printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
+
+ zA = dy * (z2 - z1) / eg.row_step + z1;
+ zB = dy * (z3 - z1) / eg.row_step + z1;
+
+ printf(" zA = %.2f zB = %.2f\n", zA, zB );
+ printf(" dx = %.2f xB - xA = %.2f\n", dx,
+ eg.col_step * dy / eg.row_step);
+
+ elev = dx * (zB - zA) * eg.row_step / (eg.col_step * dy) + zA;
}
+
+ printf("Our true ground elevation is %.2f\n", elev);
+
+ return(elev);
}
/* $Log$
-/* Revision 1.9 1997/07/10 02:22:10 curt
-/* Working on terrain elevation interpolation routine.
+/* Revision 1.10 1997/07/10 04:26:38 curt
+/* We now can interpolated ground elevation for any position in the grid. We
+/* can use this to enforce a "hard" ground. We still need to enforce some
+/* bounds checking so that we don't try to lookup data points outside the
+/* grid data set.
/*
+ * Revision 1.9 1997/07/10 02:22:10 curt
+ * Working on terrain elevation interpolation routine.
+ *
* Revision 1.8 1997/07/09 21:31:15 curt
* Working on making the ground "hard."
*