Skip to content

rand_ortho_vector

Get a random unit vector orthogonal to u.

v = rand_ortho_vector(u)

Arguments

  • u - A unit vector.

Return values

  • v - A random unit vector orthogonal to u.

Note

This function is stochastic. For reproducibility set the PRNG seed with cluseed() as discussed in the Reference.

Examples

r = rand(3, 1);           % Get a random 3D vector
r = r / norm(r);          % Normalize it
o = rand_ortho_vector(r); % Get a random unit vector orthogonal to r
dot(r, o)    % Check that r and o are orthogonal (result should be ~0)
% ans = 0