How Shear Changes Coordinates
Starting from and , we first examine what a shear changes and why we cannot simply choose a coefficient that looks small.
Here are the original horizontal and vertical coordinates, and are the new coordinates. The prime only distinguishes new from old; can be read as "the new horizontal coordinate." is a number we choose, called the "shear coefficient," and means . To evaluate the formula, first multiply the vertical coordinate by , then add the result to the original horizontal coordinate; leave the vertical coordinate unchanged. This article uses positive .
Diagram: the same point in a different coordinate system
First use to make the coordinate change easy to see. This coefficient is only for the diagrams; it is not the coefficient actually chosen by the algorithm.
Legend: the points in both diagrams are labeled and ; matching names denote the same position. The left diagram uses the original rectangular coordinate system, and the right uses the new oblique system. Both use the same scale, and points keep the same positions relative to the origin. "Oblique coordinate system" means that the two axes are no longer perpendicular.
Recall how to read rectangular coordinates: draw a vertical line from a point to the horizontal axis, and read the horizontal coordinate at the intersection; draw a horizontal line to the vertical axis, and read the vertical coordinate there. The vertical line is parallel to the vertical axis, and the horizontal line to the horizontal axis.
In an oblique coordinate system, still find the intersection by drawing parallel to the other axis:
- To read the new horizontal coordinate , draw through the point a line parallel to the new vertical axis , find where it meets the new horizontal axis , and read the scale.
- To read the new vertical coordinate , draw through the point a line parallel to the new horizontal axis , find where it meets the new vertical axis , and read the scale.
Here we call this process of "drawing in a specified direction to find an intersection on an axis" a "projection." In an oblique system, the line need not be perpendicular to the axis it reaches, so we cannot always draw perpendicular lines.
Take in the right diagram. A line through parallel to the slanted vertical axis meets the horizontal axis at , so ; a horizontal line through meets the slanted vertical axis at , so . Together these give the new coordinates . The scale on the slanted vertical axis is determined by the coordinate transformation; a length measured along that axis cannot simply be used as the vertical coordinate. We will locate the mark step by step below.
For the two points, respectively,
We add , not the same constant for every point. A positive height increases the horizontal coordinate, while a negative height decreases it.
Recover the original coordinates from the new ones
To see why the new vertical axis tilts left, first recall the coordinate transformation:
Here are a point's original coordinates, and are the same point's new coordinates. The formulas above calculate new coordinates from old ones. We now reverse the process: given , find , so that we can locate the new axes in the original diagram.
Start with the second equation. says that the two numbers are equal, so we can also write:
Now consider the first equation:
Since , replace on the right by :
To leave alone on the right, subtract from both sides:
On the right, and cancel, so:
Exchange the left and right sides:
Together with above, this gives the formulas for recovering the original coordinates from the new ones:
Why the horizontal axis stays unchanged
Look at the following diagram. The gray solid line is the original horizontal axis , and the purple dashed line is the new horizontal axis . They lie on the same horizontal line, so the gray line shows through the gaps in the purple dashes. The blue points are at the marks , , and .
First look at the blue point labeled on the right. It lies on the new horizontal axis, with new horizontal coordinate and new vertical coordinate . We want to check whether it also lies at the mark on the original horizontal axis.
Use the formulas we just derived to convert the new coordinates back to the originals:
Find the original vertical coordinate first. Since this point has ,
Its original vertical coordinate is , so it also lies on the original horizontal axis. Now find its original horizontal coordinate by substituting and :
Any number multiplied by gives , so:
Thus this blue point has new coordinates and original coordinates as well. The diagram shows just one coordinate label because the two systems give exactly the same coordinates for this point.
Next look at the other two blue points. Replace above by or , keeping . The same calculation gives or . The negative and positive scale marks in the diagram therefore coincide one by one.
This conclusion is not limited to the three points shown. Every point on the new horizontal axis satisfies . Let be any number; substitution always gives:
In other words, every position on the new horizontal axis lies on the original horizontal axis with the same reading: is still at the origin, positive numbers are still to the right, and negative numbers to the left. The gray solid and purple dashed lines therefore coincide completely. Neither the direction nor the scale of the horizontal axis changes.
Why the new vertical axis tilts left
In the new coordinate system, points on the vertical axis all satisfy . Substitute into the same formulas:
Follow the next five diagrams to find the original coordinates of a point on the new vertical axis. The blue point is the same stationary point in all five diagrams; each step adds only the guide lines currently needed. The shear coefficient in this example is one half:
Step 1: Look at the circled point on the new vertical axis.
In the following diagram, the two purple axes meet at the origin . The horizontal one is the new horizontal axis , and the one slanting upward to the left is the new vertical axis . Looking upward along the slanted axis from , we find the marks and in order. The blue ring circles the point at the mark .
This step only selects a point; no calculation has been made. Because we chose the point at the mark on the new vertical axis, we read directly:
Here is the new vertical coordinate. It does not mean that the actual distance from to the blue point is . Next we read its new horizontal coordinate.
Step 2: Follow the slanted axis back to the horizontal axis and read .
The following diagram adds an arrow from the blue point toward the origin. To read , we must reach the new horizontal axis in a direction parallel to the new vertical axis . The point already lies on the new vertical axis, so following that slanted axis downward to the right reaches the circled origin .
The arrow reaches the new horizontal axis at , and has horizontal coordinate . Hence:
This agrees with the familiar rule: points on the original vertical axis satisfy , and points on the new vertical axis satisfy . Drawing the axis at a slant does not change that rule.
Combine this with from the first diagram, writing the horizontal coordinate first and the vertical coordinate second:
Notice that the arrow follows the slanted axis. Drawing a vertical perpendicular downward at this stage would not read the new horizontal coordinate ; we will use that direction in the fourth diagram.
Step 3: Follow the horizontal dashed line to find the mark on the original vertical axis.
We now know that the blue point's new coordinates are , and turn to its original coordinates. The next diagram adds the gray original vertical axis . The bottom horizontal axis is labeled with both because the original and new horizontal axes coincide.
Look rightward from the blue point along the horizontal dashed line. It meets the gray original vertical axis at , so the blue point's original vertical coordinate is also .
Why do the two vertical axes give the same reading? Recall the original transformation in this example:
The second equation, , says that the new and original vertical coordinates agree. In step 1 we chose , so:
The labels at both ends of the horizontal dashed line show exactly this equality. Only the original horizontal coordinate remains to be found.
Step 4: Follow the vertical dashed line to its endpoint on the original horizontal axis.
The following diagram adds a dashed line straight down from the blue point. It is parallel to the gray original vertical axis , so where it meets the bottom horizontal axis gives the original horizontal coordinate . This reading uses the original axes, so the direction differs from the slanted arrow in the second diagram.
The diagram labels this endpoint . This number is calculated, not estimated: step 2 gave , and step 3 gave . The original formula is:
Replace on the left by and on the right by :
Perform the multiplication first. Since ,
Subtract from both sides:
Simplifying gives , or:
The vertical dashed line therefore meets the axis to the left of the origin, and the original horizontal coordinate is indeed . Compare with the second diagram: for the same blue point, reading along the slanted axis gives , while reading in the original vertical-axis direction gives . The point has not moved; only the direction used to read its coordinates has changed.
Step 5: Follow the two arrows to check the point's position.
The last diagram draws the original coordinates we just found as a two-part route. Start at the origin , follow the horizontal solid arrow left by to the mark on the original horizontal axis, then follow the vertical solid arrow up by . This reaches exactly the blue point.
The and beside the arrows are the magnitudes of the two displacements. The horizontal arrow points left, so the horizontal coordinate is negative; the vertical arrow points up, so the vertical coordinate is positive. Writing them in horizontal, vertical order gives:
Now look again at the purple slanted axis through the blue point. It starts at the origin and passes through this position to the left and above the origin, so it tilts upward to the left. This is the direction of the new vertical axis in the first diagram.
All five diagrams follow the same point. Reading along the new axes gives ; reading along the original axes gives . Both pairs of numbers describe the same position.
More generally, this diagram has . Moving upward along the new vertical axis gives , so : these points all lie to the left of the original vertical axis. The larger is, the farther left they lie, by a distance .
Thus in this diagram the new vertical axis tilts left while the horizontal axis stays unchanged. The angle between the two positive half-axes is greater than a right angle. This is an oblique coordinate system, not a rotation of the entire original rectangular coordinate system; understanding it requires no angle calculation.
Why we later describe points as moving
So far the points stayed fixed while we changed the axes used to read them. Below, to observe how the figure changes, we keep the original rectangular axes fixed and use the calculated numbers to draw a new point. These are two different operations and must be distinguished.
Again take point with original coordinates and . First calculate:
- Keep the point fixed and change coordinates: remains in its original position. Its coordinates read in the original rectangular system and in the new oblique system. These readings belong to different coordinate systems.
- Keep the axes fixed and draw a new point: retain the original rectangular system and plot in that system as a new point . The original point has horizontal coordinate and the new point has horizontal coordinate , a difference of . Both have vertical coordinate , so this moves right by to obtain .
Both operations use the same formula and calculate the same numbers, but use different coordinate systems when drawing. From the next section onward, we consistently use the second interpretation: keep the axes fixed and compare the original points with the transformed new points.
Example: a small-looking coefficient can still reverse order
Take two points and . In a sweep-line algorithm, the positions of segment endpoints and intersections to be processed are called "event positions." For now, consider only the left-to-right relationship of these two points.
Write for the original horizontal coordinate of and for that of . The subscripts name the points; they do not mean multiplication. Denote the transformed new points by , with horizontal coordinates .
Originally and . Since , is to the left of . Choose and substitute each point's coordinates into :
For point , calculate in the same way:
Heights stay unchanged, but the higher point moves right by , passing the stationary point :
This is a schematic diagram; the horizontal and vertical axes use different scales. Dashed lines show the projections of and onto the horizontal axis.
How small must the coefficient be?
Here "preserving order" means that if was originally to the left of , then must remain to the left of after transformation. The result above shows that is not small enough for these two points.
Instead of fixing , now treat as an unknown positive number. Substituting the coordinates of the two points again gives:
For to remain strictly to the left of , its horizontal coordinate must be smaller:
Replace by and by :
Divide both sides by . Since is positive, the inequality direction stays the same:
Cancel the common factor on the left:
Multiply both numerator and denominator of the fraction by to write it as a decimal:
This article requires to be positive, so the permitted range is . Check this range and its boundary:
- If , multiplying by the positive number gives . Thus , preserving the original left-to-right order.
- If , then , while . The points have the same horizontal coordinate, so neither is to the left of the other. Their vertical coordinates are still and , however, so the points do not coincide.
- If , multiplying by the positive number gives . Thus : is now to the right of , and the order has reversed.
If , the formulas become and , leaving every point at its original position. We discuss positive coefficients here so that the figure is actually sheared.
In this example, the original horizontal gap is , and the height difference is . Shearing moves right by more than . Only when this extra distance is less than the original gap will neither catch up with nor pass . This is the geometric meaning of .
Thus the number of decimal places in a coefficient does not tell us whether it is small enough. We must also consider horizontal gaps and height differences. The following articles bound these quantities to choose one sufficiently small positive coefficient for every event the algorithm must process.