Skip to main content

Putting all the rules into one sweep

Why check a collinear group's neighbor again when that neighbor has not changed? Why collect participants on arrival when the position is already in the pending queue? Can a future collinear member provide coverage after the group disappears?

This is Chapter 8 of the segment-intersection series. The rules established separately now cooperate on one set of inputs, one active state, and one pending queue. We proceed from input preparation to an empty queue, following four actions at each event: read, report, update, and check. Chapter 9 connects the general correctness argument; Chapter 10 analyzes total work. This example replaces neither.

Section 1: Seven inputs, one shear coefficient​

Names always denote original identities, regardless of active order. Every segment includes its endpoints; the two endpoints of ZZ coincide.

InputOriginal endpointsSupporting line or position
AA(0,0),(2,0)(0,0),(2,0)y=0y=0
BB(1,0),(4,0)(1,0),(4,0)y=0y=0
CC(6,0),(8,0)(6,0),(8,0)y=0y=0
DD(−1,4),(7,−4)(-1,4),(7,-4)y=3−xy=3-x
VV(3,−1),(3,2)(3,-1),(3,2)x=3x=3
HH(2,3),(7,−2)(2,3),(7,-2)y=5−xy=5-x
ZZ(3,2),(3,2)(3,2),(3,2)Only the point (3,2)(3,2)

We use the following established conclusions without proving them again:

PrerequisiteConclusion used hereNew connection in this article
Chapter 1: results and identitiesRetain a point or complete interval for each unordered input pairReconcile seven result records with two point positions
Chapter 2: the pending queue, Chapter 3: exact decisionsRetain real future positions; use exact values for ranges, positions, and orderTrack the only newly discovered position from the initial endpoint queue
Chapter 4: same-point participantsCollect the old block on arrival, merge starters and point inputs, report before updatingDistinguish an event with three passing members from one with an ending member and a point input
Chapter 5: collinear groupsReport complete same-line intersections on insertion; recheck extended coverage and remove empty groupsExtension, a short member's departure, a gap, and reactivation occur in one sweep
Chapter 6: complete future orderCompare both coordinates for future positions; preserve state outside the current blockApply this decision in the actual sweep coordinates
Chapter 7: uniform shear and restorationTransform all inputs with one coefficient, then restore complete intersectionsConnect the transformation to every endpoint, candidate, and result here

Using the established safe coefficient choice, all endpoints here are integral, the common denominator is 11, and the largest absolute endpoint coordinate is M=8M=8. We refer to the common denominator in words only: the letter DD always denotes the input. Thus

s=1256(M+1)5=1256×95=1256×59049=115116544.\begin{aligned} s&=\frac{1}{256(M+1)^5} =\frac{1}{256\times9^5}\\ &=\frac{1}{256\times59049} =\frac{1}{15116544}. \end{aligned}

Every input is transformed by x′=x+sy, y′=yx'=x+sy,\ y'=y. Throughout, ss denotes this exact fraction, never a decimal approximation. For example, the lower and upper endpoints of VV become (3−s,−1)(3-s,-1) and (3+2s,2)(3+2s,2), so it is no longer vertical in the new coordinates.

Figure 1: Original coordinates of the seven inputs. Dashed A overlays its shared portion with B. The diamond for Z is centered on the upper endpoint of V; no input is displaced.Figure 1: Original coordinates of the seven inputs. Dashed A overlays its shared portion with B. The diamond for Z is centered on the upper endpoint of V; no input is displaced.
Figure 2: The same inputs under an exaggerated demonstration shear of one eighth. This coefficient is not used for the calculations.Figure 2: The same inputs under an exaggerated demonstration shear of one eighth. This coefficient is not used for the calculations.

Read the numbered panels as original coordinates followed by the exaggerated shear, even when they wrap. Each panel is displayed at its original 320 × 260 size, with equal horizontal and vertical units; OO marks the origin and ticks are one unit apart. AA is blue, BB orange, CC violet, DD green, VV red, HH cyan, and ZZ pink. Dashed AA distinguishes overlapping identities, not missing coverage. The diamond has no area and does not displace ZZ.

