坐标转换中的概念
旋转变换
2维旋转变换
2维旋转变换是指在平面上某一点
p
(
x
,
y
)
p(x,y)
p(x,y),围着某一点
A
(
x
o
,
y
o
)
A(x_o,y_o)
A(xo,yo)旋转
θ
\theta
θ弧度,则旋转后的坐标为
p
(
x
′
,
y
′
)
p(x',y')
p(x′,y′)。如果
A
A
A点为坐标原点显然很容易获得。其中theta为
p
p
p点在2维坐标系下的向量夹角,l为
p
p
p点到原点的距离:
x
′
=
l
∗
c
o
s
(
t
h
e
t
a
+
θ
)
x' = l * cos(theta+\theta)
x′=l∗cos(theta+θ)
y
′
=
l
∗
s
i
n
(
t
h
e
t
a
+
θ
)
y' = l * sin(theta+\theta)
y′=l∗sin(theta+θ)
将上面展开可获得如下:
x
′
=
l
∗
c
o
s
(
t
h
e
t
a
+
θ
)
=
x
∗
c
o
s
(
θ
)
−
y
∗
s
i
n
(
θ
)
x' = l * cos(theta+\theta) = x*cos(\theta) - y*sin(\theta)
x′=l∗cos(theta+θ)=x∗cos(θ)−y∗sin(θ)
y
′
=
l
∗
s
i
n
(
t
h
e
t
a
+
θ
)
=
x
∗
s
i
n
(
θ
)
+
y
∗
c
o
s
(
θ
)
y' = l*sin(theta+\theta) = x*sin(\theta) + y * cos(\theta)
y′=l∗sin(theta+θ)=x∗sin(θ)+y∗cos(θ)
所以矩阵形式为:
[
x
′
y
′
]
=
[
c
o
s
(
θ
)
−
s
i
n
(
θ
)
s
i
n
(
θ
c
o
s
(
θ
)
)
]
∗
[
x
y
]
\left[ \begin{matrix} x'\\ y'\\ \end{matrix} \right] = \left[ \begin{matrix} cos(\theta) & -sin(\theta)\\ sin(\theta & cos(\theta))\\ \end{matrix} \right] *\left[ \begin{matrix} x\\ y\\ \end{matrix} \right]
[x′y′]=[cos(θ)sin(θ−sin(θ)cos(θ))]∗[xy]
3维旋转变换
由于在3维空间有3个轴,故旋转的角度会存在三个,即分别绕行x轴( p i t c h pitch pitch),绕行y轴( r o l l roll roll),绕行z轴( y a w yaw yaw)。
绕x轴旋转矩阵变化如下;
[
x
′
y
′
z
′
]
=
[
1
0
0
0
c
o
s
(
p
i
t
c
h
)
−
s
i
n
(
p
i
t
c
h
)
0
s
i
n
(
p
i
t
c
h
)
c
o
s
(
p
i
t
c
h
)
]
∗
[
x
a
y
a
z
a
]
\left[ \begin{matrix} x'\\ y'\\ z'\\ \end{matrix} \right] = \left[ \begin{matrix} 1&0&0\\ 0&cos(pitch) & -sin(pitch) \\ 0&sin(pitch) & cos(pitch) \\ \end{matrix} \right] *\left[ \begin{matrix} x_a\\ y_a\\ z_a\\ \end{matrix} \right]
⎣⎡x′y′z′⎦⎤=⎣⎡1000cos(pitch)sin(pitch)0−sin(pitch)cos(pitch)⎦⎤∗⎣⎡xayaza⎦⎤
另外两个轴类似,不再赘述;
则绕行三个轴的旋转矩阵为
R
x
=
[
1
0
0
0
c
o
s
(
p
i
t
c
h
)
−
s
i
n
(
p
i
t
c
h
)
0
s
i
n
(
p
i
t
c
h
)
c
o
s
(
p
i
t
c
h
)
]
R_x = \left[ \begin{matrix} 1&0&0\\ 0&cos(pitch) & -sin(pitch) \\ 0&sin(pitch) & cos(pitch) \\ \end{matrix} \right]
Rx=⎣⎡1000cos(pitch)sin(pitch)0−sin(pitch)cos(pitch)⎦⎤
R y = [ c o s ( r o l l ) 0 − s i n ( r o l l ) 0 1 0 s i n ( r o l l ) 0 c o s ( r o l l ) ] R_y = \left[ \begin{matrix} cos(roll) &0&-sin(roll) \\ 0&1 & 0 \\ sin(roll) &0 & cos(roll) \\ \end{matrix} \right] Ry=⎣⎡cos(roll)0sin(roll)010−sin(roll)0cos(roll)⎦⎤
R Z = [ c o s ( y a w ) − s i n ( y a w ) 0 s i n ( y a w ) c o s ( y a w ) 0 0 0 1 ] R_Z=\left[ \begin{matrix} cos(yaw)& -sin(yaw)&0\\ sin(yaw)&cos(yaw) & 0 \\ 0&0 & 1 \\ \end{matrix} \right] RZ=⎣⎡cos(yaw)sin(yaw)0−sin(yaw)cos(yaw)0001⎦⎤
故3维旋转矩阵则为,注意顺序应该是yaw
R
(
或
者
W
A
R
)
=
R
z
∗
R
y
∗
R
x
R(或者W_{A^R}) = R_z* R_y *R_x
R(或者WAR)=Rz∗Ry∗Rx