A = point(-1, 1)
B = point(1, 1)
C = point(1, -1)
D = point(-1, -1)
E = point(0, 0)

inArea = side(A, B, E) == -1 and
side(B, C, E) == -1 and
side(C, D, E) == -1 and
side(D, A, E) == -1;

print(inArea) -- true

Anonymous

0

If it is an even square, then x1 = x4, and the other parameters are also equal in pairs. In this case, write normally.

For an even square - you need to make sure that the X-coordinate of the point is between the X-coordinates of the left and right borders; and similarly for the Y-coordinate.

And you can calculate the midpoint. And then make sure that the deviation of the X and Y coordinates differs from the midpoint by no more than half the side of the square - in absolute value. The good thing is that you can not be afraid to confuse the right and left sides of the square.

Or square m. rotated - then it should be set a little differently, there are several options.

The calculations are a little more complicated here.

Anonymous

Your Answer

To place the code, please use CodePen or similar tool. Thanks you!