daily pastebin goal
12%
SHARE
TWEET

KalEl

a guest Sep 22nd, 2011 53 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1.         public Point2D.Double getGeoMedian(Point2D.Double start) {
  2.                 double cx=start.x, cy=start.y;
  3.                 double lastcx,lastcy;
  4.                 int cnt=0;
  5.                 do {
  6.                         lastcx=cx;lastcy=cy;
  7.                         cx=0; cy=0;
  8.                         double totalWeight=0;
  9.                         for (int i=0; i<points.size(); ++i) {
  10.                                 Point2D.Double pt=(Point2D.Double)points.get(i);
  11.                                 double weight=1/pt.distance(lastcx,lastcy);
  12.                                 cx+=pt.x*weight; cy+=pt.y*weight;
  13.                                 totalWeight+=weight;
  14.                         }
  15.                         cx/=totalWeight; cy/=totalWeight;
  16.                 } while ((Math.abs(cx-lastcx)>.5 || Math.abs(cy-lastcy)>.5) && cnt++<2500);
  17.                 return new Point2D.Double(cx,cy);
  18.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top