## Converting rotation matrices of left-handed coordinate system

In left-handed coordinate system, positive angle is clockwise direction. In right-handed coordinate system, positive angle is anti-clockwise direction.

I spent many hours to find out how to convert rotation matrices of left-handed coordinate system. The solution is to replace the angle $\theta$ with $-\theta$

The rotation matrices about three axis in left-handed coordinate system.

$Rx(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos\theta & sin\theta \\ 0 & -sin\theta & cos\theta \end{bmatrix}$

$Ry(\theta) = \begin{bmatrix} cos\theta & 0 & -sin\theta \\ 0 & 1 & 0 \\ sin\theta & 0 & cos\theta \end{bmatrix}$

$Rz(\theta) = \begin{bmatrix} cos\theta & sin\theta & 0 \\ -sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}$

The rotation matrix about arbitrary axis

${\bf R}({\bf \hat{n}}, \theta) = \begin{bmatrix} n_{x}^{2}(1 - cos\theta) + cos\theta & n_{x}n_{y}(1 - cos\theta) + n_{z}sin\theta & n_{x}n_{z}(1 - cos\theta) - n_{y}sin\theta \\ n_{x}n_{y}(1 - cos\theta) - n_{z}sin\theta & n_{y}^{2}(1 - cos\theta) + cos\theta & n_{y}n_{z}(1 - cos\theta) + n_{x}sin\theta \\ n_{x}n_{z}(1 - cos\theta) + n_{y}sin\theta & n_{y}n_{z}(1 - cos\theta) - n_{x}sin\theta & n_{z}^{2}(1 - cos\theta) + cos\theta \end{bmatrix}$

To get $Rx(\theta)$ in right-handed coordinate system, replace the angle $\theta$ with negative $\theta$. Then apply the following rules.

$cos(-\theta) = cos\theta$
$sin(-\theta) = -sin\theta$

$Rx(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos(-\theta) & sin(-\theta) \\ 0 & -sin(-\theta) & cos(-\theta) \end{bmatrix}$

$Rx(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & cos\theta & -sin\theta \\ 0 & sin\theta & cos\theta \end{bmatrix}$

$Ry(\theta) = \begin{bmatrix} cos\theta & 0 & sin\theta \\ 0 & 1 & 0 \\ -sin\theta & 0 & cos\theta \end{bmatrix}$

$Rz(\theta) = \begin{bmatrix} cos\theta & -sin\theta & 0 \\ sin\theta & cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix}$

${\bf R}({\bf \hat{n}}, \theta) = \begin{bmatrix} n_{x}^{2}(1 - cos\theta) + cos\theta & n_{x}n_{y}(1 - cos\theta) - n_{z}sin\theta & n_{x}n_{z}(1 - cos\theta) + n_{y}sin\theta \\ n_{x}n_{y}(1 - cos\theta) + n_{z}sin\theta & n_{y}^{2}(1 - cos\theta) + cos\theta & n_{y}n_{z}(1 - cos\theta) - n_{x}sin\theta \\ n_{x}n_{z}(1 - cos\theta) - n_{y}sin\theta & n_{y}n_{z}(1 - cos\theta) + n_{x}sin\theta & n_{z}^{2}(1 - cos\theta) + cos\theta \end{bmatrix}$

Reference

3D Math Primer for Graphics and Game Development 2ed, Fletcher Dunn, Ian Parberry
Mathematics for 3D Game Programming and Computer Graphics 3ed, Eric Lengyel

Email: k2.mountain [at] gmail [dot] com Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in Science and technologies and tagged , , , , , . Bookmark the permalink.

### 4 Responses to Converting rotation matrices of left-handed coordinate system

1. erfan says:

Thank you bro,

2. Bob Goudsmitje says:

What does Nx Ny and Nz mean?

• janpenguin says:

They are X, Y, and Z components of unit vector n for arbitrary axis.

3. janpenguin says:

The homepage on the link explains unit vector with examples.

https://cloudshareinfo.blogspot.com/2020/02/how-to-find-unit-vector.html