Difference between revisions of "Rotation"

From Robotics
Jump to: navigation, search
(Three-dimensional)
(Three-dimensional)
Line 165: Line 165:
  
 
In three-dimensional space three basic types of rotation are regarded: rotation around x-, y- and z-axis. These three types are defined by the axis and the rotation angle <math>\varphi</math> and denoted as <math>\mathbf{Rot}(x,\varphi)</math>, <math>\mathbf{Rot}(y,\varphi)</math> and <math>\mathbf{Rot}(z,\varphi)</math>.  
 
In three-dimensional space three basic types of rotation are regarded: rotation around x-, y- and z-axis. These three types are defined by the axis and the rotation angle <math>\varphi</math> and denoted as <math>\mathbf{Rot}(x,\varphi)</math>, <math>\mathbf{Rot}(y,\varphi)</math> and <math>\mathbf{Rot}(z,\varphi)</math>.  
 
:<math>
 
\begin{tabular}{cc}
 
Txt&text\\
 
Feld&Feld
 
\end{tabular}
 
</math>
 
 
  
 
Rotation around one one of the three coordinate axes changes two components of the coordinates while the component on the rotation axis stays as it is. Hence the properties of two-dimensional rotation can also be used for three-dimensional rotation. The rotation matrix for rotation around the z-axis for example equals the identity matrix with the two-dimensional rotation matrix <math>\mathbf{T}_{r_2}</math> replacing the four top left components:<br/>
 
Rotation around one one of the three coordinate axes changes two components of the coordinates while the component on the rotation axis stays as it is. Hence the properties of two-dimensional rotation can also be used for three-dimensional rotation. The rotation matrix for rotation around the z-axis for example equals the identity matrix with the two-dimensional rotation matrix <math>\mathbf{T}_{r_2}</math> replacing the four top left components:<br/>

Revision as of 16:37, 12 June 2014

← Back: Scaling Overview: Transformations Next: Homogeneous coordinates
Vector rotation.png

Rotation is a transformation where the coordinates are rotated around the origin of the coordinate system. In this article rotation is first described for two dimensions and based on the two-dimensional transform matrix, rotation in three-dimensional space is presented.

Two-dimensional

The figure on the right shows an example, where the vector \vec{\mathbf{q}}_0 is rotated by \varphi around the origin, what results in vector \vec{\mathbf{q}}_1. The length of the vector \vec{\mathbf{q}}_0 is assumed as l and so the length of \vec{\mathbf{q}}_1 is l as well. The initial angle of \vec{\mathbf{q}}_0 relative to the x-axis is \alpha. Hence the resulting coordinates x_1 and y_1 can be computed as follows:


x_1=l\cdot\cos(\alpha+\varphi)


y_1=l\cdot\sin(\alpha+\varphi)

Using the addition theorems of sine and cosine leads to:

\begin{align}
x_1&=l\cdot(\cos\alpha\cos\varphi-\sin\alpha\sin\varphi) \\
&=l\cdot\cos\alpha\cdot\cos\varphi-l\cdot\sin\alpha\cdot\sin\varphi
\end{align}

\begin{align}
y_1&=l\cdot(\sin\alpha\cos\varphi-\cos\alpha\sin\varphi) \\
&=l\cdot\sin\alpha\cdot\cos\varphi-l\cdot\cos\alpha\cdot\sin\varphi
\end{align}

Regarding the vector \vec{\mathbf{q}}_0 and its angle \alpha to the x-axis, x_0 equals l\cos\alpha and y_0 equals l\sin\alpha. By applying this the above equations can be reformed to:


x_1=x_0\cos\varphi-y_0\sin\varphi


y_1=y_0\cos\varphi+x_0\sin\varphi

These two equations for x_1 and y_1 can also be written in matrix notation:


\left[\begin{array}{c}
x_1\\
y_1
\end{array}\right]
=
\left[\begin{array}{cc}
\cos\varphi & -\sin\varphi\\
\sin\varphi & \cos\varphi
\end{array}\right]
\cdot
\left[\begin{array}{c}
x_0\\
y_0
\end{array}\right]
=
\left[\begin{array}{cc}
x_0\cos\varphi-y_0\sin\varphi\\
x_0\sin\varphi+y_0\cos\varphi
\end{array}\right]


So the transformation matrix for rotation about \varphi in two dimensions is:


\mathbf{T}_{r_2}
=
\left[\begin{array}{cc}
\cos\varphi & -\sin\varphi\\
\sin\varphi & \cos\varphi
\end{array}\right]


Example: rotation in two-dimensional space
RotationEx.png

