Distance between a line and a 2d plane in 4d

I have a line defined as $k + \langle t\rangle$ and a plane defined as $s + \langle u, v\rangle$ where $k, t, s, u, v$ are 4-dimensional vectors (I know the coordinates). I need to find the distance between this plane and this line.

I also don't really know how to work in 4-dimensional space. In a 3-dimensional space I'd check whether the line and the plane are parallel by finding a vector orthogonal to both $u$ and $v$ and checking whether it is orthogonal to $t$. If they are not, the distance is 0, otherwise I'd try to form a general plane equation (the $Ax + By + Cz + D = 0$ one), take any point of the line and calculate the answer.

But I'm really confused about doing something of that sort in a 4-dimensional space. I don't even know how to check whether the line and the plane are parallel because I can find a vector orthogonal to $u$ and $v$ which is not orthogonal to $t$, but I can also find a vector which is orthogonal to all three of them. Then I don't know how to form a general plane equation: with 3 dimensions I'd form a parametric equation and calculate the determinant of a 3x3 matrix, but I can't do that in 4 dimensions, I'd get a 4x3 matrix.

If you are imagining a 3d analogon, it's probably better to imagine two lines in 3d. In general these will neither intersect nor be parallel, but skew. The situation with a generic line and plane in 4d is similar: the line usually will not intersect the plane.

You get the distance between any two sets of points as the minimal distance between any pair of points from these sets. In your case

$$d=\min_{\lambda,\mu,\tau}\left\lVert(k+\lambda t)-(s+\mu u+\tau v)\right\rVert$$

You can square this to avoid the square root. Now you have a quadratic term in three variables, which you can expand to make the variables stand out:

\begin{align*} d^2 &= \quad\langle k-s,k-s\rangle +\lambda\cdot 2\langle k-s,t\rangle -\mu\cdot 2\langle k-s,u\rangle -\tau\cdot 2\langle k-s,v\rangle \\&\quad-\lambda\mu\cdot 2\langle t,u\rangle -\lambda\tau\cdot 2\langle t,v\rangle +\mu\tau\cdot 2\langle u,v\rangle +\lambda^2\cdot\langle t,t\rangle +\mu^2\cdot\langle u,u\rangle +\tau^2\cdot\langle v,v\rangle \end{align*}

You are now looking for a minimum of this expression. That is a place where all three partial derivatives are zero.

\begin{align*} 0\overset!=\frac{\partial d^2}{\partial \lambda} &= 2\langle k-s,t\rangle + 2\langle t,t\rangle\lambda - 2\langle t,u\rangle\mu - 2\langle t,v\rangle\tau \\ 0\overset!=\frac{\partial d^2}{\partial \mu} &= -2\langle k-s,u\rangle - 2\langle t,u\rangle\lambda + 2\langle u,u\rangle\mu + 2\langle u,v\rangle\tau \\ 0\overset!=\frac{\partial d^2}{\partial \tau} &= -2\langle k-s,v\rangle - 2\langle t,v\rangle\lambda + 2\langle u,v\rangle\mu + 2\langle v,v\rangle\tau \end{align*}

As the partial derivatives are linear, this is a linear system of equations. Solve for $\lambda,\mu,\tau$ to find the parameters corresponding to the minimal distance, then plug back into the initial equation to compute the distance.

If the system of equations is singular, i.e. does not have a unique solution, then likely your line and plane are parallel, leading to multiple minimal solutions.