1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! Cyclic-index arithmetic on a boundary of length `n`.
//!
//! Tiny standalone helpers -- no types, no rings, no references to
//! patches or rats. Used by [`crate::geom::patch`] (for "is this
//! match incident with a given vertex / edge range?") and elsewhere.
//! Kept separate so the patch module can stay focused on the live
//! state machine.
/// True iff vertex `index` is touched by a match of `len` edges
/// starting at edge position `start` on a cyclic boundary of length
/// `n`.
///
/// A match of `len` edges starting at edge `start` covers edges
/// `[start, start+1, ..., start+len-1]` and therefore touches the
/// `len + 1` boundary vertices `[start, start+1, ..., start+len]`
/// (the CW endpoint of the first edge through the CCW endpoint of
/// the last edge). Inclusive on both ends -- the CW vertex (`start`)
/// and the CCW vertex (`start + len`) are both counted as touched.
///
/// The forward-cyclic-distance formulation is correct regardless of
/// whether `start + len` wraps around the boundary; a naive
/// `end <= n` / `index <= end` split has an off-by-one bug exactly
/// when `start + len == n` (the wrap vertex at `0` is missed).
/// True iff two **edge-inclusive** cyclic arcs on a boundary of
/// length `n` share at least one edge.
///
/// Arc `A` = edges `[a, a+1, ..., a+l_a - 1]` (mod `n`); arc `B` =
/// edges `[b, b+1, ..., b+l_b - 1]` (mod `n`). Either arc may wrap.
/// Empty arcs (`l_a == 0` or `l_b == 0`) never overlap.