The rotation of a rectangle corresponds to the rotation of each of the three position vectors of the corners individually. The red rectangle is the initial one. If it is rotated by 30 degrees, the result is the blue rectangle. The corresponding transformation matrix is:


{\mathbf{T}_r}^{r\rightarrow b}
=
\left[\begin{array}{cc}
\cos (30^\circ) & -\sin (30^\circ)\\
\sin (30^\circ) & \cos (30^\circ)
\end{array}\right]
=
\left[\begin{array}{cc}
\frac{\sqrt{3}}{2} & -0.5\\
0.5 & \frac{\sqrt{3}}{2}
\end{array}\right]

The green rectangle is obtained by rotating the red rectangle by 90 degrees. This corresponds to the following transformation matrix:


{\mathbf{T}_r}^{r\rightarrow g}
=
\left[\begin{array}{cc}
\cos (90^\circ) & -\sin (90^\circ)\\
\sin (90^\circ) & \cos (90^\circ)
\end{array}\right]
=
\left[\begin{array}{cc}
0 & -1\\
1 & 0
\end{array}\right]

Another possibility to obtain the green rectangle is rotating the blue rectangle by 60 degrees. Then the transformation matrix is:


{\mathbf{T}_r}^{b\rightarrow g}
=
\left[\begin{array}{cc}
\cos (60^\circ) & -\sin (60^\circ)\\
\sin (60^\circ) & \cos (60^\circ)
\end{array}\right]
=
\left[\begin{array}{cc}
0.5 & -\frac{\sqrt{3}}{2}\\
\frac{\sqrt{3}}{2} & 0.5
\end{array}\right]

The back transformation of the blue rectangle to the red rectangle for example is done by the following transformation matrix:


{\mathbf{T}_r}^{b\rightarrow r}
=
\left[\begin{array}{cc}
\cos (-30^\circ) & -\sin (-30^\circ)\\
\sin (-30^\circ) & \cos (-30^\circ)
\end{array}\right]
=
\left[\begin{array}{cc}
\frac{\sqrt{3}}{2} & 0.5\\
-0.5 & \frac{\sqrt{3}}{2}
\end{array}\right]

Three-dimensional

In three-dimensional space three basic types of rotation are regarded: rotation around x-, y- and z-axis. These three types are defined by the axis and the rotation angle \varphi and denoted as \mathbf{Rot}(x,\varphi), \mathbf{Rot}(y,\varphi) and \mathbf{Rot}(z,\varphi).

Rotation around one one of the three coordinate axes changes two components of the coordinates while the component on the rotation axis stays as it is. Hence the properties of two-dimensional rotation can also be used for three-dimensional rotation. The rotation matrix for rotation around the z-axis for example equals the identity matrix with the two-dimensional rotation matrix \mathbf{T}_{r_2} replacing the four top left components:

 
\mathbf{Rot}(z,\varphi)=
\left[\begin{array}{ccc}
\mathbf{\cos\varphi} &   & 0\\
\mathbf{\sin\varphi} & \mathbf{\cos\varphi} & 0\\
0 & 0 & 1
\end{array}\right]=
\left[\begin{array}{ccc}
\mathbf{\cos\varphi} & \mathbf{-\sin\varphi} & 0\\
\mathbf{\sin\varphi} & \mathbf{\cos\varphi} & 0\\
0 & 0 & 1
\end{array}\right]

As the coordinates are rotated around the z-axis, the z-component stays as it is:

 
\left[\begin{array}{c}
x_1\\
y_1\\
z_1
\end{array}\right]=
\left[\begin{array}{ccc}
\mathbf{\cos\varphi} & \mathbf{-\sin\varphi} & 0\\
\mathbf{\sin\varphi} & \mathbf{\cos\varphi} & 0\\
0 & 0 & 1
\end{array}\right]
\cdot
\left[\begin{array}{c}
x_0\\
y_0\\
z_0
\end{array}\right]=
\left[\begin{array}{c}
x_0\cos\varphi-y_0\sin\varphi\\
x_0\sin\varphi+y_0\cos\varphi\\
z_0
\end{array}\right]

Accordingly the rotation matrices for the x- and y-axis are:

 
\mathbf{Rot}(x,\varphi)=
\left[\begin{array}{ccc}
1 & 0 & 0\\
0 & \mathbf{\cos\varphi} & \mathbf{-\sin\varphi}\\
0 & \mathbf{\sin\varphi} & \mathbf{\cos\varphi}
\end{array}\right]


\mathbf{Rot}(y,\varphi)=
\left[\begin{array}{ccc}
\mathbf{\cos\varphi} & 0 & \mathbf{\sin\varphi}\\
0 & 1 & 0\\
\mathbf{-\sin\varphi} & 0 & \mathbf{\cos\varphi}
\end{array}\right]