I need some help with this problem that I just cant seen to understand how to do.

I just need help coming up with an algorithm that can check to see if two parallelograms have an intersection. This involves where they are on a 2d grid (x,y) coordinates of the vertex's.

The other thing is the grid I am working with, the (0,0) or origin is at the top left

and as you go down, the y number is increasing and is >= 0

An example is:

(0,0) (5,0)

__________

|_|_|_|_|_|

|_|_|_|_|_|

|_|_|_|_|_|

|_|_|_|_|_|

|_|_|_|_|_|

(0,5) (5,5)

If you know can you write out the steps to solve it ex. [find of the length of this, then subtract this from this, etc...]

given 16 arguments

1)parallelogram1_x1

2)parallelogram1_y1

3)parallelogram1_x2

4)parallelogram1_y2

5)parallelogram1_x3

6)parallelogram1_y3

7)parallelogram1_x4

8)parallelogram1_y4

9)parallelogram2_x1

10)parallelogram2_y1

11)parallelogram2_x2

12)parallelogram2_y2

13)parallelogram2_x3

14)parallelogram2_y3

15)parallelogram2_x4

16)parallelogram2_y4

the (x,y)#1 will be the top_left of the parallelogram

the (x,y)#2 will be the top_right of the parallelogram

the (x,y)#3 will be the bottom_left of the parallelogram

the (x,y)#4 will be the bottom_right of the parallelogram

NOTE: the parallelogram may be a rectangle

NOTE2: I am working with variables here, not actual values.

NOTE3: there are no negative x or y coordinates in the grid. its just [for x] 0,...,room_width, and [for y] 0,...,room_height. This is the whole grid.

With this data, how do I find out if there is an intersection anywhere between both the parallelograms? One of them doesn't have to lie directly inside the other, I just want to know if they touch.

Any help is appreciated.