Hi!
Whenever I need to use a math lib in C, I use the GNU Scientific
Library (GSL):
http://www.gnu.org/software/gsl/
However, no idea if it contains what you need...
cheers, Severin
got it from a PHP script.. translated into Ruby...
def deg2rad(d)
(d/180.0)*Math:

I
end
def rad2deg(r)
(r/Math:

I)*180
end
def self.gravity_center(placemarks)
sumx = 0.0
sumy = 0.0
sumz = 0.0
for placemark in placemarks do
# convert to radians
lat = deg2rad(placemark[0])
lon = deg2rad(placemark[1])
# convert spherical coordinate into cartesian
x = Math::cos(lat) * Math::sin(lon)
y = Math::cos(lat) * Math::cos(lon)
z = Math::sin(lat)
# sum the vectors
sumx += x
sumy += y
sumz += z
end
# convert cartesian coordinate back to spherical
meanz = sumz / placemarks.nitems
lon = rad2deg(Math::atan2(sumx, sumy))
meanx = sumx / placemarks.nitems
meany = sumy / placemarks.nitems
lat = rad2deg(Math::atan(meanz / Math::sqrt(meanx**2 + meany**2)))
return [lat, lon]
end