www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/01/00:14:12

Date: Tue, 30 Sep 1997 23:12:46 -0500 (CDT)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: djgpp <djgpp AT delorie DOT com>
Subject: collision detection
Message-ID: <Pine.SUN.3.95.970930230947.10299B-100000@bert.eecs.uic.edu>
MIME-Version: 1.0

Does anyone know how to detect if two rectangles overlap each other at
some point. Let's say we have something like this:

typedef struct RECT {
   int x1, y1, x2, y2;
} RECT;

and I need a function that would take 2 of those and check if they
overlap. I got it working partailly by checking the corners of one
rectangle if they are inside the other, but if the other is smaller and is
completly enclosed in the first it does not work.

Any help would be appreciated.
Thanks.


                        ,,,
                       (0 0)
   +-------------oOO----(_)-------------------+
   |                Andrew Deren              |  
   |             aderen AT eecs DOT uic DOT edu          |
   | www.eecs.uic.edu/~aderen/ader/main.html  |
   +-------------------------oOO--------------+
                       || ||
                      ooO Ooo
 


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019