Questions tagged [overlap]

Two or more elements overlap when they partially or totally cover one another.

Two or more elements overlap when they partially or totally cover one another.
The way to find if the elements overlap or not is to test if one elements begins before the second one ends, while the second one begins before the first one ends.

For example, here are all of the ways two lines can overlap:

1.
s1|--------|e1
s2|--------|e2


2.
s1|-------|e1
     s2|--------|e2


3.
     s1|--------|e1
s2|--------|e2


4.
s1|-------------------|e1
     s2|--------|e2


5.
     s1|--------|e1
s2|-------------------|e2

Note that s1 is always smaller than e2, while s2 is always smaller than e1.

This is not the case when the two lines do not overlap:

1.
s1|--------|e1
                 s2|--------|e2


2.
                 s1|--------|e1
s2|--------|e2

Note that either s1 is bigger then e2 or s2 is bigger then e1.

The actual data type of the elements is completely irrelevant as long as it's comparable.

Therefore, to check if two elements overlap each other, all you need to do is this: (pseudo code)

If a.Start < b.End AND b.Start < a.End Then
    Overlap
Else
    No overlap
1905 questions
13
votes
3 answers

Overlapping table element left and right border

I want to set each element in the first row of my table to have a left border of a certain color and a right border of a certain color. Unfortunately, it looks like the borders of adjacent table cells are overlapping and I only get the left border…
natsuki_2002
  • 24,239
  • 21
  • 46
  • 50
13
votes
2 answers

Finding the overlapping area of two rectangles (in C#)

Edit: Simple code I used to solve the problem in case anyone is interested (thanks to Fredrik): int windowOverlap(Rectangle rect1, Rectangle rect2) { if (rect1.IntersectsWith(rect2)) { Rectangle overlap =…
Evan
  • 4,450
  • 10
  • 40
  • 58
12
votes
9 answers

How to fix strcpy so that it detects overlapping strings

In an interview, I was asked to write an implementation of strcpy and then fix it so that it properly handles overlapping strings. My implementation is below and it is very naive. How do I fix it so that: It detects overlapping strings and after…
user7
  • 2,339
  • 5
  • 25
  • 29
12
votes
4 answers

Fastest way to split overlapping date ranges

I have date range data in SQL DB table that has these three (only relevant) columns: ID (int identity) RangeFrom (date only) RangeTo (date only) For any given date range, there may be an arbitrary number of records that may overlap (completely or…
Robert Koritnik
  • 103,639
  • 52
  • 277
  • 404
12
votes
7 answers

Algorithm required to determine if a rectangle is completely covered by another set of rectangles

I am searching for an algorithm that will determine if a new rectangle is completely covered by a set of existing rectangles. Another way of putting the question, is does the new rectangle exist completely with the area covered by the existing…
12
votes
2 answers

How can i check if 2 controls overlap eachother on a canvas in WPF?

I am writing a designer that enables the user to drag controls around the screen. What would be the best way of detecting if a control is overlapping another control while i am dragging the one control around? Should i just get the dimensions of the…
Eli Perpinyal
  • 1,706
  • 3
  • 19
  • 35
12
votes
1 answer

st_intersects Vs st_overlaps

What is the difference between these two queries : select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_intersects(a.the_geom,b.the_geom) group by a.gid ; select a.gid, sum(length(b.the_geom)) from polygons…
Abhishek Sagar
  • 1,189
  • 4
  • 20
  • 44
11
votes
5 answers

How to prevent floating content in two divs from overlapping?

In a FAQ page I'm trying to make I have a page with this structure:
11
votes
4 answers

Get distinct consecutive date ranges from overlapping date ranges

I need to get a list of date ranges that are NOT overlapping with each other from a list of overlapping dates and get the sum of coins during that overlap. I have tried googling for an example but no luck so far. I might not be using the right key…
11
votes
6 answers

Multiple Date range comparison for overlap: how to do it efficiently?

To check for overlap in two different dateranges, {Start1, End1} and {Start2, End2} I am checking: if ((Start1 <= End2) && (End1 >= Start2)) { //overlap exists } The question is, what is a good way to compare overlaps if I had let's say five…
VoodooChild
  • 9,776
  • 8
  • 66
  • 99
11
votes
10 answers

how to half overlap imageview on another imageview in android

how can I overlap images half on one another from layout XML file like this image.
Asad
  • 1,241
  • 3
  • 19
  • 32
11
votes
3 answers

Collapse intersecting regions

I am trying to find a way to collapse rows with intersecting ranges, denoted by "start" and "stop" columns, and record the collapsed values into new columns. For example I have this data frame: my.df<- data.frame(chrom=c(1,1,1,1,14,16,16),…
user971102
  • 3,005
  • 4
  • 30
  • 37
11
votes
2 answers

Preventing overlap of text in D3 pie chart

I've been googling around, but I can't seem to grasp this. My situation is that the countries overlap when presented on the pie chart: This is an example of what is happening: jsfiddle I am a total beginner to D3 and am trying to prevent text…
user1431282
  • 6,535
  • 13
  • 51
  • 68
11
votes
3 answers

How to overlap UITableViewCells?

If you look at the screenshot you will notice that each UITableViewCell are 20% overlapped from top portion to the upper tableview cell. Is there any way we can overlap cells ?
Tariq
  • 9,861
  • 12
  • 62
  • 103
10
votes
3 answers

Find overlapping letters in words

I have a string with only three words like this: first_string <- c("self", "funny", "nymph") As you can see the words of this vector can all be put together to one word because there is some overlap in letters, i.e. we get selfunnymph. Let`s call…
LulY
  • 976
  • 1
  • 9
  • 24