title: How to calculate gravitation center of a planar distribution?
body: <p>I have a 2D distribution of a data set, and I would like to find its gravitation center of these points.</p>
  
  <p>What I would like to do is like the code below,</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  #define SIZE 4
  
  struct point {
   short x;
   short y;
  };
  
  point find_gravitation(struct point set[], unsigned char size)
  {
    point ret;
    .
    .
    .
    ?
    .
    .
    .
    return ret;
  }
  
  int
  main(int argc, char **argv)
  {
   struct point dataset[SIZE];
   struct point ret;
  
   dataset[0].x = 12;
   dataset[0].y = 24;
  
   dataset[1].x = 3;
   dataset[1].y = 5;
  
   dataset[2].x = 71;
   dataset[2].y = -6;
  
   dataset[3].x = -185;
   dataset[3].y = -26;
  
   ret = find_gravitation(dataset, SIZE);
  
   printf("gravitation center is: %d, %d\n", ret.x, ret.y);
  
   return 0;
  }
  </code></pre>
  
  <p>How can I calculate the gravitation center of this set?</p>