I’m using a matrix(list) to define points on a grid. the matrix is rather large 120x160. I need an algorithm that can tell the matrix what points are inside a polygon and what points are both inside and occupied by an object.

I could easily store the position of every corner and point along each line. what I don’t know, is how to mark every point inside the shape on the matrix as being inside said shape.

here are two images of the kinds of shapes I’m dealing with:

every line is always either horizontal or vertical. there are never any diagonals.