//C# Console Application Home assignment
I have 8 coordinates like this:
(x1, y1) (x2, y2) ... (x8, y8) //The first 4 coordinates are for 1st rectangle //The rest for 2nd rectangle
I store the values like this:
int[,] array2D = new int[8,2];
array2d[0,0] = x1;
array2d[0,1] = y1;
array2d[1,0] = x2;
array2d[1,1] = y2;
//...
array[7,0] = x8;
array[7,1] = y8;
I want to calculate area of intersection between those coordinates.
I already have this code to check when the rectangles aren't overlapping (it works):
if (!(array2D[2, 1] <= array2D[4, 1] && array2D[0, 1] >= array2D[6, 1]
&& array2D[2, 0] >= array2D[4, 0] && array2D[0, 0] <= array2D[6, 0]))
{
//not overlapping
}
{
//overlapping
}
I need help with algorithm to get the area of intersection.
NOTE: Coordinates can have negative values.