title: C++: How can I do zoom like Google Maps?
body: <p>I'm programming in the Windows API using C++. For this program, I'm using the Traslating and Scaling 3D MATRIX, and also I'm using the WM_MOUSEWHEEL event. This is a part of the code:</p>
  
  <pre><code>case WM_MOUSEWHEEL:
      xPos = GET_X_LPARAM(lParam);
      yPos = GET_Y_LPARAM(lParam);
      rotw = GET_WHEEL_DELTA_WPARAM(wParam);
      if (rotw &gt; 0)
          zoom += 0.05f;
      else
          zoom -= 0.05f;
      InvalidateRect(hWnd, NULL, false);
      break;
  </code></pre>
  
  <p>For the implementation, I'm using this:</p>
  
  <pre><code>Translation(xPos,yPos)*Scaling(zoom, zoom)
  </code></pre>
  
  <p>But the problem is that the zoom isn't correct, because it 'jumps' from one point to other, making confusing and difficult to do zoom in a certain point.
  I was reading something about calculate the new X and Y point with the new X and Y point and use a zoom factor (I guess my zoom factor is the variable 'zoom').</p>
  
  <p><a href="https://i.stack.imgur.com/5h8IG.png" rel="nofollow noreferrer">This is the main window, with a random picture. I put the pointer in the mustache and apply zoom with the mouse wheel...</a></p>
  
  <p><a href="https://i.stack.imgur.com/XPmSD.png" rel="nofollow noreferrer">But after I did the zoom, this happends. The zoom wasn't made in the place that I wanted!!!</a></p>
  
  <p>Can you help me? </p>
  
  <p>Thanks a lot!</p>