Only Figure 2 uses svis=1/8s_{\mathrm{vis}}=1/8 to exaggerate the shear; this is not the calculation coefficient. Later local geometry panels show original coordinates; order diagrams use discrete positions for the active order. All are teaching illustrations, not execution screenshots. Coordinate tables and decisions always use the actual ss. The originally same-column positions (3,−1),(3,0),(3,2)(3,-1),(3,0),(3,2) acquire horizontal coordinates 3−s,3,3+2s3-s,3,3+2s, so they are no longer same-column events in sweep coordinates.

Section 2: Initialization knows positions, not reported results​

Let GG denote the fixed collinear group containing A,B,CA,B,C. Its line is y′=0y'=0, but its member set changes. D,V,HD,V,H each occupy a separate group; their input names also label those order positions below. ZZ belongs to no nonzero group. G[A,B]G[A,B] means that the current members are A,BA,B; it neither merges their identities nor assigns them an internal vertical order.

Name the original-coordinate candidates P=(3,0)P=(3,0), Q=(3,2)Q=(3,2), and R=(5,0)R=(5,0). Their new coordinates are P′=(3,0)P'=(3,0), Q′=(3+2s,2)Q'=(3+2s,2), and R′=(5,0)R'=(5,0). RR is only the candidate intersection of the horizontal line with the line supporting HH, not an event assumed to be real.

Substitute the inverse relation x=x′−sy′x=x'-sy' into the equation for DD: y′=3−(x′−sy′)=3−x′+sy′y'=3-(x'-sy')=3-x'+sy'. Subtract sy′sy' from both sides to obtain (1−s)y′=3−x′(1-s)y'=3-x'. Since 0<s<10<s<1, division by 1−s1-s is valid. The same substitution applies to HH. The sweep therefore uses these fixed lines and closed ranges:

GroupHeightRanges that current members may supply
GGy′=0y'=0A:[0,2]A:[0,2], B:[1,4]B:[1,4], C:[6,8]C:[6,8]; only members that have started count
DDy′=(3−x′)/(1−s)y'=(3-x')/(1-s)[−1+4s,7−4s][-1+4s,7-4s]
VVy′=(x′−3)/sy'=(x'-3)/s[3−s,3+2s][3-s,3+2s]
HHy′=(5−x′)/(1−s)y'=(5-x')/(1-s)[2+3s,7−2s][2+3s,7-2s]

The expression for VV follows from x′=3+sy′x'=3+sy' by subtracting 33 and dividing by positive ss. Write RGR_G for the rightmost covered endpoint of GG; this is a different object from candidate point RR. While nonempty, the other groups have rightmost endpoints 7−4s,3+2s,7−2s7-4s,3+2s,7-2s, respectively.

Initialization registers both endpoints of each nonzero input and the position of ZZ. Coincident positions merge while retaining every identity. Thus the end of VV and point input ZZ share Q′Q'; the two identical endpoints of ZZ do not register it twice. There are 12 positions, with empty active order and results. P′P' has no input endpoint and is not registered yet; neither is R′R'.

For reference, call the positions eventually processed E1E_1 through E13E_{13}; Section 6 gives all coordinates. These labels do not mean that all thirteen positions are known at initialization: the initial queue contains E1E_1 through E6E_6, then E8E_8 through E13E_{13}. Each extraction still chooses the smallest unprocessed position in the new coordinates.

Section 3: Unchanged neighbors, extended coverage​

At E1=(−1+4s,4)E_1=(-1+4s,4), DD starts. There are no old participants or pairs to report. Inserting DD leaves it alone, with no neighbor to check.

At E2=(0,0)E_2=(0,0), read starter AA. The height of DD is 3/(1−s)>03/(1-s)>0, so it does not pass through this point and there is no new result. Inserting G[A]G[A] gives bottom-to-top order G[A],DG[A],D, with RG=2R_G=2.

