矩阵表达缩放
旋转矩阵表示方式为:
a 0 0 0
0 b 0 0
0 0 c 0
0 0 0 1
验证如下:
A = [x,y,z] ,如果要将A进行缩放,假设缩放比为N =[a,b,c],那么缩放结果应为 [x*a,y*b,z*c]
[x,y,z,w] *{ a,0,0,0} =a*x+y*0+z*0+w*1 =a*x
0,b,0,0 =x*0+y*b+z*0+w*0 =y*b
0,0,c,0 =x*0+y*0+z*c+w*0 =z*c
0,0,0,1 =x*0+y*0+z*0+w*1 =w
结果[a*x,y*b,z*c,w]与预期相符
矩阵表达旋转
假设轴 为n =(x,y,z).旋转α角度。 c = cos(α),s = sin(α)
那么旋转的矩阵表示为:
c+(1-c)x2 (1-c)x*y+s*z (1-c)x*z -s*y 0
(1-c)x*y-s*z c+(1-c)y2 (1-c)y*z+s*x 0
(1-c)x*z+s*y (1-c)y*z-s*x c+(1-c)z2 0
0 0 0 1
如果旋转轴为 x[1,0,0],旋转角度为α,那么其旋转矩阵为:
1 0 0 0
0 cos(α) sin(α) 0
0 -sin(α) cos(α) 0
0 0 0 1