title: map the point x,y in Cartesian coordinate into 2D Array elements
body: <p>I would like to create a map of the enviroment, ie. my room. I want to have a 2D representation of my room using 2D Array. </p>
  
  <p>I am trying to map a room, which has coordinate start at (5,5), (10,5), (5,10) and (10,10). This is a square of size 5x5 if you ever wonder. I would like to map this into a 2D grid of 100x100 cells.</p>
  
  <p>The math I am using to map is, </p>
  
  <pre><code>X' = (maxRangeX - minRangeX)*(X - minX)/(maxX - minX) + minRangeX
  Y' = (maxRangeY - minRangeY)*(Y - minY)/(maxY - minY) + minRangeY
  </code></pre>
  
  <p>where</p>
  
  <pre><code>maxRangeX   100 maxX    10  maxRangeY   100 maxY    10
  
  minRangeX   0   minX    5   minRangeY   0   minY    5
  </code></pre>
  
  <p>As you know, the way Array works is it start (0,0) at the top left, and (100,100) at the bottom right, in this case I mean. But, by using the math I showed above, it seems to map the room into a 2D array which has (0,0) start at bottom left and (100,100) ends at top right, (0,100) on top left and (100,0) on bottom right.</p>
  
  <p>I want to map the room over so that the result is ordered in a structure like how array structure does.</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p>Update:</p>
  
  <p>The idea is still as above, and here is a picture to illustrate further.</p>
  
  <p><a href="http://i.stack.imgur.com/h4Mgm.png" rel="nofollow">http://i.stack.imgur.com/h4Mgm.png</a></p>