[Chapter 6] Transformation Matrices

6. Transformation Matrices

6.1 2D Linear Transformations

6.1.1 Scaling

s c a l e s ( s x , s y ) = [ s x 0 0 s y ] scales(s_x,s_y)= \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} scales(sx,sy)=[sx00sy]

在这里插入图片描述
在这里插入图片描述

6.1.2 Shearing

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)= \begin{bmatrix} 1 & s \\ 0 & 1 \end{bmatrix}, shear\_y(s)= \begin{bmatrix} 1 & 0 \\ s & 1 \end{bmatrix} shear_x(s)=[10s1],shear_y(s)=[1s01]

在这里插入图片描述
在这里插入图片描述

6.1.3 Rotation

r o t a t e ( θ ) = [ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] rotate(\theta)= \begin{bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{bmatrix} rotate(θ)=[cosθsinθsinθcosθ]
在这里插入图片描述

6.1.4 Reflection

r e f l e c t _ y ( s ) = [ − 1 0 0 1 ] , r e f l e c t _ x ( s ) = [ 1 0 0 − 1 ] reflect\_y(s)= \begin{bmatrix} -1 & 0\\ 0 & 1 \end{bmatrix}, reflect\_x(s)= \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} reflect_y(s)=[1001],reflect_x(s)=[1001]

在这里插入图片描述
在这里插入图片描述

6.1.5 Composition and Decomposition of Transformations

在这里插入图片描述

6.1.6 Decomposition of Transformations

  • Symmetric Eigenvalue Decomposition
    A = R S R T A=RSR^T A=RSRT
    在这里插入图片描述
    for example:
    [ 2 1 1 1 ] = R [ λ 1 0 0 λ 2 ] R T = r o t a t e ( 31. 7 ∘ ) s c a l e ( 2.618 , 0.382 ) r o t a t e ( − 31. 7 ∘ ) \begin{aligned} \begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}=&R\begin{bmatrix} \lambda_1 & 0\\ 0&\lambda_2 \end{bmatrix}R^T\\ =&rotate(31.7^\circ)scale(2.618, 0.382)rotate(-31.7^\circ) \end{aligned} [2111]==R[λ100λ2]RTrotate(31.7)scale(2.618,0.382)rotate(31.7)

  • Singular Value Decomposition
    A = U S V T A=USV^T A=USVT
    for example:
    [ 1 1 0 1 ] = R 2 [ σ 1 0 0 σ 2 ] R 1 T = r o t a t e ( 31. 7 ∘ ) s c a l e ( 1.618 , 0.618 ) r o t a t e ( − 58. 3 ∘ ) \begin{aligned} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}=&R_2\begin{bmatrix} \sigma_1 & 0\\ 0&\sigma_2 \end{bmatrix}R_1^T\\ =&rotate(31.7^\circ)scale(1.618, 0.618)rotate(-58.3^\circ) \end{aligned} [1011]==R2[σ100σ2]R1Trotate(31.7)scale(1.618,0.618)rotate(58.3)

  • Paeth Decomposition of Rotations
    [ cos ⁡ θ − sin ⁡ θ sin ⁡ θ cos ⁡ θ ] = [ 1 cos ⁡ θ − 1 sin ⁡ θ 0 1 ] [ 1 0 sin ⁡ θ 1 ] [ 1 cos ⁡ θ − 1 sin ⁡ θ 0 1 ] \begin{bmatrix} \cos \theta&-\sin \theta\\ \sin \theta&\cos \theta \end{bmatrix}= \begin{bmatrix} 1&\frac{\cos \theta - 1}{\sin \theta}\\ 0&1 \end{bmatrix} \begin{bmatrix} 1&0\\ \sin \theta&1 \end{bmatrix} \begin{bmatrix} 1&\frac{\cos \theta - 1}{\sin \theta}\\ 0&1 \end{bmatrix} [cosθsinθsinθcosθ]=[10sinθcosθ11][1sinθ01][10sinθcosθ11]
    在这里插入图片描述
    This particular transform is useful for raster rotation because shearing is a very efficient raster operation for images; it introduces some jagginess, but will leave no holes.

6.2 3D Linear Transformations

