Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Solve - do 2 rectangles overlap
Message
From
20/03/2010 15:45:58
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01455826
Message ID:
01455866
Views:
78
>I tried Google on this but the answers were out of my league.
>I need the algorithm (in VFP) to determine if two containers on a form overlap at any point. The code I did now has 8 Between() statements and still does not cover all possibilities.

Assuming the rectangles use vertical and horizontal lines, as can be assumed if you use containers; also, one rectangle has horizontal coordinates a1 and a2 (a1 less-than a2), the other has horizontal coordinates b1 and b2 (b1 less-than b2):

The horizontal coordinates of the two will NOT overlap if either a2 less-than b1, or b2 less-than a1. Or less-than-or-equal, depending on the definition.

Similar with the vertical coordinates.

To have no overlap at all: either the horizontal coordinates don't overlap, or the vertical coordinates don't overlap. If both overlap, the rectangles overlap.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform