Rectangle intersection

From: kimos (urdad_at_hotmail.com)
Date: 09/25/04


Date: 25 Sep 2004 08:16:53 -0700

hi all,

how to calculate the intersection of 2 rectangle

a rectangle is the following:

Rectangle makeRectangle (Point lowerLeft, Point upperRight) {
        
        Rectangle r;

        r.pt1 = lowerLeft;
        r.pt2 = upperRight;
        return r;
}

and Point is the following:

Point makePoint(int x, int y) {
    Point p;
    p.x = x;
    p.y = y;
    return p;
}

And i want the know how to make:

Rectangle intersection(Rectangle r1, Rectangle r2)

this should return the intersection of the 2 rectangles
anyone can help me plz?



Relevant Pages

  • Re: Testing Intersection with A Rectangle(2D) w/No Area
    ... > How do I test a rectangle for intersection with another rectangle which has ... > false for a degenerate rect which is equivalent to a line. ... Boeing Associate Technical Fellow ...
    (comp.lang.java.gui)
  • Re: Polymorphism sucks [Was: Paradigms which way to go?]
    ... > intersection when I can return a rectangle? ... Well, depending on the requirements, it might be simpler - for example, if ... wether and how to use an implementation technique like OO. ...
    (comp.object)
  • Re: Intersecting Polygons
    ... I should have asked about the intersection of 2 POLYGONS, ... The polygons can have 3 or more points/sides, ... > Hi Matt: ... > places the coordinates of the intersection rectangle into the destination ...
    (microsoft.public.vb.general.discussion)
  • Re: Calculating the area of intersection of ellipse and a rectangle
    ... Calculating the area of intersection of an ellipse and a rectangle ... may I ask you if anybody knows about an efficient method or may be ...
    (comp.soft-sys.matlab)
  • Re: Intersecting Polygons
    ... don't use polygons much so I can't help you out there. ... I should have asked about the intersection of 2 POLYGONS, ... >> places the coordinates of the intersection rectangle into the destination ... >> Doug. ...
    (microsoft.public.vb.general.discussion)