/* polyfit.h Written by Volodymyr Kindratenko (kindr@ncsa.uiuc.edu) NCSA, March - April 1999 ver. 1.00 (5/5/99) - first public release libTrCalibr & dvCalibrator software copyright Copyright 1999 The Board of Trustees of the University of Illinois All rights reserved libTrCalibr & dvCalibrator software Volodymyr Kindratenko Visualization and Virtual Environments group National Center for Supercomputing Applications University of Illinois at Urbana-Champaign libTrCalibr & dvCalibrator software [both binary and source (if released)] (hereafter, Software) is copyrighted by The Board of Trustees of the University of Illinois (UI), and ownership remains with the UI. The UI grants you (hereafter, Licensee) a license to use the Software for academic, research and internal business purposes only, without a fee. Licensee may distribute the binary and source code (if released) to third parties provided that the copyright notice and this statement appears on all copies and that no charge is associated with such copies. Licensee may make derivative works. However, if Licensee distributes any derivative work based on or derived from the Software, then Licensee will (1) notify Volodymyr Kindratenko [kindr@ncsa.uiuc.edu], regarding its distribution of the derivative work, and (2) clearly notify users that such derivative work is a modified version and not the original Software distributed by the UI. Any Licensee wishing to make commercial use of the Software should contact the UI, c/o Research and Technology Management Office [rtmo@uiuc.edu], to negotiate an appropriate license for such commercial use. Commercial use includes (1) integration of all or part of the source code into a product for sale or license by or on behalf of Licensee to third parties, or (2) distribution of the binary code or source code to third parties that need it to utilize a commercial product sold or licensed by or on behalf of Licensee. UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USERS OF THIS SOFTWARE. By using or copying this Software, Licensee agrees to abide by the copyright i law and all other applicable laws of the U.S. including, but not limited to, export control laws, and the terms of this license. UI shall have the right to terminate this license immediately by written notice upon Licensee's breach of, or non-compliance with, any of its terms. Licensee may be held legally responsible for any copyright infringement that is caused or encouraged by Licensee's failure to abide by the terms of this license. Form approved by University Counsel, M.A.R., 05/10/93 */ #ifndef _POLYFIT_H_ #define _POLYFIT_H_ #ifdef __cplusplus extern "C" { #endif #define ABS(x) (x < 0 ? -(x) : (x)) #define EPS 0.000001f /* structure used to store fitting polynomials ... + ( a[i] * x^px[i] * x^py[i] * z^pz[i] ) + ... */ struct fpolynomials { int N; /* number of terms in the polynomials */ int *px; /* x power term */ int *py; /* y power term */ int *pz; /* z power term */ double *cx; /* coefficients for x polynomial */ double *cy; /* coefficients for y polynomial */ double *cz; /* coefficients for z polynomial */ double *ca; /* coefficients for az polynomial */ double *ce; /* coefficients for el polynomial */ double *cr; /* coefficients for rl polynomial */ }; /* builds all terms of the polynominal for all variables - porder is the order of the polynomial to bu built - cdata is the data from the calibration file loaded by readcalibfile - fpol is a pointer to struct fpolynomials; the pointer must exist, but the memory needed to store the polynomial coefficients, etc. will be allocated by the function returns 0 if failed, 1 otherwise */ int fit_initialize(struct calibdata *cdata, int porder, struct fpolynomials *fpol); /* once the fitting polynomials are build, this function can be used to evaluate them to obtain fitted values for measured values - xm, ym, zm, azm, elm, & rlm are the measured values - xf, yf, zf, azf, elf, & rlf are the computed fitted values - fpol is what was created by buildpolynomials function */ void fit_evaluate(struct fpolynomials *fpol, float xm, float ym, float zm, float azm, float elm, float rlm, float *xf, float *yf, float *zf, float *azf, float *elf, float *rlf); /* runs the calibration file through the computed calibration polynomials and computes mean, errors, etc. Results are stored in the file fname. - cdata is what was loaded by readcalibfile function - fpol is what was computed by buildpolynomials function */ void fit_statistics(struct calibdata *cdata, struct fpolynomials *fpol, char *fname); #ifdef __cplusplus } #endif #endif