# Thread: Need Geo. Expert Here With Checking Intersection Of Parallelograms!

1. ## Need Geo. Expert Here With Checking Intersection Of Parallelograms!

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.

2. Originally Posted by Sneaky
(0,0) (5,0)
__________
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
|_|_|_|_|_|
(0,5) (5,5)
Are you sure you "understand" coordinates?
The 2 lower ones should be (0, -5) and (5,-5).

Say you have this parallelogram:
Code:
       A                 B

C                 D
AB = CD = 9 and AC = BD = 5; height from A to CD = 4.
If you place A at origin and B on x axis, what will be the coordinates of B, C and D?

3. I understand coordinates, but the specific software I am using uses this type of coordinates in order for things to work.

also i dont understand your last question, the coordinates of all 4 points of both shapes are provided as variables, so they are all defined.

if your translating a shape to be placed on the origin, then do the same operations on the other 3 points as well.

4. My question has NOTHING to do with your program.
It is a simple geometry problem.
Can you answer it or not?

5. B=(9,0)
C=(-3,4)
D=(6,4)
i think these are right

but i think i know how to do this, for p1, u can take each of the lines and compare it with each of the lines of p2, if there are any intersections then there is a intersection with the shapes. But before you do this u check to see if p1 lies completely inside p2 and if p2 is in p1. But i am not sure how to write mathematically how to check if there is a intersection between lines.