MATLAB 3D 动画制作(二)- 3D 动画动作设计
前言:本系列教程将逐步完成一个有趣的MATLAB 3D动画,MATLAB 3D图形的绘制和3D动画的制作可以让工程人员很直观地展示工作内容,特别是在虚拟现实,控制系统设计,人机交互,计算机视觉,等领域都能得到应用。
MATLAB 3D 动画制作(二)- 3D 动画动作设计 是 MATLAB 3D 动画制作(一)- 3D 图形设计 的进阶篇。
Introduction: This series of tutorials are going to discuss a process of making 3D animation using MATLAB step by step. The 3D animation in MATLAB can let the engineers exhibit their work. It can be used widely, especially at the fields of Virtual Reality, Control system Designing, Human-machine interactivity, Computer Vision, etc.
首先介绍一下本教程的最终效果:
Below is the final effect of this 3D animation.
Section 2: 3D Animation Action Design (3D 动画动作设计)
请在“爱问共享资料”搜索“MATLAB_3D实例_sTopEu”下载本实例的源码及说明文档资料包。
关于3D动作设计,暂时没有时间详述。
3D动画的原理就是: 计算新的坐标,绘图一次,再计算新的坐标,再绘图,如此往复循环,就实现了3D动画。
此处我们用到的是欧拉旋转矩阵来计算物体的旋转角:
物体的XYZ坐标 --> 用欧拉旋转矩阵计算出新的坐标 --> 绘图一次
循环
---------------
关于对“MATLAB_3D实例_sTopEu”资料包的说明:
资料包的文件列表如下:
使用时,运行一次sTopMain.m,点击“add to Path”,以此将它添加进MATLAB工作目录。
也许报错。然后在MATLAB 命令行窗口中输入“sTopMain(animation_A.dat)”,回车即可。
animaiton_A.dat -- 数据文件,存储了物体旋转角数据,以及帧间延迟时间
createInnerBars.m
createOuterBars.m
cylinderWeights.m
torus.m -- 都是建立3D物体的
EuMat.m -- 欧拉旋转矩阵
multiplyEuMat.m -- 用欧拉旋转矩阵计算新的坐标
sTopEuler.m -- 绘图,装配
sTopMain.m -- 主函数,实现动画
----------------------------------------------------------------------------------------------
In this section, We are going to discuss the approach to build the 3D object in MATLAB figure window. We are going to begin with the simple object like sphere, bar, cylinder, torus. And we also discuss make a more complicated 3D object by assembling these simple 3D object together.
1.1 introduction to the Tools we are going to use:
- surf function in MATLAB
- cylinder function in MATLAB
- sphere function in MATLAB
1.1.1 surf function in MATLAB
surf(X,Y,Z) uses Z for the color data and surface height. X and Y are vectors or matrices defining thex and y components of a surface. If X and Y are vectors, length(X) = n and