/* float leastSquareMatrix[10][500] = { -0.023522, -0.013986, -0.006569, -0.001271, 0.001907, 0.002967, 0.001907, -0.001271, -0.006569, -0.013986, -0.023522, -0.013986, -0.004450, 0.002967, 0.008264, 0.011443, 0.012503, 0.011443, 0.008264, 0.002967, -0.004450, -0.013986, -0.006569, 0.002967, 0.010384, 0.015681, 0.018860, 0.019919, 0.018860, 0.015681, 0.010384, 0.002967, -0.006569, -0.001271, 0.008264, 0.015681, 0.020979, 0.024158, 0.025217, 0.024158, 0.020979, 0.015681, 0.008264, -0.001271, 0.001907, 0.011443, 0.018860, 0.024158, 0.027336, 0.028396, 0.027336, 0.024158, 0.018860, 0.011443, 0.001907, 0.002967, 0.012503, 0.019919, 0.025217, 0.028396, 0.029455, 0.028396, 0.025217, 0.019919, 0.012503, 0.002967, 0.001907, 0.011443, 0.018860, 0.024158, 0.027336, 0.028396, 0.027336, 0.024158, 0.018860, 0.011443, 0.001907, -0.001271, 0.008264, 0.015681, 0.020979, 0.024158, 0.025217, 0.024158, 0.020979, 0.015681, 0.008264, -0.001271, -0.006569, 0.002967, 0.010384, 0.015681, 0.018860, 0.019919, 0.018860, 0.015681, 0.010384, 0.002967, -0.006569, -0.013986, -0.004450, 0.002967, 0.008264, 0.011443, 0.012503, 0.011443, 0.008264, 0.002967, -0.004450, -0.013986, -0.023522, -0.013986, -0.006569, -0.001271, 0.001907, 0.002967, 0.001907, -0.001271, -0.006569, -0.013986, -0.023522, -0.001033, -0.000826, -0.000620, -0.000413, -0.000207, 0.000000, 0.000207, 0.000413, 0.000620, 0.000826, 0.001033, -0.000826, -0.000661, -0.000496, -0.000331, -0.000165, 0.000000, 0.000165, 0.000331, 0.000496, 0.000661, 0.000826, -0.000620, -0.000496, -0.000372, -0.000248, -0.000124, 0.000000, 0.000124, 0.000248, 0.000372, 0.000496, 0.000620, -0.000413, -0.000331, -0.000248, -0.000165, -0.000083, 0.000000, 0.000083, 0.000165, 0.000248, 0.000331, 0.000413, -0.000207, -0.000165, -0.000124, -0.000083, -0.000041, 0.000000, 0.000041, 0.000083, 0.000124, 0.000165, 0.000207, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000207, 0.000165, 0.000124, 0.000083, 0.000041, 0.000000, -0.000041, -0.000083, -0.000124, -0.000165, -0.000207, 0.000413, 0.000331, 0.000248, 0.000165, 0.000083, 0.000000, -0.000083, -0.000165, -0.000248, -0.000331, -0.000413, 0.000620, 0.000496, 0.000372, 0.000248, 0.000124, 0.000000, -0.000124, -0.000248, -0.000372, -0.000496, -0.000620, 0.000826, 0.000661, 0.000496, 0.000331, 0.000165, 0.000000, -0.000165, -0.000331, -0.000496, -0.000661, -0.000826, 0.001033, 0.000826, 0.000620, 0.000413, 0.000207, 0.000000, -0.000207, -0.000413, -0.000620, -0.000826, -0.001033, 0.000795, 0.000556, 0.000371, 0.000238, 0.000159, 0.000132, 0.000159, 0.000238, 0.000371, 0.000556, 0.000795, 0.000556, 0.000318, 0.000132, 0.000000, -0.000079, -0.000106, -0.000079, 0.000000, 0.000132, 0.000318, 0.000556, 0.000371, 0.000132, -0.000053, -0.000185, -0.000265, -0.000291, -0.000265, -0.000185, -0.000053, 0.000132, 0.000371, 0.000238, 0.000000, -0.000185, -0.000318, -0.000397, -0.000424, -0.000397, -0.000318, -0.000185, 0.000000, 0.000238, 0.000159, -0.000079, -0.000265, -0.000397, -0.000477, -0.000503, -0.000477, -0.000397, -0.000265, -0.000079, 0.000159, 0.000132, -0.000106, -0.000291, -0.000424, -0.000503, -0.000530, -0.000503, -0.000424, -0.000291, -0.000106, 0.000132, 0.000159, -0.000079, -0.000265, -0.000397, -0.000477, -0.000503, -0.000477, -0.000397, -0.000265, -0.000079, 0.000159, 0.000238, 0.000000, -0.000185, -0.000318, -0.000397, -0.000424, -0.000397, -0.000318, -0.000185, 0.000000, 0.000238, 0.000371, 0.000132, -0.000053, -0.000185, -0.000265, -0.000291, -0.000265, -0.000185, -0.000053, 0.000132, 0.000371, 0.000556, 0.000318, 0.000132, 0.000000, -0.000079, -0.000106, -0.000079, 0.000000, 0.000132, 0.000318, 0.000556, 0.000795, 0.000556, 0.000371, 0.000238, 0.000159, 0.000132, 0.000159, 0.000238, 0.000371, 0.000556, 0.000795, 0.000000, 0.000477, 0.000848, 0.001113, 0.001271, 0.001324, 0.001271, 0.001113, 0.000848, 0.000477, 0.000000, -0.000477, 0.000000, 0.000371, 0.000636, 0.000795, 0.000848, 0.000795, 0.000636, 0.000371, 0.000000, -0.000477, -0.000848, -0.000371, 0.000000, 0.000265, 0.000424, 0.000477, 0.000424, 0.000265, 0.000000, -0.000371, -0.000848, -0.001113, -0.000636, -0.000265, 0.000000, 0.000159, 0.000212, 0.000159, 0.000000, -0.000265, -0.000636, -0.001113, -0.001271, -0.000795, -0.000424, -0.000159, 0.000000, 0.000053, 0.000000, -0.000159, -0.000424, -0.000795, -0.001271, -0.001324, -0.000848, -0.000477, -0.000212, -0.000053, 0.000000, -0.000053, -0.000212, -0.000477, -0.000848, -0.001324, -0.001271, -0.000795, -0.000424, -0.000159, 0.000000, 0.000053, 0.000000, -0.000159, -0.000424, -0.000795, -0.001271, -0.001113, -0.000636, -0.000265, 0.000000, 0.000159, 0.000212, 0.000159, 0.000000, -0.000265, -0.000636, -0.001113, -0.000848, -0.000371, 0.000000, 0.000265, 0.000424, 0.000477, 0.000424, 0.000265, 0.000000, -0.000371, -0.000848, -0.000477, 0.000000, 0.000371, 0.000636, 0.000795, 0.000848, 0.000795, 0.000636, 0.000371, 0.000000, -0.000477, 0.000000, 0.000477, 0.000848, 0.001113, 0.001271, 0.001324, 0.001271, 0.001113, 0.000848, 0.000477, 0.000000 }; */ class InverseFns { public: // transepose matrix¸¦ ±¸ÇÏ°í ±× Çà·ÄÀ» TrMatrix ¿¡ ³Ö´Â ÇÔ¼ö..... //row : Çà column: ¿­... void TranseposeMatrix(float** Matrix , float** TrMatrix , int row , int column); // ÀÓÀÇÀÇ µÎ Çà·ÄÀ» °öÇÏ°í ¼¼¹øÂ° Çà·Ä¿¡ ³Ö´Â ÇÔ¼ö....... // ¾Õ Çà ¿­ µÚ ¿­.... void MultiplyMatrixAB(float** MatrixA , float** MatrixB , float** MatrixAB , int row , int column , int bcolumn); // inverse matrix¸¦ ±¸ÇÏ´Â ÇÔ¼ö.... nSize : Â÷¼ö¸¦ ¸»ÇÑ´Ù.... int CalculatingInverseMatrix(float** Matrix , int nSize , float** InverseMatrix); }; class LeastSquareFns { public: InverseFns invFnsClass; //******************************************************************************************************************************************************************************** // Least square regression À¸·Î fitting ÇÏ´Â µ¥ ÇÊ¿äÇÑ ÇÔ¼öµé.... //******************************************************************************************************************************************************************************** //coeff = (Tr(zMatrix)*zMatrix)ÀÇ ¿ªÇà·Ä*Tr(zMatrix)*Y(½ÇÁ¦ µ¥ÀÌÅÍÀÇ y °ª.. ¿©±â¼± z °ªÀÌ µÈ´Ù... ) //½ÇÁ¦·Î coeffcient ¸¦ ±¸ÇÏ´Â ÇÔ¼ö.... void MultiplyMatrixAzThreeD(float** MatrixA , float* zThreeD , float aCoeff[] , int mDegree , int dataSize); // ³Ö¾îÁØ °ªÀ» nTimes ¸¸Å­ °öÇÏ´Â ÇÔ¼ö..... float GetNTimesValue(float value , int nTimes); //Least square·Î polynomial fitting ÇÏ´Â ÇÔ¼ö... fitting ÀÌ ¾ÈµÇ¸é 1À» µÇ¸é 0À» ¸®ÅÏÇÑ´Ù... //0 ºÎÅÍ ½ÃÀÛÇØ¼­ Â÷¼ö +1 ¸¸Å­ ¸Þ¸ð¸®¸¦ Àâ¾Ò´Ù.... // a0 + a1*x + a2*x*x + ..... int GetRegressionCoeffInPoly(float* xPoint , float* yPoint , float aCoeff[] , int mDegree , int nSize); // polynomial fitting ÈÄ ±× ÇÔ¼öÀÇ y°ªÀ» ¾Ë¾Æ³»´Â ÇÔ¼ö... float GetRegressionFnValue(float aCoeff[] ,float xValue , int mDegree); //Least square·Î Æò¸éÀ¸·Î fitting ÇÏ´Â ÇÔ¼ö... fitting ÀÌ ¾ÈµÇ¸é 1À» µÇ¸é 0À» ¸®ÅÏÇÑ´Ù... //0 ºÎÅÍ ½ÃÀÛÇϹǷΠÂ÷¼ö +1 ¸¸Å­ ¸Þ¸ð¸®¸¦ Àâ¾Ò´Ù.... // z = ax + by + c ÇüÅÂÀÇ Æò¸éÀÌ´Ù... int GetRegressionCoeffInPlane(float* xPoint , float* yPoint , float* zPoint, float aCoeff[] , int nSize); int GetRegressionCoeffInZernikePoly( float* xPoint , float* yPoint , float* zPoint, float aCoeff[] , int nSize ); int GetRegressionCoeffInZernikePoly( float* xPoint , float* yPoint , int nSize); //(x*x + y*y + ax + by + c)^2ÀÇ ÇÕÀ» ÃÖ¼Ò·ÎÇÏ´Â a, b, c °ªÀ» ±¸Çϰí Á߽ɰú ¹ÝÁö¸§À» ±¸ÇÔ... int GetRegressionCoeffInCircleFitting(float* xPoint, float* yPoint, int dataNum, float *cx, float *cy, float *radius); };