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
351
votes
23 answers

Determine if two rectangles overlap each other?

I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges…
Rob Burke
  • 4,845
  • 4
  • 26
  • 29
161
votes
5 answers

How would you make two

I need two divs to look a bit like this: | | ---| LOGO |------------------------ | |_______________| LINKS | | CONTENT | What's the neatest/most elegant way of making…
st elmos fire
125
votes
8 answers

Is it a bad practice to use negative margins in Android?

Demo of negative margin:                           The scenario Overlapping views by setting a negative margin to one of them so that it invades the bounding box of another view. Thoughts It seems to work the way you'd expect with overlapping of the…
Juan Cortés
  • 18,689
  • 8
  • 63
  • 88
69
votes
3 answers

How to prevent edges in graphviz to overlap each other

I have a graph I've created in graphviz, but the problem is that edges overlap each other (I have 5-7 nodes in each row), so it is hard to tell for each node which are the nodes it connects. How can I make the edges not to overlap each other? Have…
David Rabinowitz
  • 28,033
  • 14
  • 88
  • 124
40
votes
3 answers

Overlapping matches in Regex

I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example: Consider a string "nnnn", where I want to find all matches of "nn" - but also those that overlap with each other. So the regex would provide the…
jevakallio
  • 33,015
  • 3
  • 95
  • 111
37
votes
8 answers

Getting results between two dates in PostgreSQL

I have the following table: +-----------+-----------+------------+----------+ | id | user_id | start_date | end_date | | (integer) | (integer) | (date) | (date) | +-----------+-----------+------------+----------+ Fields start_date…
Psyche
  • 7,313
  • 17
  • 64
  • 83
33
votes
7 answers

Slow cronjobs on Cent OS 5

I have 1 cronjob that runs every 60 minutes but for some reason, recently, it is running slow. Env: centos5 + apache2 + mysql5.5 + php 5.3.3 / raid 10/10k HDD / 16gig ram / 4 xeon processor Here's what the cronjob do: parse the last 60 minutes…
Tech4Wilco
  • 6,620
  • 3
  • 43
  • 80
28
votes
3 answers

How can you detect if two regular expressions overlap in the strings they can match?

I have a container of regular expressions. I'd like to analyze them to determine if it's possible to generate a string that matches more than 1 of them. Short of writing my own regex engine with this use case in mind, is there an easy way in C++ or…
Joseph Garvin
  • 18,725
  • 17
  • 83
  • 150
22
votes
7 answers

Why the content is not covered by the background of an overlapping element?

Here is the situation: body { margin: 0; background: pink; color: #fff; } .box { margin-top: 20px; background: red; } .bottom { text-align: right; background: green; animation: animate 2s infinite alternate…
Temani Afif
  • 180,975
  • 14
  • 166
  • 216
21
votes
6 answers

Synchronizing a timer to prevent overlap

I'm writing a Windows service that runs a variable length activity at intervals (a database scan and update). I need this task to run frequently, but the code to handle isn't safe to run multiple times concurrently. How can I most simply set up a…
JoshRivers
  • 8,842
  • 7
  • 35
  • 37
21
votes
4 answers

Checking a table for time overlap?

I have a MySQL table with the following fields: name starttime endtime starttime and endtime are MySQL TIME fields (not DATETIME). I need a way to periodically "scan" the table to see if there are any overlaps in time ranges within the table. If…
Danish M.
  • 947
  • 1
  • 9
  • 19
20
votes
4 answers

Finding elements that do not overlap between two vectors

I'm trying to identify elements which are not included in the other vector. For instance in two vectors I have list.a <- c("James", "Mary", "Jack", "Sonia", "Michelle", "Vincent") list.b <- c("James", "Sonia", "Vincent") is there a way to verify…
song0089
  • 2,381
  • 7
  • 35
  • 60
19
votes
4 answers

CSS: DIV containing no height on float set

assume we have this code:
content1
RYN
  • 13,462
  • 29
  • 105
  • 163
19
votes
4 answers

reversing z-index based from page render order

Example Markup:

Trigger

This is some content

Trigger

This is some content

Trigger

This is…
DA.
  • 36,871
  • 47
  • 133
  • 201
19
votes
5 answers

Beginner's stuff: How to stop CSS' Divs from overlapping?

First question ever, I started working on CSS about a month ago due to a job I got, but it seems I have encountered some problems I can't fix (mainly due to my inexperience and that it's someone else's CSS) I won't beat around the bush so much and…
Xionico
  • 193
  • 1
  • 1
  • 5
1
2 3
99 100