Skip to main content

Composite matrix: reflection about y=mx+c

Short answer

Reflection about y=mx+c is M=T(0,c)*R(theta)*Ref_x*R(-theta)*T(0,-c), where theta=arctan(m). Simplified, M = 1/(1+m^2) times [[1-m^2, 2m, -2mc], [2m, m^2-1, 2c], [0, 0, 1+m^2]].

Find the composite transformation matrix for reflection about a line y = mx + c.

A line y = mx + c has slope m = tan θ and y-intercept (0, c). A reflection about it is a composite of five basic transformations.

Step 1: translate the line so that it passes through the origin:
        T1 = T(0, −c)
Step 2: rotate by −θ so that the line lies along the x-axis,
        θ = tan⁻¹(m):  R(−θ)
Step 3: reflect about the x-axis:  Ref_x
Step 4: rotate back by +θ:  R(θ)
Step 5: translate back:  T2 = T(0, c)

The composite matrix (column-vector form, applied right to left) is

M = T(0,c) · R(θ) · Ref_x · R(−θ) · T(0,−c)

| 1 0 0 |   | cosθ −sinθ 0 |   | 1  0 0 |   |  cosθ sinθ 0 |   | 1 0  0 |
| 0 1 c | · | sinθ  cosθ 0 | · | 0 −1 0 | · | −sinθ cosθ 0 | · | 0 1 −c |
| 0 0 1 |   |  0     0   1 |   | 0  0 1 |   |   0    0   1 |   | 0 0  1 |

First, R(θ)·Ref_x·R(−θ) is

| cos²θ − sin²θ    2 sinθ cosθ  0 |   | cos2θ   sin2θ  0 |
| 2 sinθ cosθ   sin²θ − cos²θ   0 | = | sin2θ  −cos2θ  0 |
|      0              0         1 |   |   0       0    1 |

Including the translations:

        | cos2θ   sin2θ   −c·sin2θ     |
   M =  | sin2θ  −cos2θ    c(1+cos2θ)  |
        |   0       0          1        |

Using cos2θ = (1 − m²)/(1 + m²) and sin2θ = 2m/(1 + m²):

              | 1−m²    2m     −2mc  |
 M = 1/(1+m²) | 2m     m²−1     2c   |
              |  0       0     1+m²  |

Check: the point (0, c) on the line gives x' = (2m·c − 2mc)/(1+m²) = 0 and y' = ((m²−1)c + 2c)/(1+m²) = c, so points on the line do not move. For c = 0, m = 1 it gives [[0,1,0],[1,0,0],[0,0,1]], the reflection about y = x.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 3 questions →