I'm working on a problem where I have many (between 500-2000) planes which theoretically all pass through a given line. These planes are all compactly described as a vector $\vec Q$, such that
$x = \vec Q \cdot (1,\,y,\,z)$.
Since I want for my application to express the line as
$\vec L (t)= \vec O + \vec Dt$,
where $\vec O$ lies on the $y=0$ plane, it is simple to find the point $\vec O$. The problem reduces to 2D least squares line intersection. (All planes are guaranteed to intersect $y=0$.) The only problem that remains is then to find the best-fit direction of intersection $\vec D$ for all planes.
I know that for two given planes with normals $\vec n_1$ and $\vec n_2$ the line of intersection is parallel to $\vec n_1 \times \vec n_2$. However, I do not know how to apply this knowledge to least squares. My software makes use of a matrix library so matrix solutions would be best.
How can I find the direction $\vec D$ of my line?