Finding an oblique pyramid with a rectangular base which admits an inscribed sphere I want to find the apex (or locus of the apex) of a pyramid with a given (known) rectangular base, that will have an inscribed sphere.
To that end, I've written a computer code, to implement the application of the iterative Newton-Raphson multi-variate method to this problem.  I took the base of the pyramid to be a $2 a \times 2 b$ rectangle centered at the origin. I then took the apex to be of coordinates $ (x_a, y_a, h) $ where $h$ is a fixed constant, while $x_a, y_a$ are allowed to vary.  Then I took the center of the inscribed sphere to be $(x_C, y_C , r )$.  This makes the total number of variables $5$, namely, $x_C, y_C, r, x_a, y_a $.  Four equations can be written that express the constraint that the distance from the center of the inscribed sphere to the four lateral sides of the pyramid is equal to the radius $r$.
I then ran the iteration, and it converged to a solution, given $a, b, h$.  However, this solution is not unique, and by changing the initial guess, will generate a new solution.  So, there is a whole locus of possible apex locations in space, all belonging to the plane $z= h$.
I would appreciate hints, comments, and solutions, especially analytic ones, if at all possible.
 A: From the comments of @Empy2 above, I realized that the pyramid surface can be viewed as the intersection of two infinite prisms.  Assume that the pyramid apex is at $(x, y, h)$.  The first prism axis is parallel to the $y$ axis, and its intersection with $xz$ plane is the triangle with vertices $(-a, 0, 0), (a, 0, 0) , (x, 0, h)$, while the other prism has its axis parallel to the $x$ axis, and its intersection with $yz$ plane is the triangle with vertices $(0, -b, 0), (0, b, 0), (0, y, h)$.  The projection of the inscribed sphere onto the $xz$ plane is the incircle of the triangular cross section of the first prism, and its projection on the $yz$ plane is the incircle of the triangular cross section of the second prism.  These two incircles must have the same radius, which is also the $z$ coordinate of the center of the inscribed sphere.  Now we're set.
For the first triangle, its area is $A = \dfrac{1}{2} (2 a) h $ and its perimeter is $P = 2 a + \sqrt{ (x - a)^2 + h^2 } + \sqrt{ (x + a)^2 + h^2} $, therefore its inradius is given by
$r_1 = \dfrac{2 A}{P} = \dfrac{ 2 a h }{2 a + \sqrt{ (x - a)^2 + h^2 } + \sqrt{ (x + a)^2 + h^2 }}$
Similarly, the inradius of the second triangle is
$r_2 = \dfrac{ 2 b h }{2 b + \sqrt{ (y - b)^2 + h^2 } + \sqrt{ (y + b)^2 + h^2 }}$
Setting $r_1 = r_2$ gives
$ a \bigg( \sqrt{ (y - b)^2 + h^2 } + \sqrt{ (y + b)^2 + h^2 }\bigg) = b \bigg( 
\sqrt{ (x - a)^2 + h^2 } + \sqrt{ (x + a)^2 + h^2 } \bigg)$
This equation gives implicitly the relation between $x$ and $y$.
What remains is to visualize this locus of the apex that admits an inscribed sphere.
For that, I set $x$ to a range of values and calculated the corresponding $y$, using the following equation that is derived from the above implicit equation between $x$ and $y$
Let $A = \sqrt{ (x - a)^2 + h^2 } + \sqrt{ (x + a)^2 + h^2 } $, then
$y = \sqrt{ \dfrac{(b A / a)^2 (b^2 + h^2) - \frac{1}{4} (b A / a)^4 }{ 4 b^2 - (bA/a)^2 } }$
For $a = 30, b = 18, h = 10 $, I got the following locus (red), and the radius of the inscribed sphere (shown scaled up by a factor of $10$ in green)

