/** Linear fitting of circles to a set of 2D points Idea based in papers: V. Pratt. Direct least-squares fitting of algebraic surfaces ACM SIGGRAPH Computer Graphics, (21) 4, 1987, pp. 145 - 152 A. Fitzgibbon, M. Pilu, and R.B. Fisher, Direct least square fitting of ellipses IEEE Trans, of Pattern Anal. & Mach. Intell. (21) 5, 1999, pp. 476-480 **/ #include #include #include "f2c.h" #include "clapack.h" /** Compile with command line: gcc -O2 algeb_fit.c -o algeb_fit lapack_LINUX.a libF77.a blas_LINUX.a -lm gcc -O2 algeb_fit.c -o algeb_fit -L/opt/local/lib -lapack -lF77 -lblas -lm **/ #define M 4 int main( int argc, char *argv[] ) { int i,j; char namein[64]; double px, py; double a, d, e, f; double x0, y0, r; FILE *file; //////////////////////////////////////// /** Parametros para la función dggev **/ char JOBVL = 'N'; char JOBVR = 'V'; int N = M; int LDA = M; int LDB = M; int LDVL = 1; int LDVR = M; int LWORK=156; int INFO; double S[M*M], Z[M*M]; double alphar[M]; double alphai[M]; double beta[M]; double vl[LDVL*M]; double vr[LDVR*M]; double wk[LWORK]; // double wk; double C[M*M]={ 0.0, 0.0, 0.0, -2.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -2.0, 0.0, 0.0, 0.0}; //////////////////////////////////////////// if ( argc != 2 ) { fprintf( stderr, "Args: file_name\n" ); exit(1); } strncpy( namein, argv[1], 64 ); if ( (file = fopen (namein,"r") ) == NULL ) { fprintf( stderr, "Can't open %s file\n", file ); exit(1); } for( i=0; i