Skip to content

Instantly share code, notes, and snippets.

@fospathi
Created August 12, 2025 11:53
Show Gist options
  • Save fospathi/74fca86414dc93439bf16a1df0761f91 to your computer and use it in GitHub Desktop.
Save fospathi/74fca86414dc93439bf16a1df0761f91 to your computer and use it in GitHub Desktop.
Change of basis transformation

Change of basis

Let C be a right-handed three-dimensional coordinate system.

Let R be a linear transformation that preserves an orthonormal basis, such as a rotation around or reflection through the origin.

Let R be applied to any point in C, say P, and let Q be the image of P.

R : P ↦ Q

Let R be applied to the orthonormal basis vectors that define the axis directions of C to give a new coordinate system C'.

R : C ↦ C'

In the diagrams below R is shown as a π/2 radians rotation about the y-axis:

  • Coordinate system C

                 y-axis
                    |       /         Q
                    |      /          |
                    |     /           |
                    |    /            |
                    |   /             |
                    |  /             /
                    | /             /
                    |/             /
                   _/_ _ _ _ _ _ _/_ _ _ _ _ _
                  O/                         x-axis
                  /         P
                 /          |
                /           |
               /            |
              /- - - - - - -|
             /
            /
          z-axis
    
  • Coordinate system C'

                 y'-axis     x'-axis
                    |         /
                    |        /
                    |       /         Q'
                    |      /          |
                    |     /           |
                    |    /            |
                    |   /             |
                    |  /             /
                    | /             /
                    |/             /
                   _/_ _ _ _ _ _ _/_ _ _ _ _ _
                  O/                         z'-axis
                  /         P'
                 /          |
                /           |
               /            |
              /- - - - - - -|
             /
            /
    

In the diagrams:

  • O is the origin and does not move.
  • R maps the x/y/z axes to the x'/y'/z' axes respectively.
  • R⁻¹ (the inverse of R) transforms Q to P in C and therefore transforms Q' to P' in C'.

Suppose we wish to find the coordinates of P in C', that is we wish to find P'. (This is the change of basis we require.)

We have that


R⁻¹: Q' ↦ P'

Since Q' has the same coordinates in C' as P in C, to find P' we simply need to apply R⁻¹ to P:


Q' == P ∴ R⁻¹: P ↦ P'

Finding R⁻¹

The columns of the matrix R are given by the basis vectors of C' in C:

let R = |a d g|  then  |1|   |1|   |a|,  |0|   |0|   |d|,  |0|   |0|   |g|
        |b e h|        |0|→ R|0| = |b|   |1|→ R|1| = |e|   |0|→ R|0| = |h|
        |c f i|        |0|   |0|   |c|   |0|   |0|   |f|   |1|   |1|   |i|

A matrix whose columns constitute an orthonormal basis is an orthogonal matrix. The inverse of an orthogonal matrix is its transpose. That is

R⁻¹ = Rᵀ

and so

Rᵀ: P ↦ P'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment