I have a unit circle with the center at the origin $O=(0, 0, 0)$ and a random unit vector $\bar U = (a, b, c)$, in the Cartesian coordinate system. How can I find a random unit vector orthogonal to $\bar U$?
My try was to find an intersection of my sphere and plane, which passes through the origin and has $\bar U$ as a normal vector, and then to define a point on this unit circle randomly.
So I have the system of equations: \begin{cases} x^2 + y^2 + z^2 = 1, \\ ax + by + cz = 0, \end{cases} and I wanted to set the solutions of this system parametrically but I got stuck. I know how to set the solutions in particular cases (e.g. when $a=c\neq0$) but I have no idea for the general one.
If you are only interested in a numerical solution rather than a parametric one you can do the following:
If we call $\vec{n}=(a,b,c)$ than the corresponding unit vector is $\hat{n} = \frac{\vec{n}}{| \vec{n}|}$. Now generate a uniformly distributed random point $\vec{r}$ inside a sphere of radius 1.
Form the vector $\vec{u} = \vec{r} - \left( \vec{r}.\hat{n} \right) \hat{n}$. It is easy to see that this vector is perpendicular to $\vec{n}$. So if you normalise it you get a random unitvector $\hat{u}$ that is perpendicular to the normal of your circle.
There is of course a slight numerical problem if the random vector $\vec{r}$ is almost parallel to the normal. You could repeat generating the random vector $\vec{r}$ until the angle it makes with the normal is sufficiently large.
For a parametric solution, use a simple perpendicular vector $\vec{u} = (b, -a,0)$ and calculate the cross product $\vec{v} = \vec{n} \times \vec{u}$, normalise both and take a linear combination $\hat{w} = \cos \theta \hat{u} + \sin \theta \hat{v}$ with a uniformly distributed random $\theta \in [0,2 \pi]$.