The new neighbors G,DG,D have candidate P′=(3,0)P'=(3,0): substituting y′=0y'=0 into the line of DD gives 0=3−x′0=3-x', hence x′=3x'=3. This is future and covered by DD, but 3>RG=23>R_G=2, so it cannot be scheduled. BB, which has not started, cannot supply current coverage.

At E3=(1,0)E_3=(1,0), AA is an old participant and BB starts. Following the same-line insertion rule, first report the complete interval (1,0)(1,0)—(2,0)(2,0) for A,BA,B, then add BB. GG remains below DD, but RGR_G extends from 22 to 44.

Figure 3: After E2, only A supplies coverage, ending at 2. Hollow candidate P is outside that coverage.Figure 3: After E2, only A supplies coverage, ending at 2. Hollow candidate P is outside that coverage.
Figure 4: After E3, A and B share a group and B extends coverage to 4, covering P. Dashed A and solid B retain their original coordinates.Figure 4: After E3, A and B share a group and B extends coverage to 4, covering P. Dashed A and solid B retain their original coordinates.

These panels isolate A,B,DA,B,D from the same example, without changing the inputs. Recheck the still-adjacent G,DG,D: 1<3≤41<3\le4 and −1+4s<3<7−4s-1+4s<3<7-4s. Both groups currently cover P′P' and it is strictly future. Add P′=E7P'=E_7 to the queue. Reporting an interval on insertion and discovering a future point after updating coverage are separate actions.

At E4=(2,0)E_4=(2,0), AA ends while BB passes through. Retain AA's eligibility at its closed endpoint, but do not report the already-reported A,BA,B interval again as a point. Then remove AA. G[B]G[B] remains, with RG=4R_G=4. Rechecking neighbors G,DG,D yields the already registered P′P', so retain its existing record. Coverage did not extend and there is no new discovery; this check cannot report A,BA,B again.

At E5=(2+3s,3)E_5=(2+3s,3), HH starts. Here DD has height (1−3s)/(1−s)<3(1-3s)/(1-s)<3: multiplying by positive 1−s1-s reduces the comparison to 1−3s<3−3s1-3s<3-3s, or 1<31<3. Its height is also positive because s<1/3s<1/3. There is no other participant; the new order is G[B],D,HG[B],D,H. The only new adjacency is D,HD,H. Their slopes both equal −1/(1−s)-1/(1-s) and their constant terms differ, so they are distinct parallel lines: no event is scheduled. DD still separates G,HG,H, which are not directly checked here.

Section 4: One discovered position, three passing participants​

At E6=(3−s,−1)E_6=(3-s,-1), VV starts. GG has height 00; DD has height s/(1−s)>0s/(1-s)>0; HH is another 2/(1−s)>02/(1-s)>0 above DD. There is no old same-point participant. Inserting VV gives V,G[B],D,HV,G[B],D,H. Its only new neighbor is GG; the candidate is again P′P'. Both cover it and 3>3−s3>3-s, but the queue already contains that position. Keep one record. Inserting VV between G,DG,D does not cancel their earlier discovery.

Extract E7=P′E_7=P'. In the old order, V,G,DV,G,D all have height 00, forming the entire meeting block. HH, at height 2/(1−s)>02/(1-s)>0, is outside it. Expanding GG yields only current member BB, not departed AA or future CC. The participants are therefore B,D,VB,D,V, all passing through their interiors.

First report the three pairs B,DB,D, B,VB,V, and D,VD,V, each with complete intersection P′P'. Reporting only the earliest discovering pair B,DB,D would be insufficient. Do not report old same-line pair A,BA,B again: its earlier complete interval remains unchanged, neither split nor rewritten as a point.

