In linear algebra, linear transformations can be represented by matrices. If 
  
    
      
        T
      
    
    {\displaystyle T}
  
 is a linear transformation mapping 
  
    
      
        
          
            R
          
          
            n
          
        
      
    
    {\displaystyle \mathbb {R} ^{n}}
  
 to 
  
    
      
        
          
            R
          
          
            m
          
        
      
    
    {\displaystyle \mathbb {R} ^{m}}
  
 and 
  
    
      
        
          x
        
      
    
    {\displaystyle \mathbf {x} }
  
 is a column vector with 
  
    
      
        n
      
    
    {\displaystyle n}
  
 entries, then
  Matrices allow arbitrary linear transformations to be displayed in a consistent format, suitable for computation.  This also allows transformations to be composed easily (by multiplying their matrices).
 Linear transformations are not the only ones that can be represented by matrices.  Some transformations that are non-linear on an n-dimensional Euclidean space Rn can be represented as linear transformations on the n+1-dimensional space Rn+1. These include both affine transformations (such as translation) and projective transformations. For this reason, 4×4 transformation matrices are widely used in 3D computer graphics. These n+1-dimensional transformation matrices are called, depending on their application, affine transformation matrices, projective transformation matrices, or more generally non-linear transformation matrices.  With respect to an n-dimensional matrix, an n+1-dimensional matrix can be described as an augmented matrix.
 In the physical sciences, an active transformation is one which actually changes the physical position of a system, and makes sense even in the absence of a coordinate system whereas a passive transformation is a change in the coordinate description of the physical system (change of basis). The distinction between active and passive transformations is important. By default, by transformation, mathematicians usually mean active transformations, while physicists could mean either.
 Put differently, a passive transformation refers to description of the same object as viewed from two different coordinate frames.
 If one has a linear transformation 
  
    
      
        T
        (
        x
        )
      
    
    {\displaystyle T(x)}
  
 in functional form, it is easy to determine the transformation matrix A by transforming each of the vectors of the standard basis by T, then inserting the result into the columns of a matrix. In other words,
  For example, the function 
  
    
      
        T
        (
        x
        )
        =
        5
        x
      
    
    {\displaystyle T(x)=5x}
  
 is a linear transformation.  Applying the above process (suppose that n = 2 in this case) reveals that
  The matrix representation of vectors and operators depends on the chosen basis; a similar matrix will result from an alternate basis. Nevertheless, the method to find the components remains the same.
 To elaborate, vector 
  
    
      
        
          v
        
      
    
    {\displaystyle \mathbf {v} }
  
 can be represented in basis vectors, 
  
    
      
        E
        =
        
          
            [
            
              
                
                  
                    
                      e
                    
                    
                      1
                    
                  
                
                
                  
                    
                      e
                    
                    
                      2
                    
                  
                
                
                  ⋯
                
                
                  
                    
                      e
                    
                    
                      n
                    
                  
                
              
            
            ]
          
        
      
    
    {\displaystyle E={\begin{bmatrix}\mathbf {e} _{1}&\mathbf {e} _{2}&\cdots &\mathbf {e} _{n}\end{bmatrix}}}
  
 with coordinates 
  
    
      
        [
        
          v
        
        
          ]
          
            E
          
        
        =
        
          
            
              [
              
                
                  
                    
                      v
                      
                        1
                      
                    
                  
                  
                    
                      v
                      
                        2
                      
                    
                  
                  
                    ⋯
                  
                  
                    
                      v
                      
                        n
                      
                    
                  
                
              
              ]
            
          
          
            
              T
            
          
        
      
    
    {\displaystyle [\mathbf {v} ]_{E}={\begin{bmatrix}v_{1}&v_{2}&\cdots &v_{n}\end{bmatrix}}^{\mathrm {T} }}
  
:
  Now, express the result of the transformation matrix A upon 
  
    
      
        
          v
        
      
    
    {\displaystyle \mathbf {v} }
  
, in the given basis:
  The 
  
    
      
        
          a
          
            i
            ,
            j
          
        
      
    
    {\displaystyle a_{i,j}}
  
 elements of matrix A are determined for a given basis E by applying A to every 
  
    
      
        
          
            e
          
          
            j
          
        
        =
        
          
            
              [
              
                
                  
                    0
                  
                  
                    0
                  
                  
                    ⋯
                  
                  
                    (
                    
                      v
                      
                        j
                      
                    
                    =
                    1
                    )
                  
                  
                    ⋯
                  
                  
                    0
                  
                
              
              ]
            
          
          
            
              T
            
          
        
      
    
    {\displaystyle \mathbf {e} _{j}={\begin{bmatrix}0&0&\cdots &(v_{j}=1)&\cdots &0\end{bmatrix}}^{\mathrm {T} }}
  
