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

position sticky automatic "top" position

Is there a way for stickies to take into account other stickes on the page? For example: body { display: flex; min-height: 2000px; flex-direction: column; } #header { height: 40px; flex: 0 0 auto; position: sticky; top: 0; …
Elfy
  • 1,733
  • 6
  • 19
  • 39
10
votes
1 answer

Count number of days that time periods overlap

Using the lubridate library, I can find out if two time periods overlapped. But, is there an efficient way to compute for how many days they overlapped. (for instance how many days a women smoked while pregnant. The pregnancy period and smoking…
9
votes
1 answer

Merge rasters of different extents, sum overlapping cell values in R

I am trying to merge rasterized polylines which have differing extents, in order to create a single surface indicating the number of times cells overlap. Due to computational constraints (given the size of my study area), I am unable to use extend…
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
  • 949
  • 2
  • 8
  • 24
9
votes
3 answers

Find overlapping dates for each ID and create a new row for the overlap

I would like to find the overlapping dates for each ID and create a new row with the overlapping dates and also combine the characters (char) for the lines. It is possible that my data will have >2 overlaps and need >2 combinations of characters. …
sar
  • 182
  • 6
  • 26
9
votes
2 answers

Find overlapping Regexp matches

I want to find all matches within a given string including overlapping matches. How could I achieve it? # Example "a-b-c-d".???(/\w-\w/) # => ["a-b", "b-c", "c-d"] expected # Solution without overlapped results "a-b-c-d".scan(/\w-\w/) # => ["a-b",…
sschmeck
  • 7,233
  • 4
  • 40
  • 67
9
votes
1 answer

ggplot2: How to combine histogram, rug plot, and logistic regression prediction in a single graph

I am trying to plot combined graphs for logistic regressions as the function logi.hist.plot but I would like to do it using ggplot2 (aesthetic reasons). The problem is that only one of the histograms should have the scale_y_reverse(). Is there any…
ChJulian
  • 115
  • 1
  • 5
9
votes
2 answers

How to blend properly when stitching images in matlab?

I'm trying stitch images in matlab, but get ugly overlap lines. How can I blend images properly? Currently I'm using the code below, but it blends too much (especially building windows are blended with ghost artifacts, as is the black building).…
user3082220
  • 169
  • 1
  • 2
  • 6
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
  • 2
  • 7
9
votes
2 answers

How can I find overlapping dateperiods/date ranges in PHP?

If I have two date ranges (e.g. May 1 - May 31 and May 23 - June 5) what would be the best way to find out how many days the two periods overlap in PHP (so it would return 9)? Is there a way to do this using DatePeriod objects? Edit to (hopefully)…
Dustin
  • 707
  • 1
  • 7
  • 11
9
votes
4 answers

FragmentTransaction.remove has no effect

My requirement is quite simple: I have a button that should replace a FragmentA by FragmentB. This sounds easy and nearly work, the big problem is that the old fragment is not removed and the new placed on the front of the old one and they are…
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
8
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,972
  • 6
  • 34
  • 62
8
votes
2 answers

identify consecutively overlapping segments in R

I need to aggregate overlapping segments into a single segment ranging all connected segments. Note that a simple foverlaps cannot detect connections between non overlapping but connected segments, see the example for clarification. If it would…
rluech
  • 606
  • 4
  • 15
8
votes
3 answers

Group rows by overlapping ranges

I have a dataframe, where the left column is the left - most location of an object, and the right column is the right most location. I need to group the objects if they overlap, or they overlap objects that overlap (recursively). So, for example,…
Binyamin Even
  • 3,318
  • 1
  • 18
  • 45
8
votes
1 answer

Avoid text overlap in MATLAB figures

When inserting text into MATLAB figures programmatically using text(x,y,'label'), I often find that the text blocks overlap, making them unreadable. I was wondering if there was any automated way to offset the text blocks so they wouldn't overlap.…
btown
  • 2,273
  • 3
  • 27
  • 38