image.vision\spatiotemporal\st_predicates.mbt
100% · 9 / 9 points · 73 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 时空谓词 spatiotemporal/st_predicates - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 时空拓扑谓词:时间区间之间的拓扑关系。 - 7
// Spatiotemporal predicates: topological relations between time intervals. - 8
// - 9
// 参考 Allen's Interval Algebra 的 13 种关系,实现常用 8 种: - 10
// contains / within / intersects / overlaps / during / before / after / meets - 11
- 12
///| - 13
/// st_contains(a, b):区间 a 包含 b(a.start <= b.start && b.end <= a.end)。 - 14
/// 区间 a 包含区间 b Interval a contains interval b. - 15
pub fn st_contains(a : TInterval, b : TInterval) -> Bool { - 16●
a.start <= b.start && b.end <= a.end - 17
} - 18
- 19
///| - 20
/// st_within(a, b):区间 a 在 b 内(等价于 st_contains(b, a))。 - 21
/// 区间 a 在区间 b 内 Interval a is within interval b. - 22
pub fn st_within(a : TInterval, b : TInterval) -> Bool { - 23●
st_contains(b, a) - 24
} - 25
- 26
///| - 27
/// st_intersects(a, b):区间 a 与 b 相交(有重叠或仅 touching)。 - 28
/// 区间 a 与 b 相交 Intervals a and b intersect. - 29
pub fn st_intersects(a : TInterval, b : TInterval) -> Bool { - 30●
a.start < b.end && b.start < a.end - 31
} - 32
- 33
///| - 34
/// st_overlaps(a, b):区间 a 与 b 有实质重叠(排除仅 touching)。 - 35
/// 区间 a 与 b 重叠(不含仅接触) Intervals a and b overlap (excluding mere touching). - 36
pub fn st_overlaps(a : TInterval, b : TInterval) -> Bool { - 37●
a.start < b.end && b.start < a.end && a.start != b.end && b.start != a.end - 38
} - 39
- 40
///| - 41
/// st_during(a, b):区间 a 严格在 b 期间(a.start > b.start && a.end < b.end)。 - 42
/// 区间 a 严格位于区间 b 期间 Interval a is strictly during interval b. - 43
pub fn st_during(a : TInterval, b : TInterval) -> Bool { - 44●
a.start > b.start && a.end < b.end - 45
} - 46
- 47
///| - 48
/// st_before(a, b):区间 a 在 b 之前(a.end <= b.start)。 - 49
/// 区间 a 在区间 b 之前 Interval a is before interval b. - 50
pub fn st_before(a : TInterval, b : TInterval) -> Bool { - 51●
a.end <= b.start - 52
} - 53
- 54
///| - 55
/// st_after(a, b):区间 a 在 b 之后(等价于 st_before(b, a))。 - 56
/// 区间 a 在区间 b 之后 Interval a is after interval b. - 57
pub fn st_after(a : TInterval, b : TInterval) -> Bool { - 58●
st_before(b, a) - 59
} - 60
- 61
///| - 62
/// st_meets(a, b):区间 a 紧接 b(a.end == b.start)。 - 63
/// 区间 a 接触区间 b (a.end == b.start) Interval a meets interval b (a.end == b.start). - 64
pub fn st_meets(a : TInterval, b : TInterval) -> Bool { - 65●
a.end == b.start - 66
} - 67
- 68
///| - 69
/// st_equals(a, b):区间相等。 - 70
/// 区间相等 Intervals are equal. - 71
pub fn st_equals(a : TInterval, b : TInterval) -> Bool { - 72●
a.start == b.start && a.end == b.end - 73
}