I have two time intervals A and B that occur in time at a start time and occur until an end time. These time intervals however repeat in time from their start time until another end time.
So each interval starts at a specific instant in time, 'occurs' for a duration of time, then repeats after a duration (period) of time.
Interval A
- Start: 1s
- End: 5s
- Repeat Until: 50s
Repeat Period: 10s
|-[xxx]-----[xxx]-----[xxx]-----[xxx]-----[xxx]----|
Interval B
- Start: 7s
- End: 10s
- Repeat Until: 50s
Repeat period: 9s
|-------[xx]-----[xx]-----[xx]-----[xx]-----[xx]---|
Timeline
A:|-[xxx]-----[xxx]-----[xxx]-----[xxx]-----[xxx]----|
B:|-------[xx]-----[xx]-----[xx]-----[xx]-----[xx]---|
If these were considered linear (which they are partially - except for the duration) I could just set two equations equal to each other to figure out when they conflict.
|-x---x---x---x---x---x---x---x---x---x---x---x---x|
event.start + event.period(num of repeats) = new event.start
other.start + other.period(num of repeats) = new other.start
Set equal to each other solve for num of repeats
However I'm only dealing with integers, I'm checking for overlap not an exact point in time, and it doesn't tell me when other intervals overlap. I'm lost.
Representing these intervals so that I can calculate when they overlap and for how long is really the bottom line. I'm missing an important concept here that I can't quite get, some thoughts included series, regression, and brute force (calculate every position manually) but I'm lost without a clear understanding of math to help me forward.