Skip to main content
Mathematics LibreTexts

13.2: Transformation Matrix

  • Page ID
    65483
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Consider the following set of points:

    %matplotlib inline
    import matplotlib.pylab as plt
    
    x = [0.0,  0.0,  2.0,  8.0, 10.0, 10.0, 8.0, 4.0, 3.0, 3.0, 4.0, 6.0, 7.0, 7.0, 10.0, 
         10.0,  8.0,  2.0, 0.0, 0.0, 2.0, 6.0, 7.0,  7.0,  6.0,  4.0,  3.0, 3.0, 0.0]
    y = [0.0, -2.0, -4.0, -4.0, -2.0,  2.0, 4.0, 4.0, 5.0, 7.0, 8.0, 8.0, 7.0, 6.0,  6.0,
         8.0, 10.0, 10.0, 8.0, 4.0, 2.0, 2.0, 1.0, -1.0, -2.0, -2.0, -1.0, 0.0, 0.0]
    
    plt.plot(x,y, color='green');
    plt.axis('equal');

    We can rotate these points around the origin by using the following simple set of equations:

    \[ x \cos(\theta) - y \sin(\theta) = x_{rotated} \nonumber \]

    \[ x \sin(\theta) + y \cos(\theta) = y_{rotated} \nonumber \]

    This can be rewritten as the following system of matrices:

    \[\begin{split}
    \left[
    \begin{matrix}
    \cos(\theta) & -\sin(\theta) \\
    \sin(\theta) & \cos(\theta)
    \end{matrix}
    \right]
    \left[
    \begin{matrix}
    x \\
    y
    \end{matrix}
    \right]
    =
    \left[
    \begin{matrix}
    x_{rotated}\\
    y_{rotated}
    \end{matrix}
    \right]
    \end{split} \nonumber \]

    We can rotate the points around the origin by \(\pi/4\) (i.e. \(45^o\)) as follows:

    import numpy as np
    import sympy as sym
    sym.init_printing(use_unicode=True) # Trick to make matrixes look nice in jupyter
    
    points = np.matrix([x,y])
    angle = np.pi/4
    R = np.matrix([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]]);
    sym.Matrix(R)
    p=R*points
    
    plt.plot(p[0].T,p[1].T);
    plt.axis('equal');
    
    #print(p[0].T)

    We can even have a little fun and keep applying the same rotation over and over again.

    # Apply R and plot 8 times
    for i in range(0,8):
        p = R * p
        plt.plot(p[0].T,p[1].T);
    
    plt.axis('equal');
    Question

    In the above code what does the T call in p[0].T do?


    This page titled 13.2: Transformation Matrix is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?