Figure 5: Before P′, the bottom-to-top group order is V, G[B], D, H. The box marks the meeting block V, G[B], D.Figure 5: Before P′, the bottom-to-top group order is V, G[B], D, H. The box marks the meeting block V, G[B], D.
Figure 6: After P′, that block becomes D, G[B], V, while H stays above it. V and H are new boundary neighbors.Figure 6: After P′, that block becomes D, G[B], V, while H stays above it. V and H are new boundary neighbors.

Spacing in the order diagrams aids reading; it does not represent geometric heights. After reporting, all three groups continue. Use the established right-side slope ordering: DD has slope −1/(1−s)<0-1/(1-s)<0, GG has slope 00, and VV has slope 1/s>01/s>0. The full order becomes D,G[B],V,HD,G[B],V,H.

Internal neighbors D,GD,G and G,VG,V intersect at the current position, which fails the strict-future condition. There is no group below the block. The new upper boundary neighbors V,HV,H yield Q′Q': on the original line x=3x=3 of VV, the height of HH is 5−3=25-3=2, transforming to (3+2s,2)(3+2s,2). It lies to the right of P′P'. VV covers that closed endpoint, and HH covers it too. The initial endpoint and point-input records already contain Q′Q'; do not add another copy. Do not report these pairs before arrival.

Section 5: Report closed endpoints first; do not fill future gaps​

At E8=Q′E_8=Q', read the end record for VV and point input ZZ, and find passing HH in the old meeting block. GG has height 00 and DD has height −2s/(1−s)<0-2s/(1-s)<0; neither participates in this height-22 event.

First report V,HV,H, V,ZV,Z, and H,ZH,Z, each with complete intersection Q′Q'. Then VV leaves and HH continues. ZZ participates only in these pairings: it gets neither a slope nor an active-order position. The remaining order is D,G[B],HD,G[B],H.

Figure 7: Original-coordinate detail at Q: the upper endpoint of V, the interior of H, and point input Z coincide. Retain all three identities for reporting.Figure 7: Original-coordinate detail at Q: the upper endpoint of V, the interior of H, and point input Z coincide. Retain all three identities for reporting.
Figure 8: After Q′, the active groups are only D, G[B], H. Neither V nor Z remains in the order.Figure 8: After Q′, the active groups are only D, G[B], H. Neither V nor Z remains in the order.

The new boundary neighbors G,HG,H have line candidate R′=(5,0)R'=(5,0). It is future: s<1s<1 implies 3+2s<53+2s<5. HH covers it, but GG currently contains only BB, with RG=4<5R_G=4<5, so do not schedule it. The future endpoint 88 of CC cannot replace the current coverage limit.

At E9=(4,0)E_9=(4,0), only ending BB participates, with no new result. Removing it empties GG, which leaves the order. The newly connected D,HD,H are parallel and yield no candidate. The next queue entry is E10=(6,0)E_{10}=(6,0): there is no stop at (5,0)(5,0), which is neither an endpoint nor an intersection covered by both groups.

Figure 9: Original positions of B and H. Candidate R=(5,0) lies beyond B’s endpoint 4. Dashed C has not started and cannot supply coverage.Figure 9: Original positions of B and H. Candidate R=(5,0) lies beyond B’s endpoint 4. Dashed C has not started and cannot supply coverage.
Figure 10: When C starts at (6,0), R is already behind and outside C’s range. Reactivating the group does not revive that candidate.Figure 10: When C starts at (6,0), R is already behind and outside C’s range. Reactivating the group does not revive that candidate.

At E10E_{10}, read starter CC. The heights of D,HD,H are −3/(1−s)-3/(1-s) and −1/(1−s)-1/(1-s): both are below 00, with DD below HH. There is no new result. Reinserting G[C]G[C] gives D,H,G[C]D,H,G[C]. This is the same fixed-line group, but its only current member is CC and RG=8R_G=8; it was not active throughout the preceding gap.

