# Counting number of Triangles with Integer-coordinate Vertices in the xy-plane

How many triangles with positive area are there whose vertices are points in the $$xy$$-plane whose coordinates are integers $$(x, y)$$ satisfying $$1 \le x \le 4$$ and $$1 \le y \le 4$$?

There are $$16$$ total points in this range. Any triangle is formed by choosing $$3$$ out of these sixteen points. If that were the case, then the answer would trivially be $$\binom{16}{3}=560$$.

But alas, degenerate triangles (where all three points are collinear or all points have the same coordinates) have an area of $$0$$, which forbids them from contributing to the answer.

How can I solve for the number of degenerate triangles?

The 4 horizontal and 4 vertical lines contain 4 points each. Hence the number of ways to choose 3 collinear points from these 8 lines is $$8 \cdot {4 \choose 3}$$.
The 2 main diagonals contain 4 points each. Hence the number of ways to choose 3 collinear points from these 2 lines $$2 \cdot {4 \choose 3}$$.
The other 4 diagonals contain 3 points each. Hence the number of ways to choose 3 collinear points from these 4 lines $$4 \cdot {3 \choose 3}$$ collinear points.
Since none of these lines have 3 points in common, we have not over-counted. Hence the number of degenerate triangles are $$8 \cdot {4 \choose 3} + 2 \cdot {4 \choose 3} + 4 \cdot {3 \choose 3}$$