# Vector Picking on the Unit Sphere

Imagine a vector from the center of a unit sphere to its surface:

Now imagine a second vector generated in indentical fashion. Given the first vector, how can I generate vectors to uniformally distribute the angle between them (θ).

My first thought was to use spherical coordinates -- however this generates a non-uniform distribution (as most points picked will be near the equatorial circumference, relative to the first vector):

Next I read this Wolfram Alpha article on sphere point picking. But that yields nearly identical results... the {X,Y,Z} endpoint is now uniformally distributed, but the angle (θ) between the two unit vectors is not.

The closest I've come is to pick the end point of the second vector on a unit circle which I place in plane centered on the sphere's center point. Then I take the point and rotate about the original vector by a random amount using the equation for rotation about a line in arbitrary space (such that the unit sphere's center can be place in arbitrary space).

This gives this distribution:
Which is relatively flat on [30,150], but spikes near the peaks.

Any ideas on how to pick the second vector so as to give a uniform angular distribution?

-
Just to be clear: you're well aware that uniform angular distribution does not correspond to any uniform distribution on the sphere, and you're certain that uniform angular distribution is the correct notion of uniformity for your application? – Steven Stadnicki Jun 5 '13 at 20:55
Yes, that is the case. The application is dependent on using pseudo-random uniform draws of angles for a dependent formula to drive a Markov chain. And yes, as I show above, both trival (non-uniform) rectangular coordinate distribution and more advanced uniform rectangular coord. distributions fail to uniformally distribute the angles (as you state). The question is how to get such a uniform distribution? – Jason R. Mick Jun 6 '13 at 17:54

In spherical coordinates, the surface area of a sphere is proportional to (1 minus the cosine of the polar angle), as measured from a chosen "pole" on the sphere. So perhaps after choosing your first vector, the second vector would be chosen so that $\ -1 \ \le \cos \theta \le +1 \$ is uniformly distributed for your second vector, $\ \theta \$ being the plane angle between them, and the "azimuthal angle" $\ 0 \le \phi < 2 \pi\$ for the direction of the second vector being uniformly distributed.
What I'm proposing is that the point on the sphere's surface for the first vector is used to define a "North Pole", from which polar angle $\ \theta \$ is measured. The value of $\ \cos \theta \$ is what would be used as the uniform random variable. That leaves a circle parallel to the "Equator" that the second vector could now point anywhere along; that vector could point at any azimuthal angle $\ \phi \$ on the circle , though that isn't central to the arrangement I think you are asking about, since the angle $\ \theta \$ is the same for all of those choices. – RecklessReckoner Jun 5 '13 at 20:24
What if you start from spherical coordinates (really only the two angular ones, since we are on a unit sphere) and then transform $\ \theta \$ and $\ \phi \$ into rectangular coordinates? – RecklessReckoner Jun 5 '13 at 21:17
Unless I have misunderstood, this problem does not have a unique solution, perhaps you have to be more specific. One solution is this: Without loss of generality, suppose the original vector is on the equator. Then, you just uniformly pick vectors on the equator, and there you go (For $2$ dimensions uniform point picking will yield a uniform angle distribution.).