Event Spacing and the Shear Coefficient
Continuing from the previous article: after uniform scaling, all endpoints have integer coordinates with absolute values at most the integer , where . The positive denominators of endpoint and actual intersection coordinates in lowest terms are at most . We now use this result to bound event spacing and choose the shear coefficient.
How far apart must different horizontal coordinates be?
The event positions considered here include all input endpoints and all actual intersections of nonparallel segments that lie on both segments. The same point may correspond to several input pairs or several teaching stops. This proof concerns only the order of geometric positions; it does not merge their identities.
Write two different event horizontal coordinates in lowest terms as and , where are positive integers at most . Subtract using a common denominator:
Here we multiply the first fraction's numerator and denominator by , and the second fraction's numerator and denominator by , giving the common positive denominator . Distance does not depend on the sign of the subtraction, so take the absolute value:
Because the horizontal coordinates differ, the numerator cannot be . It is a nonzero integer, whose absolute value is at least . With the denominator unchanged, replacing the numerator by therefore gives a fraction no larger than the original distance:
Also, and , and both numbers are positive. Multiplying gives
Taking reciprocals of positive numbers reverses their order. For example, , but . Thus . Combining the two steps gives
This is like a "minimum safe gap" between fractions: with an upper bound on their denominators, different fractions cannot be arbitrarily close.
Check with small fractions: the distance between and is . Their denominators are both at most , so the same method bounds their distance below by . The actual distance is larger than , with no contradiction: a lower bound guarantees only that the distance is not smaller; it need not be attained. Likewise, need not be the actual smallest gap in the current figure.
On the other hand, a point on a segment cannot be higher than its higher endpoint or lower than its lower endpoint. Input endpoints and actual segment intersections therefore all have heights between and . The largest height difference occurs when one event is at the top and the other at the bottom, and is only . Thus
Notice that an intersection of supporting lines may lie far outside the segments. The denominator bound still applies to it, but this height-difference bound applies only to endpoints and actual segment intersections, not to arbitrary intersections of extended lines.
Where the fifth power and the constant 256 come from
Compare the original gap with the change caused by shear
Suppose event is originally to the left of event , so . We care about "the right horizontal coordinate minus the left horizontal coordinate": as long as this difference stays positive, remains to the right of .
After shearing, their horizontal coordinates are and . Subtract and remove parentheses:
The first term, , is the original positive gap, at least . The second term, , is the change in that gap. We choose , so:
- If , the right-hand point moves farther right, increasing the gap.
- If , both points move by the same amount, leaving the gap unchanged.
- If , the gap decreases by , which is at most .
We therefore need to guard only against the third case. If two objects start at least meters apart and the gap decreases by less than meters, they still have not met. In the same way, here we need
Since , we have . Dividing both sides by the positive number leaves the inequality direction unchanged:
The last step uses and . The fifth power comes from the fourth power in horizontal spacing multiplied by the first power in the height difference.
The inequality must be strict. If the reduction equaled the original gap, the new horizontal coordinate difference would be , and strict left-to-right order would no longer be guaranteed.
Check that the chosen coefficient meets the requirement
Rather than seek the largest usable coefficient, we choose the more conservative, uniform value
Since , multiplying five copies of gives a larger result than multiplying five copies of , so . Hence
For positive fractions with numerator , a larger denominator means a smaller fraction. Therefore
Now multiply both sides of the right-hand inequality by the positive number to check the maximum reduction:
The last step divides both numerator and denominator by . This is exactly the required condition that the reduction be smaller than the minimum safe gap.
Both and replacing by enlarge the denominator and decrease the coefficient, leaving extra room. This choice certainly meets the condition, but it is neither the only correct coefficient nor the largest possible one.
Substitute the result into the horizontal coordinate difference
Any real number is at least the negative of its absolute value; for example, and . Thus the change is at least , and the height difference is at most . Substituting step by step gives
The last step holds because we have just proved : subtracting a smaller number from a larger one gives a positive result. Therefore , and the event originally on the left remains on the left.
Example: the largest absolute coordinate is 3
Suppose the input endpoints have integer coordinates whose largest absolute value is . Take , so :
For example, the endpoints and of a vertical segment become
Their horizontal coordinates now differ, so the segment is no longer vertical, but the transformation has lost no information.
Finally, calculate the distance bounds as well. Since , the absolute value of the change in the horizontal coordinate difference of any two events is at most
For events whose original horizontal coordinates differ, the lower bound on their safe gap is
To verify , multiply both sides by the positive number . After canceling the denominators, only an integer comparison remains:
The maximum reduction is therefore smaller than the guaranteed minimum gap, without relying on decimal approximations. This estimate concerns any two events. The endpoints of the vertical segment above originally had equal horizontal coordinates; their separation follows directly from and their different heights.