Finding the center of a series of points on the surface of a sphere

56 Views Asked by At

I have a series of points on a unit sphere that are given in azimuth, elevation coordinates, where azimuth has a domain of -180 < azimuth <= 180 degrees, and elevation has a domain of -90 <= elevation <= 90 degrees. These points are

(90, 75) (180, 75) (0, 75) (-90, 75)

For the center, intuitively I know that the azimuth does not matter, and the elevation would be 90 degrees. How would I calculate this mathematically? I have other situations like this and often with more than 4 points that would not be symmetrical, and would not have a center at 90 degrees.

1

There are 1 best solutions below

0
On BEST ANSWER

Ok, figured it out. Yes, finding the centroid is easier using (x, y, z) coordinates of each point, but you have to account for azimuth wrap-around first. And yes, the center in this case needs to be on the surface of the unit sphere.

The sphere needs to be broken into two hemispheres, with the azimuth domain edge as a side and the azimuth line at 0 degrees as the other half.

I have some pseudocode below:

For each point (a, e), 
if a < 0,
  a_{Lo} = a_{Lo} + a
  aLocounter = aLocounter + 1
else
  a_{Hi} = a_{Hi} + a
  aHicounter = aHicounter + 1

if aLocounter != 0, a_{Lo} = a_{Lo} / aLocounter
if aHicounter != 0, a_{Hi} = a_{Hi} / aHicounter
//if the difference between the mean of the high and low points are more than 180
//degrees, then the average will be skewed. (179 and -179 average to 0, when they
//should average to 180) We can fix this by adding 360 degrees.
if a_{Hi} - a_{Lo} > 180,
   for each point (a, e)
   if a < 0,
      a = a + 360
    
for each point (a, e)
   convert a and e to radians
   x = x + cos(e) * cos(a)
   y = y + cos(e) * sin(a)
   z = z + sin(e)

[x, y, z] = [x, y, z] / (aLocounter + aHicounter) 

//Take projection
[xp, yp, zp] = [x, y, z] / sqrt(x^2 + y^2 + z^2)
centrala = atan2(yp,  xp)
centrale = atan2(zp, sqrt(xp^2 + yp^2))
convert centrala and centrale to degrees

if centrala > 180
   centrala = centrala - 360

return {centrala, centrale}