Homogeneous Coordinates(齐次坐标)
在一个二维的空间中,对点做位移操作无法通过二维矩阵作用完成。因此用齐次坐标来完成对所有操作的表示。
齐次坐标中:
2D Point= ( x , y , 1 ) T (x, y,\textcolor{orange}1)^T (x,y,1)T 2D Vector= ( x , y , 0 ) T (x, y,\textcolor{orange}0)^T (x,y,0)T
对点进行位移操作:
(
x
′
y
′
w
′
)
=
(
1
0
t
x
0
1
t
y
0
0
1
)
.
(
x
y
1
)
=
(
x
+
t
x
y
+
t
y
1
)
\begin{pmatrix}x^{'}\\y^{'}\\w^{'}\end{pmatrix}=\begin{pmatrix}1&0&t_x\\0&1&t_y\\0&0&1\end{pmatrix}.\begin{pmatrix}x\\y\\1\end{pmatrix}=\begin{pmatrix}x+t_x\\y+t_y\\1\end{pmatrix}
⎝⎛x′y′w′⎠⎞=⎝⎛100010txty1⎠⎞.⎝⎛xy1⎠⎞=⎝⎛x+txy+ty1⎠⎞
w
w
w坐标为0或1的有效操作:
vector+vector = vector
vector+point = point
point - point = vector
point + point比较特殊,
(
x
y
w
)
\begin{pmatrix}x\\y\\w\end{pmatrix}
⎝⎛xyw⎠⎞表示为一个2D Point
(
x
/
w
y
/
w
1
)
\begin{pmatrix}x/w\\y/w\\1\end{pmatrix}
⎝⎛x/wy/w1⎠⎞,其中
w
w
w不为0
因此point + point = point(两点的中点)
Affin Transformation仿射变换
(
x
′
y
′
1
)
=
(
a
b
t
x
c
d
t
y
0
0
1
)
.
(
x
y
1
)
\begin{pmatrix}x^{'}\\y^{'}\\1\end{pmatrix}=\begin{pmatrix}a&b&t_x\\c&d&t_y\\0&0&1\end{pmatrix}.\begin{pmatrix}x\\y\\1\end{pmatrix}
⎝⎛x′y′1⎠⎞=⎝⎛ac0bd0txty1⎠⎞.⎝⎛xy1⎠⎞
Scale 放缩
S
(
s
x
,
s
y
)
=
(
s
x
0
0
0
s
y
0
0
0
1
)
\bold{S}(s_x, s_y)=\begin{pmatrix}s_x&0&0\\0&s_y&0\\0&0&1\end{pmatrix}
S(sx,sy)=⎝⎛sx000sy0001⎠⎞
Rotation 旋转
R
(
α
)
=
(
cos
α
−
sin
α
0
sin
α
cos
α
0
0
0
1
)
\bold{R}(\alpha)=\begin{pmatrix}\cos{\alpha}&-\sin{\alpha}&0\\\sin{\alpha}&\cos{\alpha}&0\\0&0&1\end{pmatrix}
R(α)=⎝⎛cosαsinα0−sinαcosα0001⎠⎞
Translation 位移
T
(
t
x
,
t
y
)
=
(
1
0
t
x
0
1
t
y
0
0
1
)
\bold{T}(t_x, t_y)=\begin{pmatrix}1&0&t_x\\0&1&t_y\\0&0&1\end{pmatrix}
T(tx,ty)=⎝⎛100010txty1⎠⎞
一个矩阵的逆矩阵意味着进行逆操作,如顺时针旋转 α \alpha α为 R ( α ) \bold{R}(\alpha) R(α),则 R − 1 ( α ) \bold{R}^{-1}(\alpha) R−1(α)为逆时针旋转 α \alpha α
Composing Transforms复合变换
变换是有顺序的,即矩阵的作用顺序不能随意改变。复杂的变换可以拆分成几个基础的变换矩阵的乘积。
如何表示绕某个点c旋转?
可以先将点c移动到原点,进行旋转,再移动回c。
T
(
c
)
⋅
R
(
α
)
⋅
T
(
−
c
)
\bold{T}(c)\cdot\bold{R}(\alpha)\cdot\bold{T}(-c)
T(c)⋅R(α)⋅T(−c)
3维空间中雷同