Orthogonalizing basis vectors with constraints and unknowns I'm looking for help with the following problem:
Let $\vec{n} \in \mathbb{R}^{3}$ be known. Given the following constraints, is it possible to find an linearly independent orthogonal set of basis vectors $S=(\vec{S_{1}},\vec{S_{2}},\vec{S_{3}})$?


*

*$\vec{n} \in S$

*The third component of $\vec{S_{2}} = 0$

*The third component of $\vec{S_{3}} > 0$


For some context on where this problem comes from (incase there are other resources that I should look at), $\vec{n}$ specifies the direction of a screen of pixels and I am trying to find two orthogonal basis vectors that are within the plane of the screen. The basis will be used as the coordinates of an image, hence the constraints on the orientations.
 A: wlog we can break it into two cases: (a) the third  component $n_3$ of $n$ is zero and one.
case 1: $$n = (\cos t, \sin t, 0)^T, s_2 = (-\sin t, \cos t, 0)^T, s_3 = (0,0,1)^T.$$ 
case 2: $$n = (r\cos t, r\sin t, 1)^T, s_2 = (-\sin t, \cos t , 0)^T, s_3 = (x,y,1)^T.$$  now we need to satisfy the constraints $$-x \sin t + y \cos t = 0, \, x\cos t + y \sin t  = -1/r $$ which gives you $$x = -\frac 1 r\cos t, y = -\frac 1r\sin t.  $$
so we have 
$$n = (r\cos t, r\sin t, 1)^T, s_2 = (-\sin t, \cos t , 0)^T, s_3 = (-\frac 1r\cos t,- \frac 1r\sin t,1)^T.$$ 

$\bf edit:$  by the op's suggestion, the two cases can be combined to give 
$$ n = (\cos t, \sin t, r)^T, s_2 = (-\sin t, \cos t , 0)^T, s_3 = (-r\cos t,-r\sin t,1)^T.$$
A: I suppose you are searching for an orthogonal but not normal base, since $\vec n$ is not normal. So, let the vectors of the base be $\{ \vec n, \vec s, \vec t \}$:
You want:
$$
\vec n =
\begin{bmatrix}
n_1\\
n_2\\
n_3
\end{bmatrix}
$$
$$
\vec s =
\begin{bmatrix}
x\\
y\\
0
\end{bmatrix}
$$
$$
\vec t =
\begin{bmatrix}
t_1\\
t_2\\
t_3
\end{bmatrix}
\qquad t_3\ge0
$$
Since $\vec s$ must be orthogonal to $\vec n$ we have:
$$
\langle \vec n,\vec s\rangle=0
$$
and this gives:
$$
\vec s=
\begin{bmatrix}
x\\
-\dfrac{n_1}{n_2}x\\
0
\end{bmatrix}
$$
For $\vec t$ to be orthogonal to $\vec n$ and $\vec s$ we  have:
$$
\vec t= \vec n \times \vec s
$$
and this gives:
$$
\vec t= \vec i \left( -\dfrac{n_1n_3}{n_2}x\right)-\vec j \left( n_3 x\right)+\vec k \left(-\dfrac{n_1^2}{n_2}x-n_2x \right)
$$
and we want:
$$t_3=-\dfrac{n_1^2}{n_2}x-n_2x >0
$$
so you can always find $x$ and $\vec s$, $\vec t$ if $ n_2 \ne 0$. 
In the same way, the case $n_2=0$ gives:
$$
\vec s=
\begin{bmatrix}
0\\
y\\
0
\end{bmatrix}
\qquad
\vec t=
\begin{bmatrix}
-n_3y\\
0\\
n_1y
\end{bmatrix}
\qquad
$$
and we can always find $y$ such that $t_3 > 0$
