title: Uniform scaling on array of point around average point c++
body: <p>What I am trying to do:</p>
  
  <p><strong>1. scale uniformly an array of points around a point.
  2. A point has to be an average point of array of points.</strong></p>
  
  <p>The code below, seems to work, but I do not know if it is the proper way of doing that.</p>
  
  <p>I know that uniform scaling is simply multiplying points by some value, but this is scaling on 0,0,0 point, how to do it around mean point?</p>
  
  <p>The code could be subdivided by following steps:</p>
  
  <ol>
  <li>Get the average point of the array of points, by summing up all positions and dividing by a number of points.</li>
  <li>Ratio is scaling value</li>
  <li>Then I do vector subtraction to get a vector pointing from point to average point.</li>
  <li>I normalize that vector (I get unit vector)</li>
  <li>Then I add that normalized vector to current point multiplied by (1 - ratio)*0.5</li>
  </ol>
  
  <p>This last bit 5th point came totally from checking total length of the value.</p>
  
  <p>All examples I came up before was using matrices in math, and I really not capable of reading matrix operations. </p>
  
  <p>Is it the correct uniform scaling method, if it's not could you point out what I am doing wrong?</p>
  
  <pre><code>    //Get center of a curve 
      //That is average of all points
  
  
      MatMxN curveCenter = MatMxN::Zero(2, 1); //This is just 1 vector/point with x and y coordinates
  
      for (int i = 0; i &lt; n; i++)
          curveCenter += points.col(i);
  
      curveCenter /= n;
  
      //Scaling value
      float ratio = 1.3;
  
     //Get vector pointing to center  and move by ratio
      for (int i = 0; i &lt; n; i++) {
          MatMxN vector = curveCenter - points.col(i);
          MatMxN unit = vector.normalized();
          points.col(i) += unit*(1 - ratio)*0.5; //points.col(i) this is point in array
      }
  </code></pre>