How to find intersection rectitem co ordinates
-
wrote on 15 Oct 2011, 12:00 last edited by
hi, i have small problem i have one rect angle in horizentel direction rect1(3,3,25,7) and another rectangle in vertical direction rect2(5,5,8,20) rect2 is on rect1 is there any direct function to find the intesected area(it is in rect angle shape) some one please tell me how to find the co ordinates of that rectitem....
-
wrote on 15 Oct 2011, 12:15 last edited by
Your horizontal item seem to have the coordinates
rect1 (xmin = 3, ymin = 3, xmax =3+25=28, ymax = 3+7=10)
the one has
rect2 (xmin = 5, ymin = 5, xmax =5+8=13, ymax = 5+20=25)
The maximum rectangle is formed by all "extreme" coordinates:
rectmax (xmin = 3, ymin = 3, xmax =28, ymax=25)
The minimum rectangle is formed by
rectmin(xmin=5,ymin=5,xmax=13,ymax=10)
I guess you are looking for the later one.
There are also a number of webpage around to find the proper formulas for none horizotal and vertical lines. "e.g.":http://paulbourke.net/geometry/lineline2d/ -
wrote on 15 Oct 2011, 12:28 last edited by
thank you so much for your reply ...(3,3,25,7)(x,y,width,height)...the horizental and vertical rect angles are one on the other then some part of area is common for both rectitems it is also in rectangle shape...i want to find that rect angle(x,y,width,height)...
-
wrote on 15 Oct 2011, 14:57 last edited by
It's Qt, man! Everything is done for you. Try this :
@
QRect rect1(3,3,25,7);
QRect rect2(5,5,8,29);
QRect rect3=rect1 & rect2;
@
3/4