The number of a triangle on a rectangular grid

combinatoricsdiscrete mathematics

Given a $n \times m$ rectangular grid, the length of each side of the cell is 1

Arbitrarily take three non-collinear grid points on this grid to form a triangle

So what is the number of congruent triangles in this rectangular grid (including itself)?

In fact, we only need to find the length $s$ and width $t$ of the smallest rectangle covering this triangle.

Then the answer is $2(n-s+1)(m-t+1)$

But if we only know the length of the three sides of the triangle $a,b$ and $c$,

how can we fine the $s$ and $t$?

Sometimes, the $s$ and $t$ are not unique, for example, if $a=5$, maybe you can put it horizontally or diagonally

Best Answer

It looks like $n \times m$ are the dimensions of rectangle, so the grid of points is $(n+1) \times (m+1)$. Your answer is not correct. Take a $1,2,\sqrt 5$ triangle, which gives $s=2,t=1$ for the covering rectangle. If the $2$ is along the $n$ direction, there are $n-1$ places it can start and $m$ places you can start the other way, so there are $(n-1)m$ triangles. The triangle has two orientations in the rectangle, so this gives $2(n-1)m$ triangles. This matches your formula, but you can orient the rectangle the other way and get another $2(m-1)n$ triangles.

I don't have a magic way to find $s,t$. First see if any of $a,b,c$ are irrational. Find all the ways to express $a^2,b^2,c^2$ as a sum of two squares. You need to close the triangle, so need to find a way to add or subtract the values in your expression to do so. For example, if we have a $5,12,13$ triangle, we have $5^2=5^2+0^2=3^2+4^2, 12^2=12^2+0^2, 13^2=13^2+0^2=5^2+12^2$. The fact that $12^2$ has no other expression says that the $12$ must be along a grid line. Then you find $s=5,t=12$.

If you have a triangle with $a=10,b=13$, both of which can be put orthogonally or diagonally, the third side will tell you which. If your triangle is $10,13,\sqrt{269}$,the fact that $269=10^2+13^2$ says the $10$ and $13$ are orthogonal. If your triangle is $10,13,\sqrt {333}$, you have $333=18^2+3^2$. If the $10$ is oriented with the $6$ vertical and $8$ horizontal, the $13$ must be oriented with the $12$ vertical so $12+6=18$ and the $5$ horizontal so $8-5=3$

I don't know if there are triangles that can have more than one orientation on the grid up to rotations and reflections.

Related Question