I have a unit vector v1 and would like to generate a random perpendicular unit vector v2 with uniform or close to uniform distribution.
Potential solution is to generate a random unit vector and cross it with v1 to get v2. Now this has two issues - non uniform distribution and for some inputs it generates degenerate vectors, so it requires running in a loop until a valid vector is returned.
My current solution is to generate a random angle. Build a rotation matrix M using v1 and two perpendicular vectors. Those vectors are generated by crossing v1 with axis of it's smallest component and by crossing result with v1. Finally transform vector [ cos(randomAngle), sin(randomAngle), 0 ] using rotation matrix M.
It works, but I feel that I'm doing excessive amount of calculations and there is a much simpler way to solve it.