title: convert cartesian coordinate to picturebox coordinates c#
body: <p>The question I have is more of mathematics! I have some pair of values that reperesent points of a curve that I want to draw on a picturebox using fromImage(Bitmap). My picture box is sized at 500x500. I also know that the top-left corner has point of (0,0) and bottom right corner has points of (500,500). Obviously the origin should be (250,250). Now I am wondering how can I convert my own values to this format? </p>
  
  <p>A sample points that I have are like:</p>
  
  <pre><code>Voltage: -0.175         Current: -9.930625E-06
  Voltage: -0.171875      Current: -9.53375E-06
  Voltage: -0.16875       Current: -9.136875E-06
  Voltage: -0.16875       Current: -8.74E-06
  Voltage: -0.165625      Current: -8.343125E-06
  Voltage: -0.1625        Current: -7.94625E-06
  Voltage: -0.1625        Current: -7.549375E-06
  Voltage: -0.159375      Current: -7.152188E-06
  Voltage: -0.15625       Current: -6.755312E-06
  </code></pre>
  
  <p>You see there are Voltage values which should be on X axis and Current on Y axis. I know that to make them a bit better I have to multiply them in a bigger number and also maybe multiply by an inverse or something. but I still cant figure out how to represent them on my picturebox. These points are usually start from 3rd quadrant and end up in first quadrant.  Please assist!</p>
  
  <p>Just to add that my X axis min and max are -2V and +2V and for Y Axis I would have -10uA to +10uA  (that is 10*10^-6)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>What I am trying to do is have a curve like these, so those points I have are used in Graphics.DrawCurve:</p>
  
  <p><img src="https://i.stack.imgur.com/Mez1B.png" alt="enter image description here"></p>
  
  <p><strong>UPDATE</strong>
  This is how my code looks like:</p>
  
  <pre><code>            g.DrawLine(penAxis, 250, 0, 250, 500); // Y AXIS 
          g.DrawLine(penAxis, 0, 250, 500, 250); // X AXIS          
  
          PointF[] p = new PointF[pinData.GetLength(0)];   //pinData is AboutBoxForm double[,] array
  
          for (int i = 0; i &lt; pinData.GetLength(0); i++)
          {
              p[i] = new PointF(250 * ((1 + (float)pinData[i, 0]) / 2), 250 * ((1 + (float)pinData[i, 1] )/ 10));  
          }
  
          Pen pengraph = new Pen(pinColor, 2.0F);
          g.DrawCurve(pengraph, p);
  </code></pre>
  
  <p><strong>PROGRESS UPDATE</strong></p>
  
  <p>ok now using the code below my curve looks like:</p>
  
  <pre><code>            g.DrawLine(penAxis, 250, 0, 250, 500); // Y AXIS 
          g.DrawLine(penAxis, 0, 250, 500, 250); // X AXIS          
  
          PointF[] p = new PointF[pinData.GetLength(0)];   //pinData is AboutBoxForm double[,] array
  
          for (int i = 0; i &lt; pinData.GetLength(0); i++)
          {
              p[i] = new PointF(250 * (1 - ((float)pinData[i, 1] *100000) / 10), 250 * (1 + (((float)pinData[i, 0]))/ 2));  
          }
  
          Pen pengraph = new Pen(pinColor, 2.0F);
          g.DrawCurve(pengraph, p);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/nl26O.jpg" alt="enter image description here"></p>
  
  <p>I think now the problem is scaling it. <strong>SOLVED</strong> I had to multiply by 10^6 but I did with ^5 no it is ok!!! Thanks all.</p>