How to build a random vector perpendicular to another vector in R3

In summary: To see that it works, suppose that K=(0,0,1). Then, P = K x R will lie in the xy-plane, and, after normalization (call the normalized vector P'), on the equator of the unit sphere. P' is then entirely determined by its longitude. It is also clear that the direction of P and P', hence the longitude of P', depends only upon the longitude of R: If the longitude of R is θ, then the longitude of P' is θ+π/2 (mod 2π). But the longitude of R is uniformly distributed over the sphere, hence the longitude of P' is uniformly distributed over the equator
  • #1
Chandrasekhar
2
0
(SOLVED) How to build a 3D random vector perpendic. to another vector

Hi everybody,

do you have an efficient method for build up a vector with random components which is perpendicular to another (unitary) 3D vector ?

Context: I have to randomly select polarization vector (P) for unpolarized photons propagating on a certain direction (K) and the only condition is P being orthogonal to K.

input: K = (Kx, Ky, Kz) (it can be normalized if needed)
output: P = (Px, Py, Pz), P must be perpendicular to K and also unitary (modulus = 1)

I guess the Gram-Schmidt process must be used BUT the important thing is that P has to be randomly chosen on the plane perpendicular to K among the infinite possibilities with equal probability.

My photons propagates toward a preferential direction so if I chose everytime Px = Kx for starting the process, I'm giving a preferential orientation to P which is not the case.

One more thing is that I have to do this in a code so if you want to put the answer in the form of an algorithm it would be really appreciated!
Otherwise consider the use of random variables at some point in your explanation.

Thank you very much in advance! :)


------------------------------------------
one possible solution (?)

I choose a completely random vector, R, on a sphere centered at the origin of the reference frame of K.
Then I make the cross product between R and K and I should obtain P perpendicular to K (and R) but randomly chosen..

P = K x R

The question now is: does a random selection on a sphere produce a random vector on the plane perpendicular to K via cross product ?
 
Last edited:
Physics news on Phys.org
  • #2
Chandrasekhar said:
one possible solution (?)

I choose a completely random vector, R, on a sphere centered at the origin of the reference frame of K.
Then I make the cross product between R and K and I should obtain P perpendicular to K (and R) but randomly chosen..

P = K x R

The question now is: does a random selection on a sphere produce a random vector on the plane perpendicular to K via cross product ?
This will work, as far as I can see... (provided that you can you can choose a random vector on sphere, from a uniform distribution w.r.t. surface area, which does not seem to be trivial to me).

To see that it works, suppose that K=(0,0,1). Then, P = K x R will lie in the xy-plane, and, after normalization (call the normalized vector P'), on the equator of the unit sphere. P' is then entirely determined by its longitude. It is also clear that the direction of P and P', hence the longitude of P', depends only upon the longitude of R: If the longitude of R is θ, then the longitude of P' is θ+π/2 (mod 2π). But the longitude of R is uniformly distributed over the sphere, hence the longitude of P' is uniformly distributed over the equator. This means that P' is effectively a randomly chosen unitary vector in the xy-plane.

It is clear by rotational symmetry that the result must the be same if we take a random vector K on the unit sphere and the plane perpendicular to K (through the origin) instead of the xy-plane, which is what you wanted.
 
  • #3
Hi Chandrasekhar, welcome to PF!

Since "perpendicular to vector K" basically defines a plane, you only need to generate one random number in the range ##[0, 2\pi[##, which corresponds to the azimuthal angle of the vector P in that plane. You can use a generic uniform random number generator to get a number in the range ##[0,1[##, and multiply it by ##2\pi## to get the desired angle.

You then need to translate that into actual coordinates. I'm not sure what the best method for that, but here is how I would have a first go at it. Find the rotational matrix that rotates the vector K such that it is aligned with the z axis. Generate the random angle ##\theta## and define a vector in the x-y plane with that angle (using the usual convention that ##\theta = 0## corresponds to the positive x axis, ##\theta = \pi/2## is the positive y axis, etc.). Use the inverse of the rotation matrix to rotate that vector P in the proper direction.
 
  • #4
FWIW, one easy way to generate a random point on the sphere is to take a random draw from a standard 3D Gaussian, and normalize it. The 3D Gaussian is isotropic; hence, all directions are equally likely.

The only time it doesn't work is if you get the origin. Technically, that's the single most likely value (the mode), too. :) But it doesn't matter (much) in practice, since it happens with probability 0 (or, with floating point on a computer, with probability really-really-small).
 
  • #5
chogg said:
FWIW, one easy way to generate a random point on the sphere is to take a random draw from a standard 3D Gaussian, and normalize it. The 3D Gaussian is isotropic; hence, all directions are equally likely.
That's good (I had a more complicated method i mind.)
In fact, we don't even need to normalize here, since we must normalize P = K x R anyway.
 
  • #6
Hah! Good point.
 
  • #7
Thank you very much to all of you for the interesting comments!

Inspired by Dr Claude answer I found a very efficent way for doing what I needed.

First I do the cross product between K and one of the axis, for example the x-axis = [1,0,0] (but it's the same with any axis), and I obtain a temporary vector which is, by construction, perpendicular to K:

P_temp = K * x-axis ( * = cross product).

Then I normalize this vector and I use Rodrigues' formula (http://en.wikipedia.org/wiki/Rodrigues'_rotation_formula)
for rotate it around K with a random angle theta between 0 and 2*pie.

In this special case the second part of the formula is zero because of the dot product between K and P_temp.

It works and it is fast!
Thank yuo again!
 

1. How do I determine the components of a random vector perpendicular to a given vector in R3?

In order to find the components of a random vector perpendicular to a given vector in R3, you can use the cross product. The cross product of two vectors will result in a third vector that is perpendicular to both of the original vectors. Therefore, by taking the cross product of the given vector and any other random vector, you can determine the components of the random vector that will be perpendicular to the given vector.

2. Can I use any random vector to find a vector perpendicular to another vector in R3?

Yes, you can use any random vector as long as it is not parallel to the given vector. If the random vector is parallel to the given vector, then the cross product will result in a zero vector, which is not perpendicular to any vector.

3. Is there a specific order in which I should take the cross product of two vectors in order to find a perpendicular vector?

Yes, the order in which you take the cross product matters. The cross product is not commutative, meaning that A x B does not equal B x A. Therefore, you should take the cross product in the order of the given vector crossed with the random vector in order to find a perpendicular vector.

4. Can I use the dot product to find a vector perpendicular to another vector in R3?

No, the dot product will not result in a vector but rather a scalar value. In order to find a vector perpendicular to another vector, you must use the cross product.

5. Is it possible to have more than one vector that is perpendicular to a given vector in R3?

Yes, it is possible to have an infinite number of vectors that are perpendicular to a given vector in R3. Any vector that is in the plane perpendicular to the given vector can be considered perpendicular to it. Therefore, there are infinite possibilities for the direction and magnitude of a vector perpendicular to a given vector in R3.

Similar threads

Replies
3
Views
3K
  • Linear and Abstract Algebra
Replies
1
Views
839
  • Atomic and Condensed Matter
Replies
3
Views
765
Replies
4
Views
3K
Replies
2
Views
2K
Replies
3
Views
4K
  • Precalculus Mathematics Homework Help
Replies
4
Views
1K
  • Special and General Relativity
Replies
1
Views
512
  • Quantum Physics
Replies
5
Views
5K
  • Linear and Abstract Algebra
Replies
1
Views
1K
Back
Top