How to find intersection rectitem co ordinates



  • 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....


  • Moderators

    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/



  • 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)...



  • 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;
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.