Skip to main content

How Shear Changes Coordinates

Starting from x′=x+syx'=x+sy and y′=yy'=y, we first examine what a shear changes and why we cannot simply choose a coefficient that looks small.

Here x,yx,y are the original horizontal and vertical coordinates, and x′,y′x',y' are the new coordinates. The prime only distinguishes new from old; x′x' can be read as "the new horizontal coordinate." ss is a number we choose, called the "shear coefficient," and sysy means s×ys\times y. To evaluate the formula, first multiply the vertical coordinate by ss, then add the result to the original horizontal coordinate; leave the vertical coordinate unchanged. This article uses positive ss.

Diagram: the same point in a different coordinate system​

First use s=12s=\tfrac12 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.

The two diagrams keep each point in the same position relative to the origin. In the original coordinate system P is (2,2) and Q is (-1,-1); in the new oblique system P is (3,2) and Q is (-3/2,-1). Dashed lines project along the respective axis directions.The two diagrams keep each point in the same position relative to the origin. In the original coordinate system P is (2,2) and Q is (-1,-1); in the new oblique system P is (3,2) and Q is (-3/2,-1). Dashed lines project along the respective axis directions.

Legend: the points in both diagrams are labeled P\teachBlue{P} and Q\teachOrange{Q}; 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:

  1. To read the new horizontal coordinate x′x', draw through the point a line parallel to the new vertical axis y′y', find where it meets the new horizontal axis x′x', and read the scale.
  2. To read the new vertical coordinate y′y', draw through the point a line parallel to the new horizontal axis x′x', find where it meets the new vertical axis y′y', 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 PP in the right diagram. A line through PP parallel to the slanted vertical axis meets the horizontal axis at 33, so x′=3x'=3; a horizontal line through PP meets the slanted vertical axis at 22, so y′=2y'=2. Together these give the new coordinates (3,2)(3,2). 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 22 step by step below.

For the two points, respectively,

P:x′=2+12×2=2+1=3,y′=2,\teachBlue{P}:\quad x'=2+\frac12\times2=2+1=\teachBlue{3},\qquad y'=\teachBlue{2}, Q:x′=−1+12×(−1)=−1−12=−22−12=−32,y′=−1.\teachOrange{Q}:\quad x'=-1+\frac12\times(-1)=-1-\frac12=-\frac22-\frac12=\teachOrange{-\frac32},\qquad y'=\teachOrange{-1}.

We add sysy, 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:

x′=x+sy,y′=y.x'=x+sy,\qquad y'=y.

Here (x,y)(x,y) are a point's original coordinates, and (x′,y′)(x',y') are the same point's new coordinates. The formulas above calculate new coordinates from old ones. We now reverse the process: given x′,y′x',y', find x,yx,y, so that we can locate the new axes in the original diagram.

Start with the second equation. y′=yy'=y says that the two numbers are equal, so we can also write:

y=y′.y=y'.

Now consider the first equation:

x′=x+sy.x'=x+sy.

Since y=y′y=y', replace yy on the right by y′y':

x′=x+sy′.x'=x+sy'.

To leave xx alone on the right, subtract sy′sy' from both sides:

x′−sy′=x+sy′−sy′.x'-sy'=x+sy'-sy'.

On the right, +sy′+sy' and −sy′-sy' cancel, so:

x′−sy′=x.x'-sy'=x.

Exchange the left and right sides:

x=x′−sy′.x=x'-sy'.

Together with y=y′y=y' above, this gives the formulas for recovering the original coordinates from the new ones:

x=x′−sy′,y=y′.x=x'-sy',\qquad y=y'.

Why the horizontal axis stays unchanged​

Look at the following diagram. The gray solid line is the original horizontal axis xx, and the purple dashed line is the new horizontal axis x′x'. 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 −1-1, 11, and 22.

The gray original horizontal axis and the purple dashed new horizontal axis coincide. Blue points lie at the shared marks -1, 1, and 2; the point at 2 has coordinates (2,0) in both systems.The gray original horizontal axis and the purple dashed new horizontal axis coincide. Blue points lie at the shared marks -1, 1, and 2; the point at 2 has coordinates (2,0) in both systems.

First look at the blue point labeled (2,0)(2,0) on the right. It lies on the new horizontal axis, with new horizontal coordinate x′=2x'=2 and new vertical coordinate y′=0y'=0. We want to check whether it also lies at the mark 22 on the original horizontal axis.

Use the formulas we just derived to convert the new coordinates back to the originals:

x=x′−sy′,y=y′.x=x'-sy',\qquad y=y'.

Find the original vertical coordinate first. Since this point has y′=0y'=0,

y=y′=0.y=y'=0.

Its original vertical coordinate is 00, so it also lies on the original horizontal axis. Now find its original horizontal coordinate by substituting x′=2x'=2 and y′=0y'=0:

x=2−s×0.x=2-s\times0.

Any number multiplied by 00 gives 00, so:

x=2−0=2.x=2-0=2.

