I have a sphere whose centre is "not at the origin". Now I want to get random pair of points (a,b) on the surface of the sphere such that 'b' is diametrically opposite to 'a' . I am using Python for this. Any help would be appreciated.
Asked
Active
Viewed 62 times
0
-
2What did you try? If the code works for a sphere centered at the origin, it would be trivial to translate the 2 points to any other sphere. – Eric Duminil Feb 15 '17 at 13:31
-
1Hint: spherical coordinates. Find one point first, using a random angle (lat/llong) and a fixed radius, centered on zero. Find the opposing point by flipping the angles. Then apply the origin shift to both points. – Benjamin Feb 15 '17 at 13:33
-
5@Benjamin: if you use random latitude and longitude, your points won't be uniformally distributed. – Eric Duminil Feb 15 '17 at 13:37
-
2I am using this discussion [link](http://stackoverflow.com/questions/33976911/generate-a-random-sample-of-points-distributed-on-the-surface-of-a-unit-sphere) to generate random points (x,y,z) on the sphere and then the diametrically opposite points would be (-x,-y,-z). Then I am applying the origin shift to both the points. Is it the easiest way to do so?? – Arpan Das Feb 15 '17 at 13:39
-
1@ArpanDas: that sounds like a pretty good solution. Why are you not happy with it? – Eric Feb 15 '17 at 13:42
-
1How much easier do you want it? Which of the solutions offered in the link are you using? The shift part I'd categorically say you can't have any easier. – Paul Panzer Feb 15 '17 at 13:44
-
@EricDuminil: Thank you, makes sense: http://mathworld.wolfram.com/SpherePointPicking.html – Benjamin Feb 15 '17 at 13:46
-
2@ArpanDas: Your method is the easiest and cleanest one. Case closed – Eric Duminil Feb 15 '17 at 13:47
-
I was thinking about the fastest way to sample the random points. The inversion is trivial and also the origin shift. So what I am doing is picking up a random point on the upper hemisphere using a random value of theta and phi and then find the opposite point. Do I need to pick a random point on the other hemisphere as well? Because I think I am automatically sampling the other part by inverting the points!! – Arpan Das Feb 15 '17 at 13:58
-
2Why don't you pick a point on the whole sphere directly? – Eric Duminil Feb 15 '17 at 14:00
-
@EricDuminil My final aim is to draw lines from one point of the sphere to diametrically opposite point. If I pick a point on the whole sphere there is a possibility that I can repeat the pairs as I will sample large number of points say 100,000 pair of points on the sphere. So if I pick 100,000 points on one half of the points I automatically get same number of points on the other side. Don't you think this way of sampling is better? – Arpan Das Feb 15 '17 at 14:08
-
2@ArpanDas you might get repeated pairs even if you pick only from one hemisphere. With 100000 pairs, you'll probably get close to 100000 points on each hemisphere automatically. Also, what happens at the equator? I think with your method, you'll either get no point or twice as many points as on other great circles. – Eric Duminil Feb 15 '17 at 14:13
-
@EricDuminil So the best method should be sampling random points from the whole sphere and just put a if statement on the code to eliminate any repeated pairs. What do you think? – Arpan Das Feb 15 '17 at 14:28
-
1You could also use a set of coordinates. We're talking about `(float,float)` pairs here. You very probably won't get any collision as long as you don't snap those points to a regular grid. – Eric Duminil Feb 15 '17 at 14:53