[Math] Method for Counting the Number of “Unique” Vertices in a Grid

combinatoricsgeometry

I'm trying to find a mathematical formula that will return the number of vertices for an $m x n$ grid of elements. The tricky part is that any grid element is allowed to span multiple rows or columns.

Let's define the bottom left corner of a grid element as it's position and say that the origin [x=0,y=0] of any grid is the bottom left corner, where +x is to the right and +y is up.

Here are some examples to help one visualize the problem:

enter image description here

The description grids 1, 2, and 3 are:

  1. 2×2 Grid – comprised of (2) 1×1 elements at positions [0,0] and [0,1] (1) 2×1 element at position [1,0]
  2. 2×3 Grid – comprised of (4) 1×1 elements at positions [0,1] [1,1] [2,1] [0,2] and (1) 1×2 element at position [0,0]
  3. 2×4 Grid – comprised of (3) 1×1 elements at positions [0,0] [2,1] [3,1], (1) 1×2 element at position [0,1], and (1) 1×3 element at position [1,0]

If for an $mxn$ grid we know the total number of grid elements ($cnt$) and for each grid element we know it's position ($[x , y]$) and size ($l$ x $w]$), is there a formula that we may derive to calculate the number of unique vertices in said grid?

*** Note that unique vertices are shown as blue dots in the aforementioned Example Image

Thank you

01/16/2015 EDIT: I came up with a new example (4.) that is missing a grid element, it is desired for the formula to be able to calculate the number of unique vertices for an incomplete grid as well Click here to see new example #4

Best Answer

I think from your input you can simply calculate the position of each of the four vertex. It is going to be:

[x,y] , [x+l,y] , [x,y+w] , [x+l,y+w]

Then you sort this list of 4*cnt elements and remove duplicates and count the cardinality. I don't think you can have a closed formula because the domain of your function depends on how many grids you have:

vertex = $f(g_1,g_2,....,g_{cnt})$

where $g \in N^4$ (4 dimension arrays of natural numbers)

Related Question