Thus this blue point has new coordinates (2,0)(2,0) and original coordinates (2,0)(2,0) 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 x′=2x'=2 above by x′=−1x'=-1 or x′=1x'=1, keeping y′=0y'=0. The same calculation gives x=−1x=-1 or x=1x=1. 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 y′=0y'=0. Let x′x' be any number; substitution always gives:

x=x′−s×0=x′−0=x′,y=0.x=x'-s\times0=x'-0=x',\qquad y=0.

In other words, every position on the new horizontal axis lies on the original horizontal axis with the same reading: 00 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 x′=0x'=0. Substitute x′=0x'=0 into the same formulas:

x=0−sy′=−sy′,y=y′.x=0-sy'=-sy',\qquad y=y'.

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:

s=12.s=\frac12.

Step 1: Look at the circled point on the new vertical axis.

In the following diagram, the two purple axes meet at the origin OO. The horizontal one is the new horizontal axis x′x', and the one slanting upward to the left is the new vertical axis y′y'. Looking upward along the slanted axis from OO, we find the marks 11 and 22 in order. The blue ring circles the point at the mark 22.

A blue point is circled at the mark 2 on the new vertical axis, indicating y′=2.A blue point is circled at the mark 2 on the new vertical axis, indicating y′=2.

This step only selects a point; no calculation has been made. Because we chose the point at the mark 22 on the new vertical axis, we read directly:

y′=2.y'=2.

Here 22 is the new vertical coordinate. It does not mean that the actual distance from OO to the blue point is 22. Next we read its new horizontal coordinate.

Step 2: Follow the slanted axis back to the horizontal axis and read x′=0x'=0.

The following diagram adds an arrow from the blue point toward the origin. To read x′x', we must reach the new horizontal axis in a direction parallel to the new vertical axis y′y'. The point already lies on the new vertical axis, so following that slanted axis downward to the right reaches the circled origin OO.

A blue arrow follows the new vertical axis from the selected point to the origin, indicating x′=0; the new coordinates are therefore (0,2).A blue arrow follows the new vertical axis from the selected point to the origin, indicating x′=0; the new coordinates are therefore (0,2).

The arrow reaches the new horizontal axis at OO, and OO has horizontal coordinate 00. Hence:

x′=0.x'=0.

This agrees with the familiar rule: points on the original vertical axis satisfy x=0x=0, and points on the new vertical axis satisfy x′=0x'=0. Drawing the axis at a slant does not change that rule.

Combine this with y′=2y'=2 from the first diagram, writing the horizontal coordinate first and the vertical coordinate second:

(x′,y′)=(0,2).(x',y')=(0,2).

Notice that the arrow follows the slanted axis. Drawing a vertical perpendicular downward at this stage would not read the new horizontal coordinate x′x'; 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 (0,2)(0,2), and turn to its original coordinates. The next diagram adds the gray original vertical axis yy. The bottom horizontal axis is labeled with both x,x′x,x' because the original and new horizontal axes coincide.

A horizontal dashed line joins the same blue point to the mark 2 on the original vertical axis, indicating y=y′=2.A horizontal dashed line joins the same blue point to the mark 2 on the original vertical axis, indicating y=y′=2.

Look rightward from the blue point along the horizontal dashed line. It meets the gray original vertical axis at 22, so the blue point's original vertical coordinate is also 22.

Why do the two vertical axes give the same reading? Recall the original transformation in this example:

x′=x+12y,y′=y.x'=x+\frac12y,\qquad y'=y.

The second equation, y′=yy'=y, says that the new and original vertical coordinates agree. In step 1 we chose y′=2y'=2, so:

y=y′=2.y=y'=2.

The 22 labels at both ends of the horizontal dashed line show exactly this equality. Only the original horizontal coordinate xx 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 yy, so where it meets the bottom horizontal axis gives the original horizontal coordinate xx. This reading uses the original axes, so the direction differs from the slanted arrow in the second diagram.

A vertical dashed line parallel to the original vertical axis runs from the blue point to -1 on the horizontal axis, indicating the original horizontal coordinate x=-1.A vertical dashed line parallel to the original vertical axis runs from the blue point to -1 on the horizontal axis, indicating the original horizontal coordinate x=-1.

The diagram labels this endpoint −1-1. This number is calculated, not estimated: step 2 gave x′=0x'=0, and step 3 gave y=2y=2. The original formula is:

x′=x+12y.x'=x+\frac12y.

Replace x′x' on the left by 00 and yy on the right by 22:

0=x+12×2.0=x+\frac12\times2.

Perform the multiplication first. Since 12×2=1\frac12\times2=1,

0=x+1.0=x+1.

Subtract 11 from both sides:

0−1=x+1−1.0-1=x+1-1.

Simplifying gives −1=x-1=x, or:

x=−1.x=-1.

The vertical dashed line therefore meets the axis to the left of the origin, and the original horizontal coordinate is indeed −1-1. Compare with the second diagram: for the same blue point, reading along the slanted axis gives x′=0x'=0, while reading in the original vertical-axis direction gives x=−1x=-1. 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 OO, follow the horizontal solid arrow left by 11 to the mark −1-1 on the original horizontal axis, then follow the vertical solid arrow up by 22. This reaches exactly the blue point.

