Hi everybody!
I have a table in my database which containes the coordinates of corners of the boxes of the grid(the boxes can be any shape). It looks like this:
i j x1 y1 x2 y2 x3 y3 x4 y4
x1 x2= x3 x4
--------o----o---o------------ y1
| /\ |
| / \ |
| / \ |
| / \ |
| / \ | y2=y3
| \ / |
| \ / |
| \ / |
| \ / |
| \/ |
---------------------------- y4
I also have the point (x,y) and I need to define if this point is in the orthogonal box limited by the lines. I tryed to do it like this:
select * from table where not (((x<x1) and (x<x2) and (x<x3) and (x<x4)) or ((x>x1) and (x>x2) and (x>x3) and (x>x4)) or ((y<y1) and (y<y2) and (y<y3) and (y<y4)) or (((y>y1) and (y>y2) and (y>y3) and (y>y4)));
To say it in words : I want to select all the records where all 4 corners of the boxes are not from the left of the point, are not from the right of the point, are not below the point or are not beyond the point.
It didn't work. Does anybody have an idea how can I make it work?
I know my explanation is kind of messy, but please ask me if you are confused by it.
Thank you,
Elena