Only new neighbors H,GH,G need checking. Their candidate is still R′R', but 5<65<6, so it is not future; CC starts at 66 and does not contain it either. The rightmost-endpoint criterion applies toward the future from a position currently covered by the group. The inequality 5≤85\le8 alone cannot fill the past. HH separates D,GD,G, so that pair is not a new adjacency here.

Finally process the end of DD at E11=(7−4s,−4)E_{11}=(7-4s,-4), the end of HH at E12=(7−2s,−2)E_{12}=(7-2s,-2), and the end of CC at E13=(8,0)E_{13}=(8,0). Each event has only its ending participant and no new result. Each removes the bottommost group without connecting groups on both sides, so there are no new appointments. Both the queue and active order become empty.

Section 6: The complete event ledger​

Every order, member set, coverage limit, and result count below is taken after all reporting, updating, and checking for that row. Orders run bottom to top. The coverage limits of D,V,HD,V,H are given in Section 2 and remain fixed while nonempty; the changing RGR_G is listed here. Every candidate must satisfy both real coverage and complete-position strict futurity. Distinct positions happen to have distinct x′x' values in this example; this does not remove the vertical-coordinate comparison from the general rule.

EventOriginal → actual sweep positionCurrent participants; new resultsOrder afterward; RGR_GNeighbor checks and queue changesResults / pending positions
InitialNo position extractedNone; noneEmpty; noneRegister twelve endpoint positions, excluding E7E_70/120/12
E1E_1(−1,4)→(−1+4s,4)(-1,4)\to(-1+4s,4)DD starts; no pairDD; noneNo neighbor; extract E1E_10/110/11
E2E_2(0,0)→(0,0)(0,0)\to(0,0)AA starts; no pairG[A],DG[A],D; 22G,DG,D: P′P' exceeds coverage; extract E2E_20/100/10
E3E_3(1,0)→(1,0)(1,0)\to(1,0)AA passes, BB starts; interval for A,BA,BG[A,B],DG[A,B],D; 44Extension recheck of G,DG,D adds E7E_7; extract E3E_31/101/10
E4E_4(2,0)→(2,0)(2,0)\to(2,0)AA ends, BB passes; no repeat of old same-line pairG[B],DG[B],D; 44Rechecking G,DG,D retains existing E7E_7; extract E4E_41/91/9
E5E_5(2,3)→(2+3s,3)(2,3)\to(2+3s,3)HH starts; no pairG[B],D,HG[B],D,H; 44D,HD,H are parallel; extract E5E_51/81/8
E6E_6(3,−1)→(3−s,−1)(3,-1)\to(3-s,-1)VV starts; no pairV,G[B],D,HV,G[B],D,H; 44V,GV,G yield existing E7E_7; extract E6E_61/71/7
E7E_7(3,0)→(3,0)(3,0)\to(3,0)B,D,VB,D,V pass; three point-result pairsD,G[B],V,HD,G[B],V,H; 44D,GD,G and G,VG,V yield current position; V,HV,H yield existing E8E_8; extract E7E_74/64/6
E8E_8(3,2)→(3+2s,2)(3,2)\to(3+2s,2)VV ends, HH passes, point ZZ; three point-result pairsD,G[B],HD,G[B],H; 44G,HG,H: R′R' exceeds coverage; extract E8E_87/57/5
E9E_9(4,0)→(4,0)(4,0)\to(4,0)BB ends; no pairD,HD,H; noneAfter empty-group removal, D,HD,H are parallel; extract E9E_97/47/4
E10E_{10}(6,0)→(6,0)(6,0)\to(6,0)CC starts; no pairD,H,G[C]D,H,G[C]; 88H,GH,G: R′R' is past and outside CC; extract E10E_{10}7/37/3
E11E_{11}(7,−4)→(7−4s,−4)(7,-4)\to(7-4s,-4)DD ends; no pairH,G[C]H,G[C]; 88No new adjacency; extract E11E_{11}7/27/2
E12E_{12}(7,−2)→(7−2s,−2)(7,-2)\to(7-2s,-2)HH ends; no pairG[C]G[C]; 88No new adjacency; extract E12E_{12}7/17/1
E13E_{13}(8,0)→(8,0)(8,0)\to(8,0)CC ends; no pairEmpty; noneNo neighbor; extract E13E_{13}, leaving an empty queue7/07/0

