rand_ortho_vector {clugenr} | R Documentation |
u
.Get a random unit vector orthogonal to u
.
rand_ortho_vector(u)
u |
A unit vector. |
A random unit vector orthogonal to u
.
This function is stochastic. For reproducibility set a PRNG seed with set.seed.
r <- stats::runif(3) # Get a random 3D vector
r <- r / norm(r, "2") # Normalize it
o <- rand_ortho_vector(r) # Get a random unit vector orthogonal to r
r %*% o # Check that r and o are orthogonal (result should be ~0)