Minimum two multiplied straight line fit

zhaozj2021-02-08  223

// Minimum two multiplied linear fit BOOL CalculateLinekb (cfoldpointlist * m_foldlist, double & k, double & b) {// minimum number of lines of linear fitting // m_foldlist is a chain list // fitted straight line equation for key points (Y) Y = kx b)

IF (m_foldlist == null) Return False; long lcount = m_foldlist-> getCount (); if (lcount <2) return false; cfoldpoint * pfold; double mx, my, mxx, mxy, n; mx = my = mxx = MXY = 0; n = lcount; position pos = m_foldlist-> getHeadPosition (); while (pOS! = null) {pfold = m_foldlist-> getnext (pOS); mx = pfold-> x; my = pfold-> y; MXX = pfold-> x * pfold-> x; mxy = pfold-> x * pfold-> y;} if (mx * mx-mxx * n == 0) Return False; k = (My * MX-MXY * n) / (mx * mx-mxx * n); b = (my-mx * k) / n; return true;}

转载请注明原文地址:https://www.9cbs.com/read-2278.html

New Post(0)