Finding the coordinate of a point on a square pyramid?

Given a square pyramid made by 5 points (4 corners for the base and the center), how can I find the height (Z coordinate) of a given X and Y coordinate pair?

Also, the center point could be lower in height than one or several corners.

Visually, imagine a pyramid made by the following 5 heights:

100    150
225
200    200

Essentially I need to draw a square pyramid so I need the height of the pyramid at a given X and Y coordinate.

• What do the numbers mean ? A point should have $3$ coordinates. – Peter Dec 11 '16 at 23:14
• Sorry. the numbers in the pyramid example show the Z coordinate – Kaelan Cooter Dec 11 '16 at 23:21
• If it's on the edges, it's easy, done by weighting the two Z coordinates. If it's on one of the sides, however, you need to determine the equation of the corresponding plane. You can find it here at Example 1: tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfPlanes.aspx After you have the equation of the plane, you add the two equations $x = X_1$ and $y=Y_1$ where $X_1$ and $Y_1$ are the two known coordinates of your point. Then solving the system will result in Z. – GregT Dec 11 '16 at 23:28
• The title is somewhat misleading. The base area of a square pyramid usually is a square – Peter Dec 11 '16 at 23:35

Let us assume in a first step that the 4 corners (pyramid base) have the following coordinates:

$$A_1(1,0,0),\ A_2(0,1,0),\ A_3(-1,0,0), A_4(0,-1,0).$$

Then the equation of the pyramid surface is

$$z=a * \min(1 - x - y, 1 - x + y, 1 + x - y, 1 + x + y)$$

($a$ is an arbitrary positive parameter giving a more of less peaky shape).

If one desires a flat surface (ground level $z=0$) outside of the pyramid, the adequate equation will take the max of the previous equation and $0$:

$$\tag{1}z=a * max(0,min(1 - x - y, 1 - x + y, 1 + x - y, 1 + x + y))$$

where the different equations $z=1\pm x \pm y$ are the equations of the planes $A_kA_{k+1}V$ where $V(0,0,a)$ is the top point of the pyramid.

See Fig. 1 below with $a=1$.

For a different pyramid, it suffice to make a $\frac{\pi}{4}$ rotation, otherwise said by using the following change of coordinates :

$$\cases{x=\dfrac{1}{\sqrt{2}}(x'-y')\\y=\dfrac{1}{\sqrt{2}}(x'+y')}$$

Remark: We express, as is classical, the ancient coordinates with respect to the new ones.

Plugging these expressions into $(1)$ (and using multiplication by $\sqrt{2}$), we obtain:

$$\tag{2}z=a * max(0,min(\sqrt{2} - 2x', \sqrt{2} - 2y', \sqrt{2} + 2y', \sqrt{2} +2x'))$$

(of course, one should drop all the "primes"). See Fig. 2. Fig. 1 Fig. 2