I have some points that sit on the hemisphere in spherical coordinates: $\theta \in [0,\pi/2]$, $\phi \in [0, 2\pi]$ (ie so a hemisphere around the vector (1,0,0) (spherical coordinates).

I should note the convention I'm using: $\theta$ is "elevation" measured from +y-axis.

I want to rotate each vector in spherical coordinates in that hemisphere without having to convert to Cartesian coordinates first.

The subproblem is I am trying create a couple thousand random vectors in a hemisphere centered around some normal.

The "cheap" way to do this is to generate uniformly distributed points on the unit sphere, and discard those that don't have a dot product with the normal > 0.

But I want to avoid creating vectors that I'll have to discard anyway, so I'd rather generate them correctly the first time around. So generate spherical vectors with $\theta \in [0,\pi/2]$, $\phi \in [0, 2\pi]$, then rotate by $\theta, \phi$ of the normal vector these random points are supposed to surround.

To get evenly distributed points on a hemisphere around the spherical vector (1,0,0):

$$ \text{Spherical Vector} (r=1, \theta=\cos^{-1}( \sqrt{ \zeta_1 } ), \phi=2 \pi \zeta_2 ) $$

Where $\zeta_1, \zeta_2$ are a random variables with values between 0 and 1.

What this does is distribute the elevation component with GREATER emphasis on the equator (LOTS of samples with $\theta=\pi/2$, less values at poles)

  • 3
    $\begingroup$ lol, inclusion is denoted by $\in$ (\in), not epsilon. I believe rotation around an arbitrary axis in spherical coordinates will be a nightmare. (1) Convert to Cartesian coordinates, (2) apply rotation matrix, (3) convert back to spherical. $\endgroup$ – anon Aug 23 '11 at 17:36
  • $\begingroup$ Usually one is randomly generating $\mu = \cos \theta$ so the directions are uniformly distributed. It is as easy to select $\mu \in [-1,1]$ (with your random number generator) as it is in $[0,1]$. $\endgroup$ – Alice Aug 23 '11 at 18:09
  • $\begingroup$ I'm confused, what is the actual question? I don't see any question marks in the text... $\endgroup$ – Rahul Aug 23 '11 at 18:48
  • 1
    $\begingroup$ @anon: I'm not sure, but I think that the $\in$ symbol might have evolved out of $\epsilon$. I've seen old books using $\epsilon$ for set membership. $\endgroup$ – Hans Lundmark Aug 23 '11 at 19:59
  • 3
    $\begingroup$ @anon: Look at Royden's Real Analysis, 3rd ed. for example. I always thoguht $\varepsilon$ stood for element, but according to Earliest Uses of Symbols of Set Theory and Logic "Giuseppe Peano (1858-1932) used an epsilon for membership in Arithmetices prinicipia nova methodo exposita, Turin 1889 (page vi, x). He stated that the symbol was an abbreviation for est; the entire work is in Latin." $\endgroup$ – t.b. Aug 23 '11 at 21:28

Why not just reverse the ones with dot product <0 instead of discarding them? You will still have a uniform distribution in the hemisphere.

  • $\begingroup$ Yes, very clever, I will probably use it. I'm still interested to know if you can rotate in spherical coordinates or if you have to move to Cartesian first? $\endgroup$ – bobobobo Aug 23 '11 at 18:45
  • 1
    $\begingroup$ I wasn't proposing to rotate. Just pick your axis and generate vectors on the sphere. For each vector, take the dot product with the axis. If the dot product is greater than 0, keep it. If less than zero, take the opposite vector (invert $\theta$ and add $\pi$ to $\phi$) $\endgroup$ – Ross Millikan Aug 23 '11 at 19:51
  • $\begingroup$ Yes, I see that. But can you rotate a vector, while in spherical coordinates, with a matrix perhaps, was the question? $\endgroup$ – bobobobo Aug 23 '11 at 20:39
  • $\begingroup$ BTW your answer is definitely the best, computationally cheapest route to go, so I will use that. $\endgroup$ – bobobobo Aug 23 '11 at 20:45
  • $\begingroup$ I don't know of a matrix approach. You could chase through the trigonometry, but I don't have the equations available. $\endgroup$ – Ross Millikan Aug 23 '11 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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