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
8
votes
1 answer

Assign polygon duplicate area (overlap) to only one polygon

I have a shapefile (which can be downloaded here http://www.car.gov.br/publico/municipios/downloads?sigla=MA (any would do)) where each polygon represent a rural private property, as the owner submited it. However, the polygons overlap. For the…
Liz
  • 91
  • 3
8
votes
3 answers

Android RecyclerView overlap items (Card stacks)

How can I overlap items in RecyclerView? Like stacking cards. Thanks in advance.
shiami
  • 7,174
  • 16
  • 53
  • 68
8
votes
3 answers

Overlap in d3 wordcloud

I use Jason Davies' wordcloud library for d3 (https://github.com/jasondavies/d3-cloud) and my problem is that the words in the cloud overlap. I am aware that there are already questions regarding this issue on stack overflow (and other sites), but…
spaebrun
  • 271
  • 2
  • 6
8
votes
3 answers

Graphviz edges not discernible / edge labels overwritten

I've reduced my problem to the following simple example: digraph { subgraph {rank=same; 0 -> 1 -> 2;} 0 -> 2 [label="A"]; 2 -> 0 [label="B"]; } which produces While keeping 0, 1 and 2 in the same rank (the original example is in the context of a…
watsonic
  • 3,155
  • 1
  • 27
  • 31
8
votes
2 answers

How to make an overlapping barplot?

Making a barplot the 'standard' way dat <- read.table(text = "A B + 1 1 4 + 2 2 3 + 3 3 2 + 4 4 1", header = TRUE) barplot(as.matrix(dat)) gives a barplot like this: Instead, I would like to have the different segnments to overlap, like so How…
Niek de Klein
  • 8,524
  • 20
  • 72
  • 143
8
votes
4 answers

Fragments are getting overlapped on back button

I have created 3 Fragments namely (FragmentA, FragmentB, FragmentC) and one MainActivity. There is a button in each fragment which replaces itself with next Fragment till FragmentC. I am replacing FragmentA (with) FragmentB (then with)…
rajahsekar
  • 916
  • 1
  • 11
  • 25
8
votes
2 answers

How to avoid overlapping between two divs positioning absolute inside a div positioning relative?

The following code works if the page has enough space to host all divs, but if I resize at minimum the page the two divs positioning absolute overlap. How can I avoid that? #div-chatroom { position: relative; height: calc(100% - 70px); /*…
redcrow
  • 1,743
  • 3
  • 25
  • 45
8
votes
6 answers

Overlapping divs on :hover

I have divs that grow heightwise on hover and on hover I want them overlap all other divs, and not push them like in my example. #container{ width: 300px; } #container a div{ float:left; width: 100px; height: 60px; -webkit-transition: all 0.25s…
user2908882
  • 81
  • 1
  • 2
8
votes
3 answers

Isotope folded (elements overlap)

I have been reading stack overflow for a solution but can't find it. (full size image at https://i.stack.imgur.com/n0hd0.png) When I load the page it looks like that Here is the site (beta) http://e-gimnazija.hostoi.com/test/site/index.html If you…
Maverick
  • 876
  • 2
  • 12
  • 22
7
votes
5 answers

The fastest algorithm determine range overlap

I have two sets of range, each range is a pair of integers indicating start and end. What will be the fastest method to determine if there is any overlap between the two ranges? Thanks.
Mavershang
  • 1,266
  • 2
  • 15
  • 27
7
votes
6 answers

Valgrind Warning: Should I Take It Seriously

Background: I have a small routine that mimics fgets(character, 2, fp) except it takes a character from a string instead of a stream. newBuff is dynamically allocated string passed as a parameter and character is declared as char…
Chris Allen
  • 653
  • 4
  • 9
  • 17
7
votes
1 answer

Counting unique elements when some are synonyms of each other

I am trying to count the number of unique drugs in this list. my_drugs=c('a', 'b', 'd', 'h', 'q') I have the following dictionary,which gives me drug synonyms, but it is not set up so that the definitions are only for unique drugs: dictionary <-…
7
votes
2 answers

Don't bring button to foreground on click

My app currently looks like below. Three Buttons in a RelativeLayout, the middle button has negative margin left and right to overlap the other two buttons. Issue: When I click either the left or the right button, it gets to the foreground for a…
poitroae
  • 21,129
  • 10
  • 63
  • 81
7
votes
2 answers

Duration of maximum number of overlapping events

While trying to improve my algoritmic skills I have found myself stuck in the following problem which in short asks you to find the duration of the timespan where there are a maximum number of people present in a…
AsbjornF
  • 83
  • 3
7
votes
5 answers

Algorithms - Find duration of overlapping intervals in a cyclic world (24 hours)

I've been trying to figure out the algorithm for finding the number of overlapping hours between two time ranges, for example: Should return 12. And Should return 4. So please help me fill in the gaps in creating the following function: public…
Daniel
  • 6,194
  • 7
  • 33
  • 59