by PaulDavisThe1st · 2y ago · 0 comments
When you ask if a single non-interval lies within a given interval, the answer is yes or no (with a given resolution).
When you ask what the relationship between 2 intervals is, there are multiple answers (*). In a given problem domain, each one may have different semantic implications.
(*)
interval 1 is larger than interval 2 and fully includes it
interval 2 is larger than interval 1 and fully includes it
interval 1 begins before interval 2
interval 1 ends after interval 2
interval 2 begins before interval 1
interval 2 ends after interval 1
interval 1 and interval 2 are disjoint
interval 1 and interval 2 are equivalent at a given resolutionhttps://en.wikipedia.org/wiki/Allen's_interval_algebra
It's possible to build a graph where the relations are nodes, and the edges are possible smooth operations on the intervals (e.g. translation). Then you have a state machine for smooth system evolution.
This has also come up for me in two dimensions when dealing with overlapping rectangles. For some reason the complexity of it surprised me both times. Sadly computing these cases is a straight-forward slog in 1-D; you can however reuse the solution for higher dimensions in a nice way.
https://en.wikipedia.org/wiki/R-tree
e.g. PostGIS has GiST-RTree:
https://postgis.net/docs/manual-3.2/using_postgis_dbmanageme...