Given three vectors $u_1, u_2, u_3 \in \mathbb{R}^3$ that are linearly independent, you build a parallelepiped by specifying a vertex $V_1$, and then the other $7$ vertices follow:
$V_2 = V_1 + u_1 $
$V_3 = V_1 + u_1 + u_2 $
$V_4 = V_1 + u_2 $
$V_5 = V_1 + u_3 $
$ V_6 = V_1 + u_3 + u_1 $
$ V_7 = V_1 + u_3 + u_1 + u_2 $
$ V_8 = V_1 + u_3 + u_2 $
Now given two points that lie on the surface of the parallelepiped given as follows
$ P_1 = V_1 + t_1 u_1 + s_1 u_2 $
$ P_2 = V_1 + t_2 u_2 + s_2 u_3 $
where $0 \lt t_1, s_1, t_2, s_2 \lt 1 $
You want to find the equation of the ellipsoid that is inscribed in the parallelepiped and tangent to it at the two specified points $P_1$ and $P_2$.
Remarks
The parameters $t_1, s_1, t_2, s_2 $ are not independent. Only three of them can be specified independently.
My attempt: is detailed in my answer below.
Your comments, remarks on the question and answer as well as alternative answers are highly appreciated.
I first transformed the parallelepiped into a cube by an affine transformation. This way it should be easier to find the ellipsoid. Once its equation is found, it can be transformed back into the original coordinate system.
For simplicity, let the target cube have a side of $2$, and centered at the origin. Then the affine transformation is given by
$ Y = L (X - C) $
where
$ C = V_1 + 0.5(u_1 + u_2 + u_3)$
and matrix $L$ is to be determined.
is the center of the parallelepiped.
Now, we want $V_1$ mapped to $(-1, -1, -1)$, $V_2$ mapped to $(1, -1, -1)$ , $V_4$ mapped to $(-1, 1, -1)$ and finally $V_5$ mapped to $(-1, -1, 1) $.
This means that $u_1 = V_2 - V_1$ is mapped to $(2, 0, 0)$ and $u_2 = V_4 - V_1$ is mapped to $(0,2,0)$ and $u_3 = V_5 - V_1$ is mapped to $(0, 0, 2)$
So now have the matrix equation:
$ 2 I = L [u_1, u_2, u_3] $
From which
$ L = 2 [u_1, u_2, u_3]^{-1} $
Applying this transformation to points $P_1$ and $P_2$ gives the corresponding points on the surface of the cube as:
$Q_1 = L ( P_1 - C ) = L ( (t_1 - 0.5) u_1 + (s_1 - 0.5) u_2 -0.5 u_3 ) = ( 2 t_1 - 1, 2 s_1 - 1, -1 ) $
And
$Q_2 = L ( P_2 - C ) = L ( -0.5 u_1 + (t_2 - 0.5) u_2 + (s_2 - 0.5) u_3 ) = (-1, 2 t_2 - 1, 2 s_2 - 1 ) $
Now, we have a cube centered at the origin, with its edges parallel to the coordinate axes, with side length $2$.
The generic equation of an ellipsoid centered at the origin is
$ r^T A r = 1 \tag{1}$
where $r = [x,y,z]^T $ and $A$ is a symmetric, positive definite $3 \times 3 $ matrix.
The gradient vector is given by
$ N = 2 A r $
Now at point $Q1 = ( 2 t_1 - 1, 2 s_1 - 1, -1 )$ this gradient is pointing in the $-e_3$ direction. Thus
$ A Q_1 = - k_3 e_3 $
where $k_3 \gt 0 $, so that
$ Q_1 = - k_3 B e_3 $
where $B = A^{-1}$
Plugging this expression into $(1)$, we get
$ k_3 = \dfrac{1}{\sqrt{ e_3^T B e_3 } } $
Now,
$ e_3^T Q_1 = -1 = - \sqrt{ e_3^T B e_3} = - \sqrt{B_{33}} $
From which $B_{33} = 1 $
Next,
$ e_1^T Q_1 = 2t_1 - 1 = - \dfrac{ e_1^T B e_3 }{\sqrt{ e_3^T B e_3}} = - e_1^T B e_3 $
Therefore, $ B_{13} = 1- 2 t_1 $
And similarly $ B_{23} = 1 - 2 s_1 $
Moving on to $Q_2=(-1, 2 t_2 - 1, 2 s_2 - 1 )$, we find using the above analysis, that
$ B_{11} = 1 $
And that
$ B_{21} = 1 - 2 t_2 $
and
$ B_{31} = 1 - 2 s_2 $
But $B_{31} = B_{13}$, therefore, we must have $ s_2 = t_1 $.
Using the fact that the tangency point with the plane $y=-1$ has that value for its $y$-coordinate, it follows that
$ B_{22} = 1 $
And we can use the above analysis to find the rest of the tangency points.
So now, we have $B_{11} = B_{22} = B_{33} = 1 $ and $ B_{12} = 1 - 2 t_2 , B_{13} = 1 - 2 t_1 , B_{23} = 1 - 2 s_1 $
So $B$ is completely specified. Matrix $A$ is
$ A = B^{-1} $
This means we have found the equation of the ellipsoid tangent to the cube.
To find the equation of the original ellipsoid in the original coordinate frame, we have
$ r' = L (r - C) \tag{2}$
where $r'$ is the coordinate vector in the transformed space (the cube space), and $r$ is the corresponding coordinate vector in the original coordinate frame (the parallepiped space). Substituting $(2)$ into $(1)$,
$ ( L (r - C) )^T A ( L (r - C) ) = 1 $
Expanding, we get
$ (r - C)^T L^T A L (r - C) = 1 $
Here's an example of the solution ellipsoid inscribed in a cuboid with dimensions $5, 6, 7$, with $t_1 = 0.2 , s_1 = 0.4, t_2 = 0.4 $