, and observing the response vector
  This equation defines the wanted elements, 
  
    
      
        
          a
          
            i
            ,
            j
          
        
      
    
    {\displaystyle a_{i,j}}
  
, of j-th column of the matrix A.
 Yet, there is a special basis for an operator in which the components form a diagonal matrix and, thus, multiplication complexity reduces to n. Being diagonal means that all coefficients 
  
    
      
        
          a
          
            i
            ,
            j
          
        
      
    
    {\displaystyle a_{i,j}}
  
 except 
  
    
      
        
          a
          
            i
            ,
            i
          
        
      
    
    {\displaystyle a_{i,i}}
  
 are zeros leaving only one term in the sum 
  
    
      
        ∑
        
          a
          
            i
            ,
            j
          
        
        
          
            e
          
          
            i
          
        
      
    
    {\textstyle \sum a_{i,j}\mathbf {e} _{i}}
  
 above. The surviving diagonal elements, 
  
    
      
        
          a
          
            i
            ,
            i
          
        
      
    
    {\displaystyle a_{i,i}}
  
, are known as eigenvalues and designated with 
  
    
      
        
          λ
          
            i
          
        
      
    
    {\displaystyle \lambda _{i}}
  
 in the defining equation, which reduces to 
  
    
      
        A
        
          
            e
          
          
            i
          
        
        =
        
          λ
          
            i
          
        
        
          
            e
          
          
            i
          
        
      
    
    {\displaystyle A\mathbf {e} _{i}=\lambda _{i}\mathbf {e} _{i}}
  
