Consider a line which passes through the origin and with direction vector $\vec g= G \vec f$ where $G$ is an $n+1$ by $n$ matrix of rank $n$
Consider a point $p$ in $n+1$ space
I'd like to find the $f$ which minimises the distance between the line and point $p$ over the sphere $f^{T}f=1$
If $g$ is three dimensional (it isn't in general) then I could use the distance equation:
$\frac {\Vert p\times Gf \Vert}{\Vert Gf \Vert}$
And i can introduce the skew-symmetric matrix for $p$ and also minimise the square instead to give:
$\frac {\Vert f^{T}G^{T} [p_\times]^{T}[p_\times] Gf \Vert}{\Vert f^{T}G^{T}Gf \Vert}$
where $[p_x]$ is the equivalent skew-symmetric matrix of cross product with $p$
I could then transform $f$ using cholseky decomposition of $G^{T}G$ and solve...
But i don't know how to do this in n-dimensions (i've tried to use the dot product formulation of distance to line without success).