Home Game Development arithmetic – How to transform a 4×4 matrix transformation to a different coordinate system?

arithmetic – How to transform a 4×4 matrix transformation to a different coordinate system?

0
arithmetic – How to transform a 4×4 matrix transformation to a different coordinate system?

[ad_1]

This is as straightforward as writing your previous coordinates by way of the brand new ones.

  • We need +x to map to +x (1, 0, 0)

  • We need +y to map to +z (0, 0, 1)

  • We need +z to map to -y (0, -1, 0)

  • We need the fourth, homogenous coordinate to outlive unchanged (0, 0, 0, 1)

So you make these vectors the columns of a coordinate conversion matrix:

$$Bbb C = start{bmatrix}
1 & 0 & 0 & 0
0 & 0 & -1 & 0
0 & 1 & 0 & 0
0 & 0 & 0 & 1
finish{bmatrix}$$

If you left-multiply this matrix by any homogeneous vector in your previous coordinate system, it converts it to the corresponding vector within the new coordinate system:

$$vec v_{textual content{new}} = Bbb C occasions vec v_{textual content{previous}}$$

And the identical goes for any vector remodeled by a metamorphosis matrix $Bbb M$ expressed in your previous area:

$$ vec v_{textual content{new}} = Bbb C occasions vec v_{textual content{remodeled}} = Bbb C occasions (Bbb M occasions vec v_{textual content{untransformed}})
vec v_{textual content{new}} = (Bbb C Bbb M) occasions vec v_{textual content{untransformed}}$$

So you may multiply any transformation matrix by this coordinate transformation matrix to get a single matrix that does each the unique transformation and the coordinate conversion.

If you utilize the alternative multiplication conference – vector on the left, matrix on the suitable – then take the transpose of $Bbb C$ (so your vacation spot vectors are the rows as an alternative of the columns) and multiply it on the suitable as an alternative of the left.


You can use this identical logic to work with untransformed vectors already within the new coordinate system: simply convert them again to the previous coordinate system (utilizing the inverse of matrix $Bbb C$ above, $Bbb C^{-1}$), use the transformation matrix from the previous system ($Bbb M$), after which convert again:

$$start{align}
vec v_text{transformed-new} &= Bbb C occasions vec v_text{transformed-old}
&= Bbb C occasions (Bbb M occasions vec v_text{untransformed-old})
&= (Bbb C Bbb M) occasions (Bbb C^{-1} occasions vec v_text{untransformed-new})
&= (Bbb C Bbb M Bbb C^{-1}) occasions vec v_text{untransformed-new}
finish{align}$$

So, your matrix that does the identical job as $Bbb M$ however within the new coordinate system is simply $Bbb M_text{new} = Bbb C Bbb M Bbb C^{-1}$.

Since your coordinate transformation is pure rotation/reflection – no scaling/shearing – the inverse of $Bbb C$ is simply its transpose (making its rows into columns and vice versa):

$$Bbb C^{-1} = Bbb C^T = start{bmatrix}
1 & 0 & 0 & 0
0 & 0 & 1 & 0
0 & -1 & 0 & 0
0 & 0 & 0 & 1
finish{bmatrix}$$

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here