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
4
votes
3 answers

Meaning of overlapping when using memcpy

I am trying to understand the function memcpy() which is defined in the C library Syntax: void *memcpy(void*dst,const void*src,size_t n); I know this function is used to copy the contents of the memory pointed by pointer src to the…
user4722851
4
votes
1 answer

How to find bucket overlap based on common items in r

I have data like this, where buckets can have different numbers of items: Bucket A | Item 1 Bucket A | Item 2 Bucket A | Item 3 Bucket B | Item 3 Bucket B | Item 4 Bucket C | Item 1 Bucket C | Item 5 Bucket C | Item 2 I want to find the item…
NBC
  • 1,606
  • 4
  • 18
  • 31
4
votes
2 answers

Find max overlap in list of lists

I have two lists of lists: a = [[0, 1, 5], [2], [3], [4], [6, 7], [8, 9, 10, 11], [12], [13], [14], [15]] b = [[0, 1], [2, 3], [4], [5], [6, 7], [8, 9, 10, 11], [12], [13, 14], [15]] How can I find the maximum overlap between the values of the…
elcombato
  • 473
  • 1
  • 4
  • 16
4
votes
3 answers

Check if a date range touches a time range

Sam is working as a part time truck driver. He gets special allowance if he is driving from 0200 hrs - 0600hrs. His boss wants to know which all trips touched this time period. Below are the details for his last 4 trips. Trip 1: StartDateTime :…
RBz
  • 896
  • 3
  • 17
  • 34
4
votes
3 answers

Python: Dynamic interval data structure

I am looking for some python code to efficiently compute interval overlaps. I've used the interval tree of the bx-python package before, but now need to delete intervals from the tree (or better yet, modify them). It seems the bx-python tree doesn't…
buddahfist
  • 57
  • 1
  • 2
4
votes
2 answers

How to check for overlap of cyclic ranges (overlapping yearly recurring periods)

I am trying to find an elegant algorithm to check if two yearly recurring periods overlap. The period is year-agnostic, but a year can be expected to always be a leap year. For example, period A = (March 1st to May 1th,) and period B = (April 1st to…
Rabarberski
  • 23,854
  • 21
  • 74
  • 96
4
votes
2 answers

Check if two or more DOM elements overlap

Good day people! I have run into an issue with my simple single day calendar script. I've been tasked to create a single day calendar, which shows each block hour from 9am to 6pm. If an event overlaps another, they should equal the same width and…
douglaswissett
  • 231
  • 1
  • 4
  • 14
4
votes
6 answers

HTML/CSS - Why does float:left render as 'invisible'?

If you have two divs contained within a div:
The two inner divs are…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
4
votes
1 answer

SpriteKit - Create at random position without overlapping

I want to create some sprites at random positions without getting overlapped, here is my code : var sprites = [SKSpriteNode]() for index in 0...spriteArray { let sprite = SKSpriteNode(imageNamed: named) …
Abdou023
  • 1,654
  • 2
  • 24
  • 45
4
votes
1 answer

Combining observations with overlapping dates

Each observations in my dataframe contains a different "before date" and "after date instance". The problem is some dates overlap for each ID. For instance, in the table below, ID's 1 and 4 contain overlapping date values. ID before date after…
michael
  • 412
  • 1
  • 3
  • 13
4
votes
1 answer

How to jitter lines in ggplot2

Say I have the following data and plot: require(reshape2) require(ggplot2) data <- data.frame(id=seq(1,9,1), var1=c(10,3,5,7,8,9,4,6,5), var2=c(9,3,5,7,8,9,4,6,5)) data_graph <- melt(data, id="id") ggplot(data=data_graph, aes(y=value, x=id,…
bill999
  • 2,147
  • 8
  • 51
  • 103
4
votes
4 answers

comparing and finding overlap range in R

I have two tables where each of them including range of numbers. one table is subdivision of the other. I want to create binary column in the first table which shows in which range they are overlapped. for example: df1: start1 end1 1 6 6 …
Cina
  • 9,759
  • 4
  • 20
  • 36
4
votes
0 answers

Android ViewPager - Overlapping fragments when page width set to 90%

I'm running into a weird issues with Android's ViewPager from the support library. I have my ViewPager set to show a small part of the next fragment. It works and all, except sometimes the left view doesn't resize the way it's supposed to and…
Pkmmte
  • 2,822
  • 1
  • 31
  • 41
4
votes
2 answers

Problems with overlapping sticky header (overlaps main content below it)

I've followed various tutorials over the last few days and am having difficulties with the (sticky) header overlapping the content below it when my page is scrolled vertically. It's on all pages of this test site. HTML >
Will
  • 63
  • 2
  • 7
4
votes
1 answer

View overlapping with RelativeLayout on Android 1.5

I am having a problem with views overlapping in a RelativeLayout on Android 1.5... Everything is working fine on Android 1.6 and above. I do understand that Android 1.5 has some issues with RelativeLayout, but I was not able to find anything on…
Justin
  • 6,564
  • 6
  • 37
  • 34