Reconstruct the queue row by row: start with twelve entries, remove the current one in each row, and add E7E_7 only at E3E_3. Rediscovery never inserts a duplicate. In particular, after E3E_3 the remaining order is E4,E5,E6,E7,E8,E9,E10,E11,E12,E13E_4,E_5,E_6,E_7,E_8,E_9,E_{10},E_{11},E_{12},E_{13}.

Exact values verify the event order. Since 0<s<1/40<s<1/4, we have −1+4s<0-1+4s<0 and 2<2+3s<3−s<3<3+2s<42<2+3s<3-s<3<3+2s<4. The middle comparison 2+3s<3−s2+3s<3-s follows from 4s<14s<1; 3+2s<43+2s<4 follows from 2s<12s<1. At the other end, 6<7−4s<7−2s<86<7-4s<7-2s<8 follows respectively from 4s<14s<1, 2s>02s>0, and −2s<1-2s<1. Together with 0<1<20<1<2 and 4<64<6, these establish the strict order of all thirteen entries.

Section 7: Restore and check seven complete pair intersections​

The sweep results use new coordinates. Apply the established inverse transformation, x=x′−sy′, y=y′x=x'-sy',\ y=y'. The interval endpoints have height zero, restoring horizontal coordinates 1−s×0=11-s\times0=1 and 2−s×0=22-s\times0=2. P′P' restores to 3−s×0=3,y=03-s\times0=3,y=0; Q′Q' restores to 3+2s−s×2=3+2s−2s=3,y=23+2s-s\times2=3+2s-2s=3,y=2. Restoring the whole interval relies on intersection preservation under shear, not on treating it as two point results.

Original unordered input pairComplete intersection in original coordinatesReporting event
A,BA,BClosed interval from (1,0)(1,0) to (2,0)(2,0)E3E_3
B,DB,D; B,VB,V; D,VD,VPoint (3,0)(3,0) for each pairE7E_7
V,HV,H; V,ZV,Z; H,ZH,ZPoint (3,2)(3,2) for each pairE8E_8

These are 7 input pairs: 1 interval pair and 6 point pairs, with only 2 distinct point positions. Independently check the set by applying Chapter 1's pairwise method to the other fourteen pairs, using Chapter 3's exact intersection conclusions:

Unreported pairsSpecific reason for an empty intersection
A,CA,C; B,CB,CDisjoint collinear closed ranges: 2<62<6 and 4<64<6
A,DA,D; C,DC,DUnique line candidate (3,0)(3,0) is beyond AA and before CC, respectively
A,VA,V; C,VC,VThe unique candidate is again (3,0)(3,0), outside their respective horizontal ranges
A,HA,H; B,HB,H; C,HC,HUnique candidate (5,0)(5,0) is outside [0,2][0,2], [1,4][1,4], and [6,8][6,8]
D,HD,Hy=3−xy=3-x and y=5−xy=5-x are distinct parallel lines
A,ZA,Z; B,ZB,Z; C,ZC,ZZZ has height 22, so is not on the horizontal line y=0y=0
D,ZD,ZAt x=3x=3, the height of DD is 00, not the height 22 of ZZ

Seven nonempty pairs plus fourteen empty pairs account for all 7×6/2=217\times6/2=21 unordered pairs. This checks the complete result set for this example, not correctness of the general algorithm.

The continuous process connects three distinctions in one state: fixed collinear membership is not current coverage; discovering a position is not collecting all participants on arrival; and eligibility for reporting at an endpoint is not continued activity. The next chapter, Why the whole algorithm remains correct, follows initialization, preservation, and completion to connect the established local arguments into a general explanation of no missed, false, or repeated results for all allowed inputs.