I have a program in C# (Windows Forms) which draws some rectangles on a picturebox. They can be drawn at an angle too (rotated).
I know each of the rectangles\' star
See the rectangle edges as a list of vectors linking a corner to the next, sorting corners clockwise. If the point is in the square, it must be to the right with respect to all of the edge vectors.
This can be solved by vector products, but it boils down to the following:
Iterate over rectangle corners:
P=[px,py]
C=[cx,cy]
and the next corner is N=[nx,ny]
px*ny+cx*py+nx*cy, the point is outside the square.
this would actually work for every convex polygon.