title: Divide a rectangle into squares
body: <p>I have a rectangle with the co-ordinates A,B,C,D which are respectively having the co-ordinates:</p>
  
  <pre><code>A-&gt;(3,9)
  B-&gt;(6,9)
  C-&gt;(6,6)
  D-&gt;(3,6)
  </code></pre>
  
  <p>where A is the top left co-ordinate and D is the bottom left co-ordinate.</p>
  
  <p>I want to divide the rectangle into 25 grids and assign each grid a number.For example<a href="https://i.stack.imgur.com/EZaUW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EZaUW.png" alt="grid"></a></p>
  
  <p>So I tried like </p>
  
  <pre><code>double width =  6-3=3;
  double height = 9-6=3;
  
  grid width=3/5=0.6
  grid height=3/5=0.6
  </code></pre>
  
  <p>Now I want to assign the grid an id and their co-ordinates like</p>
  
  <pre><code>1  -&gt;  (3,9),(3.6,9),(3.6,8.4),(3,8.4)
  </code></pre>
  
  <p>and so on.</p>
  
  <p>So I am implementing a hash map  to store the information.</p>
  
  <pre><code>HashMap&lt;Integer, Double[]&gt; hmap = new HashMap&lt;Integer, Double[]&gt;();
  </code></pre>
  
  <p>But I am confused how I can get the grid id's and the </p>
  
  <p>Any help is appreciated.</p>