s c a l e ( s x , s y , s z ) = [ s x 0 0 0 s y 0 0 0 s z ] scale(s_x,s_y,s_z)= \begin{bmatrix} s_x&0&0\\ 0&s_y&0\\ 0&0&s_z \end{bmatrix} scale(sx,sy,sz)=sx000sy000sz
r o t a t e _ z ( θ ) = [ cos ⁡ θ − sin ⁡ θ 0 sin ⁡ θ cos ⁡ θ 0 0 0 1 ] rotate\_z(\theta)= \begin{bmatrix} \cos \theta & -\sin \theta&0 \\ \sin \theta & \cos \theta&0\\ 0&0&1 \end{bmatrix} rotate_z(θ)=cosθsinθ0sinθcosθ0001
r o t a t e _ x ( θ ) = [ 1 0 0 0 cos ⁡ θ − sin ⁡ θ 0 sin ⁡ θ cos ⁡ θ ] rotate\_x(\theta)= \begin{bmatrix} 1&0&0\\ 0&\cos \theta & -\sin \theta \\ 0&\sin \theta&\cos \theta\\ \end{bmatrix} rotate_x(θ)=1000cosθsinθ0sinθcosθ
r o t a t e _ y ( θ ) = [ cos ⁡ θ 0 sin ⁡ θ 0 1 0 − sin ⁡ θ 0 cos ⁡ θ ] rotate\_y(\theta)= \begin{bmatrix} \cos \theta & 0&\sin \theta \\ 0&1&0\\ -\sin \theta&0&\cos \theta\\ \end{bmatrix} rotate_y(θ)=cosθ0sinθ010sinθ0cosθ

6.2.1 Arbitrary 3D Rotations

In matrix form, to rotate about the w-axis by an angle θ \theta θ:

[ x u x v x w y u y v y w z u z v z w ] [ cos ⁡ θ − sin ⁡ θ 0 sin ⁡ θ cos ⁡ θ 0 0 0 1 ] [ x u y v z w x u y v z w x u y v z w ] \begin{bmatrix} x_u&x_v&x_w\\ y_u&y_v&y_w\\ z_u&z_v&z_w \end{bmatrix} \begin{bmatrix} \cos \theta&-\sin \theta&0\\ \sin \theta& \cos \theta&0\\ 0&0&1 \end{bmatrix} \begin{bmatrix} x_u&y_v&z_w\\ x_u&y_v&z_w\\ x_u&y_v&z_w \end{bmatrix} xuyuzuxvyvzvxwywzwcosθsinθ0sinθcosθ0001xuxuxuyvyvyvzwzwzw

6.2.2 Transforming Normal Vectors

在这里插入图片描述

n T t = 0 n^Tt=0 nTt=0
If we denote the desired transformed vectors as t M = M t t_M = Mt tM=Mt and n N = N n n_N = Nn nN=Nn,our goal is to find N N N such that n N T t M = 0 n^T_Nt_M= 0 nNTtM=0
n T t = n T I t = n T M − 1 M t = 0 ( n T M − 1 ) ( M t ) = ( n T M − 1 ) t M = 0 ⇒ n N T = n T M − 1 ⇒ n N = ( n T M − 1 ) T = ( M − 1 ) T n n^Tt=n^TIt=n^TM^{-1}Mt=0\\ (n^TM^{-1})(Mt)=(n^TM^{-1})t_M=0\\ \Rightarrow n^T_N=n^TM^{-1}\\ \Rightarrow n_N=(n^TM^{-1})^T=(M^{-1})^Tn nTt=nTIt=nTM1Mt=0(nTM1)(Mt)=(nTM1)tM=0nNT=nTM1nN=(nTM1)T=(M1)Tn

6.3 Translation and Affine Transformation

In particular, homogeneous coordinates underlie the Homogeneous coordinates design and operation of renderers implemented in graphics hardware.

6.4 Inverses of Transformation Matrices

for example in 3D we have
M = R 1 s c a l e ( σ 1 , σ 2 , σ 3 ) R 2 , M − 1 = R 2 T s c a l e ( 1 σ 1 , 1 σ 2 , 1 σ 3 ) R 1 T M=R_1scale(\sigma_1,\sigma_2,\sigma_3)R_2,\\ M^{-1}=R_2^Tscale(\frac1\sigma_1,\frac1\sigma_2,\frac1\sigma_3)R_1^T M=R1scale(σ1,σ2,σ3)R2,M1=R2Tscale(σ11,σ12,σ13)R1T

6.5 Coordinate Transformations

P x y = [ u v e 0 0 1 ] P u v P_{xy}= \begin{bmatrix} u&v&e\\ 0&0&1 \end{bmatrix} P_{uv} Pxy=[u0v0e1]Puv

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值