title: c++ change of coordinates (Pixels 1920 x 1080 to 640 x 480)
body: <p>I am developing a small program that can draw a rectangle in different videos modes (for example 1920 x 1080 -> 640 x 480). I can resize a rectangle. But I am getting stuck, because I cannot find a clear method to achieve the problem. I am currently trying to create a matrix to perform a scale operation over the pixels but I cannot get the right answer. Part of the problem seems to be that <code>TransformMatrix::transform</code> is not scaling correctly.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  typedef struct _Pixel
  {
        _Pixel():X(1920)
        ,Y(1080)
        {}
        unsigned X;
        unsigned Y;
  }Pixel;
  
      typedef struct TransformMatrix
      {
        constexpr TransformMatrix(const float aWeigth = 0.3f
                                  ,const float aHeigth = 0.225f):W(aWeigth)
        ,H(aHeigth)
        {}
        void transform( const Pixel &amp; aPixel)
        {
          auto x_value=static_cast&lt;float&gt;(aPixel.X)*W;
          auto y_value=static_cast&lt;float&gt;(aPixel.Y)*H;
  
          std::cout&lt;&lt;"x_value: "&lt;&lt;x_value&lt;&lt;std::endl;
          std::cout&lt;&lt;"y_value: "&lt;&lt;y_value&lt;&lt;std::endl;
  
        }
        const float W;
        const float H;
  
      }TransformMatrix;
  
      int main()
      {
        Pixel aPixel;
        TransformMatrix _TransformMatrix;
        _TransformMatrix.transform(aPixel);
        return 0;
      }
  </code></pre>
  
  <p>The actual result:</p>
  
  <blockquote>
    <p>x_value: 576<br>
    y_value: 243</p>
  </blockquote>
  
  <p>The expected result:</p>
  
  <blockquote>
    <p>x_value: 640<br>
    y_value: 480</p>
  </blockquote>
  
  <p>How can I perform the right operation? Is it just a change of basis?
  Should I scale only or also do a transformation operation?</p>