Two solid arrows go left by 1 and up by 2 from the origin, reaching the same point with original coordinates (-1,2).Two solid arrows go left by 1 and up by 2 from the origin, reaching the same point with original coordinates (-1,2).

The 11 and 22 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:

(x,y)=(−1,2).(x,y)=(-1,2).

Now look again at the purple slanted axis through the blue point. It starts at the origin and passes through this position 11 to the left and 22 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 (0,2)(0,2); reading along the original axes gives (−1,2)(-1,2). Both pairs of numbers describe the same position.

More generally, this diagram has s>0s>0. Moving upward along the new vertical axis gives y′>0y'>0, so x=−sy′<0x=-sy'<0: these points all lie to the left of the original vertical axis. The larger y′y' is, the farther left they lie, by a distance sy′sy'.

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 PP with original coordinates (2,2)(2,2) and s=1/2s=1/2. First calculate:

x′=2+12×2=2+1=3,y′=2.x'=2+\frac12\times2=2+1=3,\qquad y'=2.
  • Keep the point fixed and change coordinates: PP remains in its original position. Its coordinates read (2,2)(2,2) in the original rectangular system and (3,2)(3,2) 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 (3,2)(3,2) in that system as a new point P′P'. The original point PP has horizontal coordinate 22 and the new point P′P' has horizontal coordinate 33, a difference of 3−2=13-2=1. Both have vertical coordinate 22, so this moves PP right by 11 to obtain P′P'.

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 A=(0,200)A=(0,200) and B=(1,0)B=(1,0). 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 xAx_A for the original horizontal coordinate of AA and xBx_B for that of BB. The subscripts A,BA,B name the points; they do not mean multiplication. Denote the transformed new points by A′,B′A',B', with horizontal coordinates xA′,xB′x'_A,x'_B.

Originally xA=0x_A=0 and xB=1x_B=1. Since 0<10<1, AA is to the left of BB. Choose s=0.01=1/100s=0.01=1/100 and substitute each point's coordinates into x′=x+syx'=x+sy:

xA′=0+1100×200=0+200100=0+2=2.x'_A=0+\frac1{100}\times200=0+\frac{200}{100}=0+2=2.

For point BB, calculate in the same way:

xB′=1+1100×0=1+0=1.x'_B=1+\frac1{100}\times0=1+0=1.

Heights stay unchanged, but the higher point AA moves right by 22, passing the stationary point BB:

Before shearing A is to the left of B. With s = 0.01, A moves from horizontal coordinate 0 to 2, passing B at horizontal coordinate 1.Before shearing A is to the left of B. With s = 0.01, A moves from horizontal coordinate 0 to 2, passing B at horizontal coordinate 1.

This is a schematic diagram; the horizontal and vertical axes use different scales. Dashed lines show the projections of AA and A′A' onto the horizontal axis.

How small must the coefficient be?​

Here "preserving order" means that if AA was originally to the left of BB, then A′A' must remain to the left of B′B' after transformation. The result above shows that 0.010.01 is not small enough for these two points.

Instead of fixing s=0.01s=0.01, now treat ss as an unknown positive number. Substituting the coordinates of the two points again gives:

xA′=0+s×200=200s,x'_A=0+s\times200=200s, xB′=1+s×0=1+0=1.x'_B=1+s\times0=1+0=1.

For A′A' to remain strictly to the left of B′B', its horizontal coordinate must be smaller:

xA′<xB′.x'_A<x'_B.

Replace xA′x'_A by 200s200s and xB′x'_B by 11:

200s<1.200s<1.

Divide both sides by 200200. Since 200200 is positive, the inequality direction stays the same:

200s200<1200.\frac{200s}{200}<\frac1{200}.

Cancel the common factor 200200 on the left:

s<1200.s<\frac1{200}.

Multiply both numerator and denominator of the fraction by 55 to write it as a decimal:

1200=1×5200×5=51000=0.005.\frac1{200}=\frac{1\times5}{200\times5}=\frac5{1000}=0.005.

This article requires ss to be positive, so the permitted range is 0<s<0.0050<s<0.005. Check this range and its boundary:

  • If 0<s<1/2000<s<1/200, multiplying by the positive number 200200 gives 200s<1200s<1. Thus xA′<xB′x'_A<x'_B, preserving the original left-to-right order.
  • If s=1/200s=1/200, then xA′=200×(1/200)=200/200=1x'_A=200\times(1/200)=200/200=1, while xB′=1x'_B=1. The points have the same horizontal coordinate, so neither is to the left of the other. Their vertical coordinates are still 200200 and 00, however, so the points do not coincide.
  • If s>1/200s>1/200, multiplying by the positive number 200200 gives 200s>1200s>1. Thus xA′>xB′x'_A>x'_B: A′A' is now to the right of B′B', and the order has reversed.

If s=0s=0, the formulas become x′=x+0×y=xx'=x+0\times y=x and y′=yy'=y, 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 1−0=11-0=1, and the height difference is 200−0=200200-0=200. Shearing moves AA right by 200s200s more than BB. Only when this extra distance is less than the original gap 11 will AA neither catch up with nor pass BB. This is the geometric meaning of 200s<1200s<1.

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.