MATLAB 3D 动画制作(二)- 3D 动画动作设计

本教程详细介绍了如何使用MATLAB进行3D动画动作设计,包括欧拉旋转矩阵在3D物体旋转中的应用,以及如何通过surf、cylinder和sphere等函数创建简单和复杂3D对象。通过实例展示了如何逐步构建3D动画对象。
摘要由CSDN通过智能技术生成

MATLAB 3D 动画制作(二)- 3D 动画动作设计

 MATLAB 3D Animation -- 3D Animation Action Design
 Auther: Sonictl Northeastern University. 

前言:本系列教程将逐步完成一个有趣的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 

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于谷歌官方提供的3D翻转示例进行修改,修复了在不同设备上显示效果差异过大的问题。项目地址:https://github.com/GcsSloop/Rotate3dAnimation 效果图:如何使用:// 计算中心点(这里是使用view的中心作为旋转的中心点)         final float centerX = view.getWidth() / 2.0f;                 final float centerY = view.getHeight() / 2.0f;        //括号内参数分别为(上下文,开始角度,结束角度,x轴中心点,y轴中心点,深度,是否扭曲)         final Rotate3dAnimation rotation = new Rotate3dAnimation(this, start, end, centerX, centerY, 1.0f, true);         rotation.setDuration(1500);                               //设置动画时长         rotation.setFillAfter(true);                              //保持旋转后效果         rotation.setInterpolator(new AccelerateInterpolator());   //设置插值器         rotation.setAnimationListener(new AnimationListener() {   //设置监听器             @Override             public void onAnimationStart(Animation animation) {             }            @Override             public void onAnimationRepeat(Animation animation) {             }            @Override             public void onAnimationEnd(Animation animation) {             }         });         view.startAnimation(rotation);                            //开始动画
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值