Skip to main content
Mathematics LibreTexts

Computer Graphics

  • Page ID
    218305
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \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}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Computer Graphics

    The Geometry of 2 x 2 Matrices

    Since a 2 x 2 matrix corresponds uniquely to a linear transformation from R2 to R2, we can think of a matrix as transforming a planar figure into a new planar figure.  

    Example

    Consider the matrix

            \( A = \begin{pmatrix} 1 & -2 \\ 3 & -4 \end{pmatrix} \)

    and the triangle with vertices (0,0), (12), (5,3).  We have

            \( \begin{pmatrix} 1 & -2 \\ 3 & -4 \end{pmatrix} \begin{pmatrix} 0 \\ 0 \end{pmatrix}  = \begin{pmatrix} 0 \\ 0 \end{pmatrix}  \)           \( \begin{pmatrix} 1 & -2 \\ 3 & -4 \end{pmatrix} \begin{pmatrix} 1 \\ 2 \end{pmatrix}  = \begin{pmatrix} -3 \\ -5 \end{pmatrix}  \)           \( \begin{pmatrix} 1 & -2 \\ 3 & -4 \end{pmatrix} \begin{pmatrix} 5 \\ 3 \end{pmatrix}  = \begin{pmatrix} -1 \\ 3 \end{pmatrix}  \)            

        

    It is a property of linear transformations that if the matrix is nonsingular, then line segments map onto line segments.  Hence triangles map onto triangles.  The picture below shows the original triangle.

            Two separate graphs of triangles.  The first has vertices (0,0), (5,3), and (1,2).  The second has vertices (0,0), (-1,3), and (-3,-5).


    Some Basic Transformations

    There are certain basic transformation that are building blocks for general transformations.

    Example  Reflection With Respect to the x axis.

    To find the matrix for this transformation, we consider where the vectors e1 and e2 are mapped.  The reflection with respect to the x-axis makes the y-coordinate negative and leaves the x-coordinate constant.  We have

            L(1, 0)  =  (1, 0)        L(0, 1)  =  (0, -1)

    These vectors are the column vectors for the matrix.  We have

            \( A = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \)


    Example  Reflection About the Line y = x

    We see that 

            L(1,0)  =  (0,1)        L(0,1)  =  (1,0)

    so that 

            \( A = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \)


    Example  Rotation About an Angle q

    The point (0,1) rotated about this angle is on the unit circle at radian angle q.  The point (1,0) rotated about this angle is on the unit circle at radian angle p/2 + q.  We have

            L(1,0)  =  (cos q, sin q)        L(0,1)  =  (cos(p/2 + q), sin(p/2 + q)  =  (-sin q, cos q)

    We have 

            \( A = \begin{pmatrix} cos(\theta) & -sin(\theta) \\ sin(\theta) & cos(\theta) \end{pmatrix} \)


    Example  Shear in the y-direction

    Another transformation that is common in computer graphics is a shear in the x or y direction.  The picture below gives and example

            Two pictures of a person.  The first is normal.  The second is sheared vertically looking a bit rotated.

    The matrix that makes this happen is 

              \( A = \begin{pmatrix} 1 & 0 \\ k & 1 \end{pmatrix} \)

    for some constant k

    You can find an interactive applets that lets you play with computer graphics and matrices at

            Matrix Transformations



    Back to the Vectors Page

     

     

    Computer Graphics is shared under a CC BY license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?