本帖最后由 王三国 于 2017-10-26 23:00 编辑
开源代码网址是https://www.codeproject.com/Arti ... -circle-and-ellipse
示例程序
#include <iostream>
#include <sstream>
#include "BestFit.h"
int main(int argc, char * argv[])
{
int count = 10;
double points[20] = {
99.9510022,201.01559,
100.0701559,199.016258,
100.921381,200.0685969,
99.031849,199.895546,
99.469357,200.869111,
100.525856,200.793908,
99.13055,200.56031,
100.787632,199.483885,
100.498142,199.169206,
99.363449,199.276086
};
// Input settings specify the source coordinates.
BestFitIO input;
input.numPoints = count;
input.points = points;
// Output settings in this simple example left with default values.
BestFitIO output;
// Create the best-fitting circle object, and make it do the work.
int type = BestFitFactory::Circle;
BestFit *b = BestFitFactory::Create(type, std::cout);
b->Compute(input, output);
... // output contains solved parameters, and optionally the adjusted points.
// The factory allocated memory needs to be freed.
delete b;
return 0;
}
|