   Bilinear Interpolation
  Hi, I'm trying to impliment this into an app i'm writing, but nto sure how to go about it. googling said phrase brings up reams of maths for what I don't think is an especially complex task.basically i'm looking to find the height of a point on a terrain made up of 3d points (equally spaced, so really we're just looking at the y coordinate for now).heres what i've got...float theTerrain::GetHeightOfPoint(float x, float z){//Check we're calculating a valid point within the bounds of the terrainif((x < this->mPos.x)||(z < this->mPos.z)||(x > (this->mPos.x + (TERRAIN_SIZE * STEP_SIZE)))||(z > (this->mPos.z + (TERRAIN_SIZE * STEP_SIZE)))){return -1.0f;}float tempX = x; float tempZ = z;int countX = 0;int countZ = 0;bool done = false;while(!done){if(tempX > STEP_SIZE){tempX -=STEP_SIZE;countX++;}if(tempZ > STEP_SIZE){tempZ -=STEP_SIZE;countZ++;}if((tempX < STEP_SIZE)&&(tempZ < STEP_SIZE)){done = true;}}//Now we have countX, countZ which represent the array index of the tile//and tempX, tempZ represent the offset from this tilefloat height = this->mGrid[countX][countZ].y;//height += change in height along Xheight += tempX * (this->mGrid[countX+1][countZ].y - this->mGrid[countX][countZ].y); //height += change in height along Zheight += tempZ * (this->mGrid[countX][countZ+1].y - this->mGrid[countX][countZ].y); //i think the above bit is where i'm messing up, I can see that adding both//is overkill, but i'm not sure what else to do?height+= 20.0f;//extra bit of height so we're not 'on' the groundreturn height;}
  Here's the most concise explanation I have seen for getting height on triangle surface:http://gpwiki.org/index.php/MathGem:Height_of_a_Point_in_a_TriangleIt even shows a simpler equation for when you triangle edges are grid-aligned, as is usually the case in simple grid-based height maps.   ;  on that link you posted it says"Given three vertices of a triangle, P, Q, and R, and x and y of the point,"for the x and y, does it mean the height values of the point on the triangle?  ie for x it'd be...float x = distance along line PQ * (height of P - height of Q);