1
0
Fork 0

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.
This commit is contained in:
curt 1997-07-10 04:26:36 +00:00
parent abf27ac881
commit 1f718dcc8f
4 changed files with 83 additions and 56 deletions

View file

@ -73,8 +73,8 @@ void engine( SCALAR dt, int init )
/* F_X_engine = Throttle[3]*813.4/0.2; */ /* original code */
/* F_Z_engine = Throttle[3]*11.36/0.2; */ /* original code */
F_X_engine = Throttle[3]*813.4/0.88;
F_Z_engine = Throttle[3]*11.36/0.88;
F_X_engine = Throttle[3]*813.4/0.85;
F_Z_engine = Throttle[3]*11.36/0.85;
Throttle_pct = Throttle[3];
}

View file

@ -105,7 +105,7 @@ static void fgInitVisuals() {
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
@ -193,9 +193,9 @@ static void fgUpdateViewParams() {
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 );
@ -610,9 +610,15 @@ int main( int argc, char *argv[] ) {
/* $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.
*

View file

@ -47,7 +47,7 @@ GLint mesh2GL(struct mesh *m) {
printf("In mesh2GL(), generating GL call list.\n");
istep = jstep = 4; /* Detail level 1 -- 1200 ... */
istep = jstep = 10; /* Detail level 1 -- 1200 ... */
/* setup the batch transformation */
fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
@ -132,9 +132,15 @@ GLint mesh2GL(struct mesh *m) {
/* $Log$
/* Revision 1.27 1997/07/09 21:31:13 curt
/* Working on making the ground "hard."
/* Revision 1.28 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.27 1997/07/09 21:31:13 curt
* Working on making the ground "hard."
*
* Revision 1.26 1997/07/08 18:20:13 curt
* Working on establishing a hard ground.
*

View file

@ -155,11 +155,9 @@ void mesh_do_it(struct mesh *m) {
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
______
@ -181,61 +179,78 @@ double mesh_altitude(double lon, double lat) {
dx = xlocal - xindex;
dy = ylocal - yindex;
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];
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;
z2 = eg.mesh_data[x2 * eg.rows + y2];
x3 = xindex + eg.col_step;
y3 = yindex;
z3 = eg.mesh_data[x3 * eg.rows + y3];
} else {
x3 = xindex;
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 {
/* 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];
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;
}
/* 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 */
printf("Our true ground elevation is %.2f\n", elev);
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] );
}
}
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."
*