. The resulting equation is known as eigenvalue equation. The eigenvectors and eigenvalues are derived from it via the characteristic polynomial.
 With diagonalization, it is often possible to translate to and from eigenbases.
 Most common geometric transformations that keep the origin fixed are linear, including rotation, scaling, shearing, reflection, and orthogonal projection; if an affine transformation is not a pure translation it keeps some point fixed, and that point can be chosen as origin to make the transformation linear.  In two dimensions, linear transformations can be represented using a 2×2 transformation matrix.
 A stretch in the xy-plane is a linear transformation which enlarges all distances in a particular direction by a constant factor but does not affect distances in the perpendicular direction. We only consider stretches along the x-axis and y-axis. A stretch along the x-axis has the form x' = kx; y' = y for some positive constant k. (Note that if k > 1, then this really is a "stretch"; if k < 1, it is technically a "compression", but we still call it a stretch. Also, if k = 1, then the transformation is an identity, i.e. it has no effect.)
 The matrix associated with a stretch by a factor k along the x-axis is given by:
  Similarly, a stretch by a factor k along the y-axis has the form x' = x; y' = ky, so the matrix associated with this transformation is
  If the two stretches above are combined with reciprocal values, then the transformation matrix represents a squeeze mapping:
  For rotation by an angle θ counterclockwise (positive direction) about the origin the functional form is 
  
    
      
        
          x
          ′
        
        =
        x
        cos
        ⁡
        θ
        −
        y
        sin
        ⁡
        θ
      
    
    {\displaystyle x'=x\cos \theta -y\sin \theta }
  
 and 
  
    
      
        
          y
          ′
        
        =
        x
        sin
        ⁡
        θ
        +
        y
        cos
        ⁡
        θ
      
    
    {\displaystyle y'=x\sin \theta +y\cos \theta }
  
.  Written in matrix form, this becomes:
  Similarly, for a rotation clockwise (negative direction) about the origin, the functional form is 
  
    
      
        
          x
          ′
        
        =
        x
        cos
        ⁡
        θ
        +
        y
        sin
        ⁡
        θ
      
    
    {\displaystyle x'=x\cos \theta +y\sin \theta }
  
 and 
  
    
      
        
          y
          ′
        
        =
        −
        x
        sin
        ⁡
        θ
        +
        y
        cos
        ⁡
        θ
      
    
    {\displaystyle y'=-x\sin \theta +y\cos \theta }
  
 the matrix form is:
  These formulae assume that the x axis points right and the y axis points up.
 For shear mapping (visually similar to slanting), there are two possibilities.
 A shear parallel to the x axis has 
  
    
      
        
          x
          ′
        
        =
        x
        +
        k
        y
      
    
    {\displaystyle x'=x+ky}
  
 and 
  
    
      
        
          y
          ′
        
        =
        y
      
    
    {\displaystyle y'=y}
  
. Written in matrix form, this becomes:
  A shear parallel to the y axis has 
  
    
      
        
          x
          ′
        
        =
        x
      
    
    {\displaystyle x'=x}
  
 and 
  
    
      
        
          y
          ′
        
        =
        y
        +
        k
        x
      
    
    {\displaystyle y'=y+kx}
  
, which has matrix form:
  For reflection about a line that goes through the origin, let 
  
    
      
        
          l
        
        =
        (
        
          l
          
            x
          
        
        ,
        
          l
          
            y
          
        
        )
      
    
    {\displaystyle \mathbf {l} =(l_{x},l_{y})}
  
 be a vector in the direction of the line. Then use the transformation matrix:
  To project a vector orthogonally onto a line that goes through the origin, let 
  
    
      
        
          u
        
        =
        (
        
          u
          
            x
          
        
        ,
        
          u
          
            y
          
        
        )
      
    
    {\displaystyle \mathbf {u} =(u_{x},u_{y})}
  
 be a vector in the direction of the line.  Then use the transformation matrix:
  As with reflections, the orthogonal projection onto a line that does not pass through the origin is an affine, not linear, transformation.
 Parallel projections are also linear transformations and can be represented simply by a matrix.  However, perspective projections are not, and to represent these with a matrix, homogeneous coordinates can be used.
 The matrix to rotate an angle θ about any axis defined by unit vector (x,y,z) is 
  To reflect a point through a plane 
  
    
      
        a
        x
        +
        b
        y
        +
        c
        z
        =
        0
      
    
    {\displaystyle ax+by+cz=0}
  
 (which goes through the origin), one can use 
  
    
      
        
          A
        
        =
        
          I
        
        −
        2
        
          
            N
            N
          
          
            
              T
            
          
        
      
    
    {\displaystyle \mathbf {A} =\mathbf {I} -2\mathbf {NN} ^{\mathrm {T} }}
  
, where 
  
    
      
        
          I
        
      
    
    {\displaystyle \mathbf {I} }
  
 is the 3×3 identity matrix and 
  
    
      
        
          N
        
      
    
    {\displaystyle \mathbf {N} }
  
 is the three-dimensional unit vector for the vector normal of the plane.  If the L2 norm of 
  
    
      
        a
      
    
    {\displaystyle a}
  
, 
  
    
      
        b
      
    
    {\displaystyle b}
  
, and 
  
    
      
        c
      
    
    {\displaystyle c}
  
 is unity, the transformation matrix can be expressed as:
  Note that these are particular cases of a Householder reflection in two and three dimensions.  A reflection about a line or plane that does not go through the origin is not a linear transformation — it is an affine transformation — as a 4×4 affine transformation matrix, it can be expressed as follows (assuming the normal is a unit vector):
  If the 4th component of the vector is 0 instead of 1, then only the vector's direction is reflected and its magnitude remains unchanged, as if it were mirrored through a parallel plane that passes through the origin. This is a useful property as it allows the transformation of both positional vectors and normal vectors with the same matrix.  See homogeneous coordinates and affine transformations below for further explanation.
 One of the main motivations for using matrices to represent linear transformations is that transformations can then be easily composed and inverted.
 Composition is accomplished by matrix multiplication. Row and column vectors are operated upon by matrices, rows on the left and columns on the right. Since text reads from left to right, column vectors are preferred when transformation matrices are composed:
 If A and B are the matrices of two linear transformations, then the effect of first applying A and then B to a column vector 
  
    
      
        
          x
        
      
    
    {\displaystyle \mathbf {x} }
  
 is given by:
  In other words, the matrix of the combined transformation A followed by B is simply the product of the individual matrices.
 When A is an invertible matrix there is a matrix A−1 that represents a transformation that "undoes" A since its composition with A is the identity matrix. In some practical applications, inversion can be computed using general inversion algorithms or by performing inverse operations (that have obvious geometric interpretation, like rotating in opposite direction) and then composing them in reverse order.  Reflection matrices are a special case because they are their own inverses and don't need to be separately calculated.
 When composing linear transformations, it is possible to create a shear/skew by composing a rotation matrix A followed by a non-uniform scale matrix B. Therefore, if shear/skew is not desired, non-uniform scale must also be disallowed in order to prevent a shear/skew from appearing as the result of composition. Linear transformations with this property are known as conformal linear transformations because they are also conformal maps.
 To represent affine transformations with matrices, we can use homogeneous coordinates.  This means representing a 2-vector (x, y) as a 3-vector (x, y, 1), and similarly for higher dimensions.  Using this system, translation can be expressed with matrix multiplication.  The functional form 
  
    
      
        
          x
          ′
        
        =
        x
        +
        
          t
          
            x
          
        
        ;
        
          y
          ′
        
        =
        y
        +
        
          t
          
            y
          
        
      
    
    {\displaystyle x'=x+t_{x};y'=y+t_{y}}
  
 becomes:
  All ordinary linear transformations are included in the set of affine transformations, and can be described as a simplified form of affine transformations. Therefore, any linear transformation can also be represented by a general transformation matrix. The latter is obtained by expanding the corresponding linear transformation matrix by one row and column, filling the extra space with zeros except for the lower-right corner, which must be set to 1. For example, the counter-clockwise rotation matrix from above becomes:
  Using transformation matrices containing homogeneous coordinates, translations become linear, and thus can be seamlessly intermixed with all other types of transformations. The reason is that the real plane is mapped to the w = 1 plane in real projective space, and so translation in real Euclidean space can be represented as a shear in real projective space. Although a translation is a non-linear transformation in a 2-D or 3-D Euclidean space described by Cartesian coordinates (i.e. it can't be combined with other transformations while preserving commutativity and other properties), it becomes, in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a shear).
 More affine transformations can be obtained by composition of two or more affine transformations. For example, given a translation T' with vector 
  
    
      
        (
        
          t
          
            x
          
          ′
        
        ,
        
          t
          
            y
          
          ′
        
        )
        ,
      
    
    {\displaystyle (t'_{x},t'_{y}),}
  
 a rotation R by an angle θ counter-clockwise, a scaling S with factors 
  
    
      
        (
        
          s
          
            x
          
        
        ,
        
          s
          
            y
          
        
        )
      
    
    {\displaystyle (s_{x},s_{y})}
  
 and a translation T of vector 
  
    
      
        (
        
          t
          
            x
          
        
        ,
        
          t
          
            y
          
        
        )
        ,
      
    
    {\displaystyle (t_{x},t_{y}),}
  
 the result M of T'RST is:
  When using affine transformations, the homogeneous component of a coordinate vector (normally called w) will never be altered.  One can therefore safely assume that it is always 1 and ignore it.  However, this is not true when using perspective projections.
 Another type of transformation, of importance in 3D computer graphics, is the perspective projection.  Whereas parallel projections are used to project points onto the image plane along parallel lines, the perspective projection projects points onto the image plane along lines that emanate from a single point, called the center of projection.  This means that an object has a smaller projection when it is far away from the center of projection and a larger projection when it is closer (see also reciprocal function).
 The simplest perspective projection uses the origin as the center of projection, and the plane at 
  
    
      
        z
        =
        1
      
    
    {\displaystyle z=1}
  
 as the image plane.  The functional form of this transformation is then 
  
    
      
        
          x
          ′
        
        =
        x
        
          /
        
        z
      
    
    {\displaystyle x'=x/z}
  
; 
  
    
      
        
          y
          ′
        
        =
        y
        
          /
        
        z
      
    
    {\displaystyle y'=y/z}
  
.  We can express this in homogeneous coordinates as:
  After carrying out the matrix multiplication, the homogeneous component 
  
    
      
        
          w
          
            c
          
        
      
    
    {\displaystyle w_{c}}
  
 will be equal to the value of 
  
    
      
        z
      
    
    {\displaystyle z}
  
 and the other three will not change. Therefore, to map back into the real plane we must perform the homogeneous divide or perspective divide by dividing each component by 
  
    
      
        
          w
          
            c
          
        
      
    
    {\displaystyle w_{c}}
  
:
  More complicated perspective projections can be composed by combining this one with rotations, scales, translations, and shears to move the image plane and center of projection wherever they are desired.