- 线性变换:变换能够用矩阵乘法得到
可以说,Linear Transformation = Matrices (of the same dimension)
我们将如下所示的简单矩阵乘法定义为对向量
(
x
,
y
)
T
(x, y)^{T}
(x,y)T 的线性变换。
[
a
11
a
12
a
21
a
22
]
[
x
y
]
=
[
a
11
x
+
a
12
y
a
21
x
+
a
22
y
]
\left[
缩放变换是一种沿着坐标轴作用的变换,定义如下:
scale
(
s
x
,
s
y
)
=
[
s
x
0
0
s
y
]
\operatorname{scale}\left(s_{x}, s_{y}\right)=\left[
即除了
(
0
,
0
)
T
(0,0)^{T}
(0,0)T 保持不变之外,所有的点变为
(
s
x
x
,
s
y
y
)
T
\left(s_{x} x, s_{y} y\right)^{T}
(sxx,syy)T
shear 变换直观理解就是把物体一边固定,然后拉另外一边,定义如下:
s
h
e
a
r
−
x
(
s
)
=
[
1
s
0
1
]
,
s
h
e
a
r
−
y
(
s
)
=
[
1
0
s
1
]
shear-x(s)=\left[


R
θ
=
[
cos
θ
−
sin
θ
sin
θ
cos
θ
]
\mathbf{R}_{\theta}=\left[
推导如下
定义 2D 坐标和 2D向量如下
vector + vector = vector
point – point = vector
point + vector = point (一个点沿着向量移动)
point + point = 两个点的中点
此外,当第三维为
w
(
w
≠
0
)
w(w\ne 0)
w(w=0)时,定义
(
x
y
w
)
is the
2
D
point
(
x
/
w
y
/
w
1
)
,
w
≠
0
\left(
S
(
s
x
,
s
y
)
=
(
s
x
0
0
0
s
y
0
0
0
1
)
\mathbf{S}\left(s_{x}, s_{y}\right)=\left(
R
(
α
)
=
(
cos
α
−
sin
α
0
sin
α
cos
α
0
0
0
1
)
\mathbf{R}(\alpha)=\left(
T
(
t
x
,
t
y
)
=
(
1
0
t
x
0
1
t
y
0
0
1
)
\mathbf{T}\left(t_{x}, t_{y}\right)=\left(
再次使用齐次坐标描述
Use
4
×
4
4 \times 4
4×4 matrices for affine transformations
(
x
′
y
′
z
′
1
)
=
(
a
b
c
t
x
d
e
f
t
y
g
h
i
t
z
0
0
0
1
)
⋅
(
x
y
z
1
)
\left(
S
(
s
x
,
s
y
,
s
z
)
=
(
s
x
0
0
0
0
s
y
0
0
0
0
s
z
0
0
0
0
1
)
\mathbf{S}\left(s_{x}, s_{y}, s_{z}\right)=\left(
T
(
t
x
,
t
y
,
t
z
)
=
(
1
0
0
t
x
0
1
0
t
y
0
0
1
t
z
0
0
0
1
)
\mathbf{T}\left(t_{x}, t_{y}, t_{z}\right)=\left(
around x − , y − x-, y- x−,y−, or z z z-axis
sin α \sin \alpha sinα 的正负号由右手定则确定,顺序是 x → z x\to z x→z
R
x
(
α
)
=
(
1
0
0
0
0
cos
α
−
sin
α
0
0
sin
α
cos
α
0
0
0
0
1
)
R
y
(
α
)
=
(
cos
α
0
sin
α
0
0
1
0
0
−
sin
α
0
cos
α
0
0
0
0
1
)
R
z
(
α
)
=
(
cos
α
−
sin
α
0
0
sin
α
cos
α
0
0
0
0
1
0
0
0
0
1
)
R x y z ( α , β , γ ) = R x ( α ) R y ( β ) R z ( γ ) \mathbf{R}_{x y z}(\alpha, \beta, \gamma)=\mathbf{R}_{x}(\alpha) \mathbf{R}_{y}(\beta) \mathbf{R}_{z}(\gamma) Rxyz(α,β,γ)=Rx(α)Ry(β)Rz(γ)
Rotation by angle
α
\alpha
α around axis
n
n
n
R
(
n
,
α
)
=
cos
(
α
)
I
+
(
1
−
cos
(
α
)
)
n
n
T
+
sin
(
α
)
(
0
−
n
z
n
y
n
z
0
−
n
x
−
n
y
n
x
0
)
⏟
N
\mathbf{R}(\mathbf{n}, \alpha)=\cos (\alpha) \mathbf{I}+(1-\cos (\alpha)) \mathbf{n} \mathbf{n}^{T}+\sin (\alpha) \underbrace{\left(
Think about how to take a photo
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Fx3Pqwmp-1660291810051)(https://cdn.jsdelivr.net/gh/QiuHong-1202/FigureBed/2021/202208071729657.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZTM6RjtF-1660291810052)(https://cdn.jsdelivr.net/gh/QiuHong-1202/FigureBed/2021/202208071733145.png)]
Translate (center to origin) first, then scale (length/width/height to 2)
M
ortho
=
[
2
r
−
l
0
0
0
0
2
t
−
b
0
0
0
0
2
n
−
f
0
0
0
0
1
]
[
1
0
0
−
r
+
l
2
0
1
0
−
t
+
b
2
0
0
1
−
n
+
f
2
0
0
0
1
]
M_{\text {ortho }}=\left[
计算机图形学二:视图变换(坐标系转化,正交投影,透视投影,视口变换)
M per = M ortho M persp → ortho \mathrm{M}_{\text {per }}=\mathrm{M}_{\text {ortho }} \mathrm{M}_{\text {persp } \rightarrow\text { ortho }} Mper =Mortho Mpersp → ortho
M
per
=
[
2
r
−
l
0
0
0
0
2
t
−
b
0
0
0
0
2
n
−
f
0
0
0
0
1
]
[
1
0
0
−
r
+
l
2
0
1
0
−
t
+
b
2
0
0
1
−
n
+
f
2
0
0
0
1
]
[
n
0
0
0
0
n
0
0
0
0
n
+
f
−
f
n
0
0
1
0
]
\mathrm{M}_{\text {per }}=\left[