I want to uniformly generate two $n$-dimensional orthogonal vectors $\mathbf a, \mathbf b \in \mathbb R^n$ on a unit $n$-dimensional sphere. In other words, the vectors should satisfy $$ \begin{cases} a_1^2 + a_2^2 + \dotsb + a_n^2 = 1, \\ b_1^2 + b_2^2 + \dotsb + b_n^2 = 1, \\ a_1 b_1 + a_2 b_2 + \dotsb a_n b_n = 0. \end{cases} $$
The problem for me is to generate them uniformly over their set.
If $n=2$, I would generate like this:
- Generate a uniform angle $\varphi \in [0, 2\pi]$.
- Set $\mathbf a = (\cos \varphi, \sin \varphi)$.
- Uniformly generate angle $\theta \in \{ \varphi + \pi/2, \varphi - \pi/2 \}$ (only two values to generate from).
- Set $\mathbf b = (\cos \theta, \sin \theta)$.
For $n=3$, the situation already becomes more complicated...