in reply to OT:Math problem: Grids and conical sections.

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.

Replies are listed 'Best First'.
Re^2: OT:Math problem: Grids and conical sections.
by tilly (Archbishop) on Nov 24, 2005 at 20:21 UTC
    I don't recognize your equation for the cone because you've introduced a variable z without explaining what it is. You also are missing necessary square roots.

    You can't just set the slope at 1 because the slope has a complex effect on the observed heights. Doing that massively simplifies the answer.

    Those two math errors are significant enough that I see no reason to analyze farther.

    Update: BrowserUk pointed out where the equation came from. Indeed it did not need square roots. However the slope definitely matters.

      I don't recognize your equation for the cone because you've introduced a variable z

      Isn't jeffguy's cone equation a reordering of equation 5 on this Wolfram page?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Oh, so THAT's where he got it from.

        But he still can't just assume that the slope is 1. Let's take a concrete example and run a sanity check to demonstrate that.

        peak (1/2, 1/2), height 5, slope 2 point 1: bottom left 5 - 2*sqrt((3/2)**2 + (3/2)**2) = 0.757359312880715 point 2: bottom right 5 - 2*sqrt((1/2)**2 + (3/2)**2) = 1.83772233983162 point 3: top right 5 - 2*sqrt((1/2)**2 + (1/2)**2) = 3.58578643762691 point 4: top left 5 - 2*sqrt((3/2)**2 + (1/2)**2) = 1.83772233983162 a = 1.83772233983162 - 3.58578643762691 = -1.74806409779529 b = 0.757359312880715 - 3.58578643762691 = -2.8284271247462 c = 1.83772233983162 - 3.58578643762691 = -1.74806409779529 x = a(c-b)(a-c-b)/(4(a+c-b)) = -1.74806409779529 * (-1.74806409779529 - -2.8284271247462) * (-1.74806409779529 + -1.74806409779529 - -2.8284271247462) /( 4 * (-1.74806409779529 + -1.74806409779529 - -2.8284271247462) ) = -0.472135954999583
        and I'm not going to bother working out what he thinks that y should be since his value for x is already obviously wrong.
      You're right. At first glance, this looked like a term that wouldn't matter because of symmetry.
      For what it's worth, Z was the term representing the adjusted height of the peak (after subtracting the top-left corner off).

      Oh well -- back to math!
Re^2: OT:Math problem: Grids and conical sections.
by BrowserUk (Patriarch) on Nov 24, 2005 at 23:47 UTC

    Could you post your 4 (missing) equations, and their reduction to the 3 you posted?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      The four equations are the immediate offspring of plugging in values for x and y and z into that first equation I posted: (x-x')^2+(y-y')^2=m(z-z')^2. So for the equation for the top left corner (x'=-1, y'=1, z'=whatever height value was given), we plug those values into the above equation. Alas, I saw symmetry where there was none, and so I set m=1 which allowed much cancelling out. But even without m==1, when you multiply out the squares and then subtract any two equations, all the squares cancel out.
        Wow. I am impressed. This is solveable analytically!

        First one note. Your equation for a cone only works if m is the slope squared. Then follow this derivation (I've marked the important equations with ****):

        Point 1: (1, 0) at height h1
        Eqn 1:
          (x-1)2 + y2 = m(z - h1)2
          x2 - 2x + 1 + y2 = m(z2 - 2zh1 + h12)
          **** step 4
        
        Point 2: (0, 1) at height h2
        Eqn 2:
          x2 + (y-1)2 = m(z - h2)2
          x2 + y2 - 2y + 1 = m(z2 - 2zh2 + h22)
        
        Point 3: (-1,0)) at height h3
        Eqn 3:
          (x+1)2 + y2 = m(z - h3)2
          x2 + 2x + 1 + y2 = m(z2 - 2zh3 + h32)
        
        Point 4: (0, -1) at height h4
        Eqn 4:
          x2 + (y+1)2 = m(z - h4)2
          x2 + y2 + 2y + 1 = m(z2 - 2zh4 + h42)
        
        -------------------------------------------------------
        
        (Eqn 2 - Eqn 1)/m:
          2(x - y)/m = -2zh2 + h22 + 2zh1 - h12
        
        (Eqn 3 - Eqn 4)/m:
          2(x - y)/m = -2zh3 + h32 + 2zh4 - h42
        
        Combine to get:
        
          -2zh2 + h22 + 2zh1 - h12 = -2zh3 + h32 + 2zh4 - h42
          2z(h1 - h2 + h3 - h4) = h12 - h22 + h32 - h42
          z = 0.5(h12 - h22 + h32 - h42)/(h1 - h2 + h3 - h4)
          **** step 1
        
        -------------------------------------------------------
        
        (Eqn 3 - Eqn 1)/4:
        
          x = 0.25m(-2zh3 + h32 + 2zh1 - h12)
          **** step 2
        
         (Eqn 4 - Eqn 2)/4:
        
          y = 0.25m(-2zh4 + h42 + 2zh2 - h22)
          **** step 3
        
        And now we can use step 1 to find z, use steps 2 and 3 to substitute into step 4 to come up with a quadratic equation in m. Solve for m (remember that that's the slope squared). Substitute m back into steps 2 and 3 to find x and y.

        Whew!

        Update: Typos fixed. Had a - where I needed a +, and 4 when I needed 2.