> Q1. Given two rectangles - (ax1,ay1,ax2,ay2) & (bx1,by1,bx2,by2), what is

> the best (fastest rather than smallest) algorithm in C or C++ to determine

> if the rectangles overlap.

That's simple. Check for overlap of the ranges covered by both of them,

on each axis. Assuming x2>x1m and y2>y1 for both a and b, the test is:

if ((bx2<ax1) || (bx1>ax2))

return("no overlap");

if ((by2<ay1) || (by1>ay2))

return("no overlap");

return("overlap");

Quote:> Q2. Given that the two rectangles overlap, is it possible to adjust the

> algorithm to return an integer determining where they overlap?

No. That's because a single integer cannot possibly answer this

"where?" question. The answer would another rectangle, i.e. 4 numbers

to describe them.

--

Even if all the snow were burnt, ashes would remain.