title: Transform points between two screens
body: <p>I have a large collection of points that I want to transform from one screen/monitor to another in a script.</p>
  
  <p>Screen A - 2880x1800 resolution<br>
  Screen B - 1280x1024 resolution</p>
  
  <p><a href="https://i.stack.imgur.com/QmsRq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QmsRq.png" alt="enter image description here"></a></p>
  
  <p>• Black box: screen/monitor.<br>
  • Green box: portion of the screen where all points will be transformed from C(a) to C(b).</p>
  
  <p>The green box is a video feed with an aspect ratio of 16:9 on both screens. I'm not actually sure this green box matters but I included it to show what I'm trying to do.</p>
  
  <p>So far I've tried to follow <a href="https://stackoverflow.com/a/20539498/869936">this post</a>, which seems to work fine for transforming x values:</p>
  
  <pre><code>Rectangle Old
  NW coordinate - (X0_Old, Y0_Old)
  SE coordinate - (X1_Old, Y1_Old)
  
  Rectangle New
  NW coordinate - (X0_New, Y0_New)
  SE coordinate - (X1_New, Y1_New)
  
  X_New = X0_New + (X_Old - X0_Old) * X_Coeff
  X_New =   0    + (X_Old -   0   ) * X_Coeff
    where 
      X_Coeff = (X1_New - X0_New) / (X1_Old - X0_Old)
      X_Coeff = (1280   -   0   ) / (2880   -   0   )
  
  X_New = (X_Old)*(1280/2880)
  </code></pre>
  
  <p>That <code>X_New</code> wasn't perfect, but for some reason this one was:<br>
  <code>X_New = 2*(X_Old)*(1280/2880)</code></p>
  
  <p>Maybe this was due to some kind of scaling? The x coordinates were working so I didn't question it and moved on.  </p>
  
  <p>My problem came when I tried to transform the Y coordinates:</p>
  
  <pre><code>Y_New = Y0_New + (Y_Old - Y0_Old) * Y_Coeff
  Y_Coeff = (Y1_New - Y0_New) / (Y1_Old - Y0_Old)
  
  Y_New = Y0_New + (Y_Old - Y0_Old) * Y_Coeff
  Y_New =    0   + (Y_Old -   136 ) * Y_Coeff
    where
      Y_Coeff = (Y1_New - Y0_New) / (Y1_Old - Y0_Old)
      Y_Coeff = (  720  -   174 ) / (1620   -   136)
      Y_Coeff = 546/1484
  
  Y_New = (Y_Old - 136) * (546/1484)
  </code></pre>
  
  <p>Y values calculated with <code>Y_New</code> are definitely much too low to be correct. What's the right way to calculate <code>Y_New</code>?</p>