Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

enter image description here

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): Angle distribution

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: enter image description here
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?

share|improve this question
    
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
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Sounds promising, but how do you suggest ensuring the planar angle is uniformally distributed? I'm a bit confused because it seemed like you reiterated by question... maybe I'm missing your train of thought. –  Jason R. Mick Jun 5 '13 at 20:18
    
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
    
Ah, I think I understand... let me test this.... –  Jason R. Mick Jun 5 '13 at 20:54
    
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
1  
@JasonR.Mick I don't recognize the coding language, but from what I could puzzle out about its grammar, I don't think it is doing what I've been describing. It seems to be based entirely in an approach using rectangular coordinates (which may be complicating what the programmer wants to do), but the process seems to have a different intent from what we've been discussing on this page. –  RecklessReckoner Jun 6 '13 at 17:35
show 5 more comments

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.).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.