title: Algorithm for smoothing
body: <p>I wrote this code for smoothing of a curve .
  It takes 5 points next to a point and adds them and averages it .</p>
  
  <pre><code>/* Smoothing */
  void smoothing(vector&lt;Point2D&gt; &amp;a)
  {
      //How many neighbours to smooth
      int NO_OF_NEIGHBOURS=10;
      vector&lt;Point2D&gt; tmp=a;
      for(int i=0;i&lt;a.size();i++)
      {
  
          if(i+NO_OF_NEIGHBOURS+1&lt;a.size())
          {
              for(int j=1;j&lt;NO_OF_NEIGHBOURS;j++)
              {
                  a.at(i).x+=a.at(i+j).x;
                  a.at(i).y+=a.at(i+j).y;
              }
              a.at(i).x/=NO_OF_NEIGHBOURS;
              a.at(i).y/=NO_OF_NEIGHBOURS;
  
          }
          else
          {
              for(int j=1;j&lt;NO_OF_NEIGHBOURS;j++)
              {
                  a.at(i).x+=tmp.at(i-j).x;
                  a.at(i).y+=tmp.at(i-j).y;
              }
              a.at(i).x/=NO_OF_NEIGHBOURS;
              a.at(i).y/=NO_OF_NEIGHBOURS;
          }
  
      }
  
  }
  </code></pre>
  
  <p>But i get very high values for each point, instead of the similar values to the previous point . The shape is maximized a lot , what is going wrong in this algorithm ?</p>