Finding the x and y coordinates of the peak is simple. Since there is no grid, let's arbitrarily choose to make (0,0) be the center of your rectangle and (1,1) be the top right corner. For finding the location of the peak, the height of the peak is irrelevant, so take the height of the top right corner and subtract it from all the heights (effectively lowering the height of the whole landscape). Let:
a=adjusted height of top left corner
b=adjusted height of bottom left corner
c=adjusted height of bottom right corner
0=adjusted height of top right corner ;-)
Recognize that the equation for the cone is (x-x')^2+(y-y')^2=m(z-z')^2, but we'll set m=1 because it only effects the slope and thus the height of the peak, which we're ignoring for now. Plug in the above 4 points to get 4 equations. Take the fourth equation and subtract it from the other three to get three new equations that have no ^2 terms:
4x -a^2+2az=0
4x+4y-b^2+2bz=0
4y-c^2+2cz=0
These can be solved straightforwardly. The z value in the solution is irrelevant because I've taken so many shortcuts by procrastinating dealing with z. But for the others, we get:
x= a(c-b)(a-b-c) / (4(a+c-b)) ; when (b!=c; a+c != b)
y= c(b-a)(b+a-c) / (4(a+c-b)) ; when (b!=c; a+c != b ; a!=0)
For the rest, use the similar triangles thing that everyone else recommended: Using the x,y found above, compute the distance between each corner of the rectangle and the computed x,y (remembering that the corners are located at (+/-1, +/-1)). Choose any two of those corners such that their x,y distance to the peak is not equal. Denote their heights h1 and h2 and their x,y distances to the peak as w1 and w2. h=(h1*w2 - h2*w1) / (w2-w1) (when w2!=w1).
Update:The above is based on the
incorrect assumption of slope==1. Please discard.