计算机图形的核心矩阵

矩阵如下面的屏幕截图所示的矩阵是计算机图形的核心。它们描述了在三维空间中移动的物体。Matlab的句柄图形使用它们。Mathwork的新功能也是如此Roadrunner.编辑。所有流行的视频游戏和CAD包都也是如此。

内容

犹他州茶壶

From its introduction in 1976 by Martin Newell, then a grad student at the University of Utah, the Teapot has played an import role in the development of computer graphics. If you knew to look for it, you could have seen it in Pixar's movies and on episodes of Fox TV's Simpsons. There are an excellent维基百科页面和一个有趣的展览计算机历史博物馆。茶壶的坐标可在Matlab中获得功能茶几。A MATLAB live script describing shading and lighting of the teapot is在这里提供

茶壶= grafix;

M.

我对感兴趣M.,面板中的矩阵。现在是4×4的身份矩阵。该矩阵描述了在目标对象集合上进行的所有转换。

回转

Homogeneous coordinates make it possible to describe rotations, translations and many other transformations with 4-by-4 matrices. The matrices operate on vectors with the coordinates of the objects in the first three components and, for now, a one in the fourth.

This matrix leaves theZ.coordinates fixed while rotatingXandy

r_z(t)= [cosd(t)-sind(t)0 0 sind(t)cosd(t)0 0 0 0 1 0 0 0 0 1]

这是一个45度的旋转Z.

RZ.= R_z(45)
RZ = 0.7071 -0.7071 0 0 0.7071 0.7071 0 0 0 0 1.0000 0 0 0 0 1.0000

将此旋转应用于茶壶。

apply(Teapot,Rz)

RZ * RX.

一系列转换由所有矩阵的乘积表示。

这种正交的旋转叶X固定在旋转时yandZ.

R_x(t) = [ 1 0 0 0 0 cosd(t) -sind(t) 0 0 sind(t) cosd(t) 0 0 0 0 1]

跟随our original 45 degreeZ.transformation by a 60 degree rotation aboutX

RX.= R_x(60) M = Rx*Rz; apply(Teapot,M)
RX.= 1.0000 0 0 0 0 0.5000 -0.8660 0 0 0.8660 0.5000 0 0 0 0 1.0000

订单很重要,因为这些矩阵不通勤。这是逆转订单的结果。

m = rz * rx;申请(茶壶,m)

r

This leavesy固定在旋转时XandZ.

r_y(t)= [cosd(t)0 -sind(t)0 0 0 1 0 0 sind(t)0 cosd(t)0 0 0 0 1]
ry = r_y(-120)申请(茶壶,ry)
r= -0.5000 0 -0.8660 0 0 1.0000 0 0 0.8660 0 -0.5000 0 0 0 0 1.0000

Translation and scaling

Nonorthogonal matrices come from translation and scaling. Homogeneous coordinates and the fourth column of M produce translation. A typical translation is

T_x(t) = [ 1 0 0 t 0 1 0 0 0 0 1 0 0 0 0 1];
tx = t_x(2.5)
Tx = 1.0000 0 0 2.5000 0 1.0000 0 0 0 0 0 1.0000 0 0 0 0 1.0000

翻译茶壶沿着X轴。

apply(Teapot,Tx)

我们可以单独扩展每个坐标方向。或者,该矩阵将一个因素应用于所有坐标。

S_xyz(t)= [t 0 0 0 0 t 0 0 0 0 t 0 0 0 0 1];
SXYZ.= S_xyz(0.75)
Sxyz = 0.7500 0 0 0 0 0.7500 0 0 0 0 0.7500 0 0 0 0 1.0000

“亲爱的,我缩小了茶壶”。

申请(茶壶,SXYZ)

全部一起

我生成了五个转变,RX.RZ.rTX.andSXYZ.。Here is their product, in the order of their introduction.

m = sxyz * tx * ry * rz * rx;申请(茶壶,m)

Here is the reverse order.

m = rx * rz * ry * tx * sxyz;申请(茶壶,m)

Finally, a scrambled order.

m = rz * ry * sxyz * tx * rx;申请(茶壶,m)




发布MATLAB®R2021B

|

Comments

要发表评论,请点击here要登录您的MathWorks帐户或创建新的。