The main topic: There are n points on the plane, to draw a circle with the smallest radius, covering all the point accuracy 0.1 points of coordinates up to 100000
Method 1:http://wenku.baidu.com/view/584b6d3e5727a5e9856a610d.html O (n)
Method 2: Three-part set of three-point violence is solved as follows. O (n) time overhead 1600~ (log 2/3 0.1/100000) ^2
1 floatDisy (floatYfloatx)2 {3 intn=pvec.size ();4 floatrmin=0;5 6 for(intI=0; i<n;i++)7 {8Rmin=max (RMIN,SQRT (pvec[i].y-y) * (pvec[i].y-y) + (pvec[i].x-x) * (pvec[i].x-x ));9 }Ten returnRmin; One } A floatDisfloatx) - { -ymax=10000, ymin=0; the while(ymax-ymin>accu) - { - if(Disy (ymin+ (ymax-ymin) *2.0/3, x) <disy (ymin+ (ymax-ymin) *1.0/3, x)) - { +ymin=ymin+ (ymax-ymin) *1.0/3; - } + Else Aymax=ymin+ (ymax-ymin) *2.0/3; at } - returnDisy ((ymax+ymin)/2, x); - } - intFindcenter (Point &Pstart) - { -xmax=0, xmin=10000; in intn=pvec.size (); - for(intI=0; i<n;i++) to { +xmax=Max (xmax,pvec[i].x); -xmin=min (xmin,pvec[i].x); the } * while((xmax-xmin)/2>accu) $ {Panax Notoginseng if(Dis (xmin+ (xmax-xmin) *1.0/3) <dis (xmin+ (xmax-xmin) *2.0/3)) - { thexmax=xmin+ (xmax-xmin) *2.0/3; + } A Else thexmin=xmin+ (xmax-xmin) *1.0/3; + } -pstart.x= (xmax+xmin)/2; $pstart.y= (ymax+ymin)/2; $ intR=disy ((ymax+ymin)/2, (xmax+xmin)/2); - returnR; -}
Patronize to use what new method is better, the result did not think the best method ...
Minimum circle minimum Circle overlay covering all points