Handling vertical segments with a shear
A vertical segment passes through intersections at two different heights. Both have the same coordinate. At which height should this segment sit in the active order?
This is Chapter 7 of the segment-intersection series. It incorporates vertical inputs into Chapter 6's point-by-point sweep: transform all inputs together, apply the existing rules in the new coordinates, then restore the intersection results. The shear topics provide mathematical proofs. Here we state their results and conditions where needed and follow one set of inputs through the process. You need not read the complete topic first.
Section 1: Where a vertical segment gets stuck
Take three closed segments, whose names denote fixed original identities:
| Input | Endpoints | Range in the original coordinates |
|---|---|---|
| , | ||
| , | ||
| , |
Call the position where crosses , and where crosses . Both points lie within their respective closed ranges. lie on distinct horizontal lines and have no common point. Of the three input pairs, only and intersect.
Read Figures 1 and 2 as a numbered pair, retaining that order when they wrap onto separate rows. Each has an original size of 320 × 260 and equal horizontal and vertical units; is the origin. All transformed figures here use the demonstration coefficient to magnify the shear. It is not the used below, and horizontal distances in the figures cannot check the sweep calculations. Both original and demonstration figures are teaching diagrams, not real execution traces. Coordinate tables, formulas, and event tables always use the actual coefficient.
Chapter 6's reason for updating only the current block uses this condition: a nonvertical line has only one height at a fixed coordinate. One nonzero input therefore cannot participate in both a low and a high event in one column.
Here covers every height from to at , containing both and . Treating it as one position with a single height fails: choosing loses its participation at , while choosing cannot describe its participation at . Assigning an arbitrary slope does not change this fact. We must first make the inputs satisfy the old rules' conditions, then use those rules.
Section 2: Transform the inputs into a form the sweep can handle
Reuse the transformation from How a shear changes coordinates:
are original coordinates and are new coordinates. The prime distinguishes coordinates, not input identities. The same positive number , called the shear coefficient, is chosen for this computation. To transform a point, multiply its coordinate by and add that to its original coordinate; leave its height unchanged. We fix the axes and plot the calculated coordinates as new points, without repeating the interpretation of tilted coordinate axes.
Every endpoint of every input uses the same . A shared original position therefore undergoes the same transformation: whichever input we compute along, we get the same new position. Different coefficients for different lines would not transform the whole figure uniformly, so the intersection-correspondence result would not apply.
How the coefficient ensures the old conditions
For rational coordinates, follow Integer scaling and intersection denominators: choose a positive integer common denominator making every endpoint's integers. Let be the maximum of and the absolute values of these integers. Use the choice established in Event spacing and the shear coefficient:
This preserves the left-to-right order of endpoints and actual intersections with originally different coordinates. The topics above derive the denominator bound, fifth power, and constant. Scaling is used only to select the coefficient; the original coordinates still use the same , without an extra multiplication or division by .
The result in Equal horizontal coordinates, degenerate inputs, and original coordinates directly checks both input types. Originally different endpoint coordinates remain different coordinates by order preservation. For endpoints with the same but different heights, the positive coefficient places the lower endpoint left of the higher. Thus every nonzero input becomes nonvertical, and originally nonvertical inputs do not become vertical. This supplies the missing condition. Zero-length inputs remain points; the statement does not turn them into nonzero segments.
The main example already has integer endpoints: take . Its largest absolute coordinate is , so . It meets the same conditions as the topic's example with largest absolute coordinate 3, so reuse the result calculated there:
We retain the letter below. It always equals this exact fraction, never the demonstration coefficient or a decimal approximation.
| Input identity | Transformed left endpoint | Transformed right endpoint |
|---|---|---|
For example, the upper endpoint of has , and the left endpoint of has . Each row retains its original endpoint heights. The new horizontal length of is , while those of are both .
Section 3: How original events correspond to transformed events
First confirm that the transformed problem is still the original problem. Why shearing preserves intersections proves that one fixed coefficient maps an entire closed segment to the entire closed segment between its transformed endpoints. The transformation can be uniquely undone, so no common points are lost or introduced. This holds for any rational coefficient and does not depend on order preservation by a small coefficient.
The main example's two common points therefore become
Their new coordinates differ by . The bottom-to-top pair in one original column becomes the left-to-right pair . This is more than renaming points: reaches height at , then height at . One order position no longer has to represent two heights in one column.
For other inputs, both same-column separation and preservation of order between originally different columns follow from the coefficient result above. Chapter 6's complete event order can therefore be used in new coordinates. Originally coincident positions remain coincident: same-point participants must not be split into separate processing times. The preserved order is that of geometric event positions; endpoint information and input identifiers must still be retained separately.
Collinearity is also preserved by the line result in the intersection topic. Originally collinear nonzero inputs remain on one line. Distinct lines cannot merge into one because the transformation is uniquely reversible. Chapter 5's collinear groups are therefore organized by lines in the new coordinates, retaining each original identity inside. Point inputs have no unique supporting line and do not join these groups.
Keep a third responsibility separate: exact rational arithmetic prevents fractions from being truncated to finite decimals. The invertible, whole-segment-preserving transformation gives intersection correspondence; the chosen coefficient gives event order preservation; fraction arithmetic avoids rounding error. A small coefficient is not itself a reason for exact calculation.
Section 4: Complete the sweep in the new coordinates
Now sweep the transformed inputs. Heights, slopes, endpoint ranges, candidate intersections, and future comparisons all use . The names still refer to the same original inputs and are not renumbered when their order changes.
Write the new lines and coverage ranges
For , originally , substitution gives . Since , this is . As , divide both sides by to get . The other two heights remain unchanged:
| Input | Height in new coordinates | New slope | Closed range of new coordinates |
|---|---|---|---|
Ranges come from transformed endpoints. A slope states how much new height changes when the new coordinate increases by . We cannot use an old slope for originally vertical , or its old range alone to judge a new intersection.
From the start events to the two intersections
Because , we have . The horizontal inputs' left endpoints satisfy , so both start before . is alone when it joins, and joins above it. These horizontal lines are parallel; no intersection is scheduled.
At , joins at height , below . The line intersection of new neighbors satisfies . Multiplying both sides by gives , at height . Since and , the candidate is in both closed ranges and strictly right of the current position, so register . still separates ; this start event has not made them direct neighbors.
At , both have height and has height . First report for , then use Chapter 3's slope relation on the right: has slope , less than 's , so the right-side bottom-to-top order becomes .
Only now do become new neighbors and get checked. Multiplying by gives , height . It satisfies and , so both inputs cover it. Also , placing it strictly after , so register . This uses Chapter 6's distinct future and coverage checks: actual range membership and still awaiting processing must be checked separately.
At , only , both at height , participate; at height does not. After reporting for , order them on the right since . The full bottom-to-top order is . New neighbors are parallel and have no new intersection.
Here are all the events. The order column describes the state after processing the event, not an arbitrary ordering of equal-height participants at the meeting point.
| New event position | Current action | Bottom-to-top order after processing |
|---|---|---|
| starts | ||
| starts; are parallel | ||
| starts; discover and register | ||
| Report ; after updating, discover and register | ||
| Report ; are parallel | ||
| ends | ||
| ends | ||
| ends | Empty |
The last three endpoints really occur in this order: subtracting from both sides makes equivalent to ; and follows from . No other input passes through these end events, so no results are added. All endpoints and both real intersections have been processed.
This example incorporates transformed inputs into the sweep without reproving neighbor discovery. General inputs still use Chapter 4's same-point participant collection, Chapter 5's coverage-extension checks, and Chapter 6's complete future comparison. Their nonvertical condition is now satisfied. A collinear group's farthest right endpoint must also use transformed endpoints' coordinates, not a mixture with old endpoints' coordinates.
Section 5: Return the answer to the original figure
The sweep obtained intersections in the new coordinates. Use the inverse formulas from the shear topic:
For the result of , substitution gives
This restores . For the result of , likewise obtain
This restores . The final answer has two results attached to original unordered input pairs: for and for ; has empty intersection. Do not return two points without input-pair identities, or mistake the new-coordinate for answers in the original figure.
Restore an entire overlap interval as an entire interval
Take a separate short example with only and a new input , whose endpoints are . Neither nor is present. The largest absolute endpoint coordinate remains , so the actual coefficient is still .
After transformation, covers and covers , both on . By Chapter 5's rule of reporting the complete intersection when a new member joins, when joins at it reports, with same-group member , the complete interval from to . These positions are not two point results: the solid line emphasizes the entire common part.
Restore the lower endpoint: ; restore the upper: . By the whole-segment correspondence cited in Section 3, restore the entire segment determined by these boundaries, obtaining the complete overlap interval from to . Keep the input pair , without merging identities. Even if another crossing occurs inside, use Chapter 5's classified reporting, without splitting this interval or reporting it again as a point.
Point inputs still participate only in their own event
Take another separate short example with only and two point inputs , each with both endpoints at . There are no . Use the same actual .
Both endpoints become under the same transformation, so each input still has zero length. By Chapter 4's rule that point inputs participate in only this event, merge both point identities with nonzero participant at . This produces three point-result pairs: , , and . They share a position but have different identities. Each result is restored to using .
acquire neither slopes nor later positions in the active order. continues through this point and remains the only active input afterward. This connects the existing point-participation rule across the transformation; no new sweep mechanism is needed.
The inputs now satisfy the sweep conditions through one uniform coefficient; all decisions use new coordinates; inverse transformation restores points or complete intervals; and original input pairs are retained throughout. Continue with Chapter 8: Putting all the rules into one sweep to follow a complete mixed-input example. General correctness and total work remain for Chapters 9 and 10 respectively.