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
1695 questions
11
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,159
  • 5
  • 24
  • 29
11
votes
7 answers

Subtract Overlaps Between Two Ranges Without Sets

NO SETS! I can't use Sets because: The ranges will be too long. They will take up too much memory The creation of the sets themselves will take too long. Using only the endpoints of the of the ranges, is there an optimal way to subtract two lists…
sequenceGeek
  • 707
  • 1
  • 8
  • 19
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,578
  • 7
  • 64
  • 97
11
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,596
  • 3
  • 17
  • 34
11
votes
2 answers

Merge overlapping ranges into unique groups, in dataframe

I have a dataframe of n rows and 3 df <- data.frame(start=c(178,400,983,1932,33653), end=c(5025,5025, 5535, 6918, 38197), group=c(1,1,2,2,3)) df start end group 1 178 5025 1 2 400 5025 1 3 983 5535 2 4 1932 6918 …
user1560292
  • 187
  • 3
  • 7
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,514
  • 11
  • 55
  • 97
10
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…
10
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…
10
votes
3 answers

Collapse rows with overlapping ranges

I have a data.frame with start and end time: ranges<- data.frame(start = c(65.72000,65.72187, 65.94312,73.75625,89.61625),stop = c(79.72187,79.72375,79.94312,87.75625,104.94062)) > ranges start stop 1 65.72000 79.72187 2 65.72187 …
Liza
  • 896
  • 1
  • 13
  • 23
10
votes
8 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
  • 864
  • 3
  • 15
  • 30
10
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
  • 19,933
  • 18
  • 42
  • 49
10
votes
2 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
  • 2,635
  • 4
  • 23
  • 34
9
votes
3 answers

Flutter AdMob Banner Ad overlaps screen

I am working on a Flutter Application where I need to show an AdMob's Banner Ad. I have noticed that the banner overlaps my list view. I tried to search for the solution but I did not find anything much useful. One solution I found is to provide fix…
Sam
  • 2,476
  • 2
  • 25
  • 42
9
votes
1 answer

Fixed div background overlapping browser scrollbars

Very strange behavior that I haven't seen before. I have a fixed position div that has a transparent png background image. The z-index is set to -1 so that content can scroll over the fixed image with the scrollbars. I have it positioned with the…
Adam Casey
  • 920
  • 2
  • 8
  • 24
9
votes
1 answer

How do you overlap widgets/frames in python tkinter?

I was wondering if this is even possible. My goal is to have a small white box in the bottom right hand corner, on top of a larger text field. The white box will be used as an "info box" while the person scrolls through the text inside of the text…
user3033423
  • 151
  • 1
  • 1
  • 7