/* SurfaceEllipsoid.c Surface d'un Ellipsoïde Jeux et Mathématiques 11/02/2012 licence GCC gcc -o surfell SurfaceEllipsoid.c -lgsl -lblas -lm surfell 5 3 2 */ /* extrait de la manpage de la librairie gsl : DESCRIPTION The GNU Scientific Library (GSL) is a collection of routines for numerical computing. The routines are written from scratch by the GSL team in C, and present a modern Applications Programming Interface (API) for C programmers, allowing wrappers to be written for very high level languages. The library covers the following areas, Complex Numbers Roots of Polynomials Special Functions Vectors and Matrices Permutations Combinations Sorting BLAS Support Linear Algebra Eigensystems Fast Fourier Transforms Quadrature Random Numbers Quasi-Random Sequences Random Distributions Statistics Histograms N-Tuples Monte Carlo Integration Simulated Annealing Differential Equations Interpolation Numerical Differentiation Chebyshev Approximations Series Acceleration Discrete Hankel Transforms Root-Finding Minimization Least-Squares Fitting Physical Constants IEEE Floating-Point For more information please consult the GSL Reference Manual, which is available as an info file. You can read it online using the shell command info gsl-ref (if the library is installed). */ #include #include #include #include #define PREC GSL_PREC_SINGLE //GSL_PREC_APPROX double surface(double u, double v, double w) { if(u==v && v==w) { return 4*M_PI*u*u; } double a=u, b=v, c=w, d; if(b>a) { d=b,b=a,a=d; } if(c>a) { d=c,c=b,b=a,a=d; } else if(c>b) { d=c,c=b,b=d; } double cos2phi = c*c/(a*a), sin2phi=1-cos2phi, ph = acos(c/a), k = sqrt(a*a*(b*b-c*c)/(b*b*(a*a-c*c))); return 2*M_PI*(c*c+a*b/sin(ph)*(gsl_sf_ellint_E(ph,k,PREC)*sin2phi+gsl_sf_ellint_F(ph,k,PREC)*cos2phi)); } int main (int argc,char *argv[]) { if(argc<4) { printf("usage : %s a b c\n",argv[0]); return 0; } double a = atof(argv[1]), b = atof(argv[2]), c = atof(argv[3]); printf("%f\n",surface(a,b,c)); return 0; }