Chaitanya's Random Pages

January 26, 2015

Affine Transformations of Cartesian Coordinates

Filed under: mathematics — ckrao @ 11:43 am

A very common exercise in high school mathematics is to plot transformations of some standard functions. For example, to plot y = 2\sin (5x + \frac{2\pi}{3}) - 1 we may start with a standard sine curve and apply the following transformations in turn:

  • squeeze it by a factor of 5 in the x-direction
  • shift it left by \frac{2\pi}{3}
  • stretch it by a factor of 2 in the y-direction
  • shift it down by 1

This leads to the plot shown.


For sine and cosine graphs an alternative is to plot successive peaks/troughs of the curve and interpolate accordingly. For example, to plot y = 2\sin (5x + \frac{2\pi}{3}) - 1 we may proceed as follows.

  • Since \sin(x) has a peak at \frac{\pi}{2}, solve 5x + \frac{2\pi}{3} = \frac{\pi}{2} to find x = -\frac{\pi}{30} as a point where there is a peak at y = 2\times 1 - 1 = 1. Hence plot the point (-\frac{\pi}{30},1).
  • Since the angular frequency is 5, the period is \frac{2\pi}{5} and we may plot successive peaks spaced \frac{2\pi}{5} apart from the point (-\frac{\pi}{30},1).
  • Troughs will be equally spaced halfway between the peaks at y = 2\times (-1) - 1 = -3 (at x = -\frac{\pi}{30} + \frac{\pi}{5} + k\frac{2\pi}{5}). Then join the dots with a sinusoidal curve.
  • Additionally x- and y- intercepts may be found by setting y = 0 and x = 0 respectively. We find that the x-intercepts are at x = \frac{2\pi k}{5} - \frac{\pi}{10}, \frac{2\pi k}{5} + \frac{\pi}{30}\ (k \in \mathbb{Z}) and y-intercept is y = 2\sin (\frac{2\pi}{3}) - 1 = \sqrt{3}-1.


The first approach is more generalisable to plotting other functions. Instead of thinking of the graph transforming, we also may consider it as a change of coordinates. For example, if we translate the parabola y = x^2 so that its turning point is at (2,1), this is equivalent to keeping the parabola fixed and shifting axes so that the new origin is at (-2,-1) with respect to the old coordinates. This is illustrated below where the black coordinates are modified to the red ones. The parabola has equation y = x^2 under the black coordinates and y - 1 = (x-2)^2 or y = (x-2)^2 + 1 under the red coordinates.


As another example suppose we take a unit circle and stretch it by a factor of 2 in the x direction and a factor of 3 in the y direction. This is the equivalent of changing scale so that the x-axis is squeezed by 2 and the y-axis is squeezed by 3.



Under this stretching of the circle or squeezing of axes, the unit circle equation x^2 + y^2 = 1 transforms to that of the ellipse \left(\frac{x}{2}\right)^2 + \left(\frac{y}{3}\right)^2 = 1.

More generally, by stretching a Cartesian graph f(x,y) = 0 by a in the x-direction and b in the y-direction, then shifting it along the vector (h,k), we obtain the equation

\displaystyle f\left(\frac{x-h}{a}, \frac{y-k}{b}\right) = 0.

This uses the fact that \frac{x-h}{a} and \frac{y-k}{b} are the inverses of ax+h and by+k respectively. Note that if |a| or |b| are less than 1, the stretch becomes a squeezing of the graph, while a < 0 or b < 0 correspond to a reflection in the x or y axes.

We can extend this idea to the rotation of a graph. Suppose for example we wish to rotate the hyperbola y = 1/x by 45 degrees anti-clockwise. This is equivalent to a rotation of the axes by 45 degrees clockwise and the matrix corresponding to this linear transform is

\displaystyle \left[ \begin{array} {c} x' \\ y' \end{array} \right] = \frac{1}{\sqrt{2}}\left[ \begin{array}{rr} 1 & 1\\ -1 & 1 \end{array} \right] \left[ \begin{array} {c} x \\ y \end{array} \right] = \left[ \begin{array} {c} \frac{x+y}{\sqrt{2}} \\ \frac{-x+y}{\sqrt{2}}\end{array} \right].

(Here the columns of the change of basis matrix correspond to where the basis vectors (1,0) and (0,1) map to under a 45 degree clockwise rotation.)

In other words we replace x' with (x+y)/\sqrt{2} and y' with (-x+y)/\sqrt{2} in the equation y' = 1/x' and obtain (-x+y)/\sqrt{2} = 1/( (x+y)/\sqrt{2}) or y^2 - x^2 = 2.


Here is the same transformation applied to the parabola y = x^2 to obtain \frac{-x+y}{\sqrt{2}} = \frac{(x+y)^2}{2} or x^2 + y^2 + 2xy + \sqrt{2}(x-y) = 0:


If a graph is affinely transformed (by an invertible map) so that (1,0) maps to (a,b) and (0,1) maps to (c,d) followed by a shift along the vector (h,k), then this is equivalent to the coordinates shifting by (-h,-k) and then transforming under the inverse mapping \displaystyle \left[ \begin{array}{cc} a & c\\ b & d\end{array} \right]^{-1} = \frac{1}{ad-bc} \left[ \begin{array}{cc} d & -c\\ -b & a\end{array} \right]:

\displaystyle \boxed{\begin{aligned} x' &= (x-h) \frac{d}{ad-bc} - (y-k) \frac{c}{ad-bd}\\ y' &= -(x-h) \frac{b}{ad-bc} + (y-k) \frac{a}{ad-bd}\end{aligned}}

Here are some special cases of this formula:

  • rotation of the graph by \theta anti-clockwise: \displaystyle x' = x\cos \theta + y \sin \theta, y' = - x \sin \theta + y\cos \theta (the example \theta = \pi/4 was done above)
  • reflection of the graph in y = x: x' = y, y' = x
  • reflection of the graph in y = mx where m = \tan \theta: verify that a = \cos 2\theta, b = \sin 2\theta, c = \sin 2\theta, d = -\cos 2\theta so \displaystyle x' = x \cos 2\theta + y \sin 2\theta, y' = x \sin 2\theta - y \cos 2\theta
  • reflection of the graph in y = mx + c where m = \tan \theta: this is equivalent to a reflection in the line y = mx followed by a shift along the vector (h,k) = (-c \sin 2\theta, c (1+\cos 2 \theta) ) so
    \displaystyle \begin{aligned} x' &= (x+c \sin 2\theta)\cos 2\theta + (y-c(1+\cos 2\theta))\sin 2\theta\\ &= x \cos 2\theta + (y-c)\sin 2\theta,\\ y' &= (x+c \sin 2\theta)\sin 2\theta - (y-c(1+\cos 2\theta))\cos 2\theta\\ &= x \sin 2\theta - (y-c) \cos 2\theta + c \end{aligned}
  • reflection of the graph in y = x + c (special instance of the previous case with \sin 2\theta = 1, \cos 2\theta = 0): x'= y - c, y' = x+c

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: