Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档 > MATLAB技术文章
MATLAB技术文章 MATLAB Technical Articles From Mathworks
 
 
主题工具 显示模式
旧 2023-02-11, 03:23   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Grafix Users Guide - Cleve Moler on Mathematics and Computing

This is a quick look at Grafix, our tool for exploring matrices via 3-D computer graphics.



Contents
Matrices

The word matrix comes from the Latin word mater, which means mother or origin. Matrices provide the origins of much of modern applied mathematics and computational science.

Grafix is a study of the matrices that describe rotation, translation and scaling of objects moving in three-dimensional space. These matrices are the building blocks of today's computer graphics and are essential to all popular video games, to all CAD (Computer Added Design) packages, to CGI (Computer Graphics Imagery) in films. and to MATLAB's Handle Graphics.

MATLAB is short for Matrix Laboratory. Matrices are also the foundation of MATLAB and of MathWorks.

The homogeneous coordinates system used in modern computer graphics makes it possible to describe rotations, translations and many other operations with 4-by-4 matrices. These matrices operate on vectors with the position of an objec in the first three components and, for now, a one as the fourth component, e.g. [x,y,z,1]',

The matrices, which we collectively denote by M, are always shown in the panel in our displays. Here is an animation of one important example. Do you see the pattern in the evolving elements of this M? How are they related to each other? How long before they repeat?



Axis

Here is the coordinate system used by view(3), MATLAB's default projection of our three-dimensional physical world onto the two-dimensional computer display. The positive x-axis goes up and to the right on the screen, the positive y-axis goes up and to the left, and the positive z-axis goes straight up.



Rx

The three knobs at the lower right of the Grafix window allow you to vary the angles of Rx, Ry and Rz. Here are snapshots of the resulting motion. The Rx knob produces rotation about the x-axis, leaving x unchanged while rotating y and z.



Ry

Ry, rotation about the y-axis, leaves y unchanged while rotating x and z.



Rz

And, Rz, rotation about the z-axis, leaves z unchanged while rotating x and y.



Tx

The three sliders at the lower left of the Grafix window control matrices with values in the fourth column. Multiplying a vector by Tx, which has a nonzero element in the first row, produces a horizontal movement in the direction of the x-axis.



Ty

Ty, with a nonzero in the second row, is translation in the direction of the y-axis.



Tz

And, Tz is translation in the z direction.



S

The fourth slider controls S, a diagonal matrix with a single scaling factor for all three axes.

The use of matrix multiplication allows translations and scaling to be combined with rotations and other operations in a uniform way. The arithmetic units on today's Graphics Processing Units, GPUs, are designed to do 4-by-4 matrix multiplications at speeds hundreds of times faster than general purpose Central Processing Units, CPUs.



Switches

The switch on the left provides other objects that we will introduce later. The switch on the right provides different views of three dimensions. The yz plane view is shown here.



Pitch, Roll, Yaw

Pitch, roll and yaw are often used to describe the motion of aircraft and spacecraft. These terms are closely related to the rotations Rx, Ry and Rz. The Pitch button animates the Rx knob. Here is a snapshot near one extreme of the resulting motion.



Start, Reset, Viz

The Start button restarts Grafix. The Reset button resets all knobs and sliders.

The Viz button turns off the display of buttons, knobs, sliders, and switches. A small button, emphasized here with color, but usually barely visible, turns the display back on.



Apps/taxi

Grafix is programable, in a primitive sort of way. Apps are Grafix programs. Taxi is a small app. This is a snapshot.



Apps/takeoff

When the takeoff app first appeared, I thought it was a bug in the code for Grafix.

You can see the takeoff program by entering type takeoff at the MATLAB command prompt. You can also edit takeoff.



Prop

One of my favorite animations employs the rotations from the Matrices section to drive the propeller alone.



Info

The info button is a link to this User's Guide.



Exercises
  • What color is the beacon on top of the plane?
  • Demonstrate how matrix-vector multiplication, Mv, of a position vector, v = [x,y,z,1]', by a 4-by-4 matrix M, achieves a rotation, translation or scaling.
  • Describe the evolution of the matrix values in the Matrices and prop animations.
  • What angles are involved in the snapshots shown for Rx, Ry and Rz?
  • Why is the plane in the Pitch animation upside down?
  • What angles and what matrices characterize the extremes of the Pitch animation?
  • Write another app like taxi and takeoff.
Software

The MATLAB code for Grafix is available here.


Get the MATLAB code (requires JavaScript)

Published with MATLAB® R2023a




More...
poster 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 23:31


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.