使用matlab验证modelview矩阵
2016-04-04 17:24
609 查看
format compact posX = 3; % 物体位置 posY = -2; posZ = 4;
rotX = 15; % 物体旋转角度 rotY = 14; rotZ = 14; camX = 3; % 摄像机位置 camY = -2; camZ = 10; pitch = 14; % 绕X轴 heading = 10; % 绕Y轴 roll = 14; % 绕Z轴 % 转成弧度 rotX = deg2rad(rotX); rotY = deg2rad(rotY); rotZ = deg2rad(rotZ); % 模型平移矩阵 tran_matrix = [ 1 0 0 posX 0 1 0 posY 0 0 1 posZ 0 0 0 1]; % 模型绕Z旋转矩阵 rotZ_matrix = [ cos(rotZ) -sin(rotZ) 0 0 sin(rotZ) cos(rotZ) 0 0 0 0 1 0 0 0 0 1]; % 模型绕Y旋转矩阵 rotY_matrix = [ cos(rotY) 0 sin(rotY) 0 0 1 0 0 -sin(rotY) 0 cos(rotY) 0 0 0 0 1]; % 模型绕X旋转矩阵 rotX_matrix = [ 1 0 0 0 0 cos(rotX) -sin(rotX) 0 0 sin(rotX) cos(rotX) 0 0 0 0 1]; %模型矩阵 model = tran_matrix * rotX_matrix * rotY_matrix * rotZ_matrix * eye(4); model % 转成弧度 pitch = deg2rad(pitch); heading = deg2rad(heading); roll = deg2rad(roll); % 视图平移矩阵 tran_matrix = [ 1 0 0 -camX 0 1 0 -camY 0 0 1 -camZ 0 0 0 1]; % 模型绕Z旋转矩阵 rotZ_matrix = [ cos(-roll) -sin(-roll) 0 0 sin(-roll) cos(-roll) 0 0 0 0 1 0 0 0 0 1]; % 模型绕Y旋转矩阵 rotY_matrix = [ cos(-heading) 0 sin(-heading) 0 0 1 0 0 -sin(-heading) 0 cos(-heading) 0 0 0 0 1]; % 模型绕X旋转矩阵 rotX_matrix = [ 1 0 0 0 0 cos(-pitch) -sin(-pitch) 0 0 sin(-pitch) cos(-pitch) 0 0 0 0 1]; view = rotZ_matrix * rotY_matrix * rotX_matrix * tran_matrix * eye(4); view modelview = view * model
相关文章推荐
- Matlab曲线绘制详解
- 将matlab的m文件转成C语言
- matlab simulink 使用总结
- Arduino & Matlab
- matlab图像边缘检测
- 实现MATLAB2016a和M文件关联
- Matlab批量转换彩色图像为灰度图像(批量读文件和写文件)
- PCA图像压缩的matlab实现
- matlab矩阵的定义和运算
- matlab 取整函数的使用
- 多分类问题中每一类的Precision-Recall Curve曲线以及ROC的Matlab画法
- 多分类问题中混淆矩阵(Confusion Matrix)的Matlab画法
- MATLAB笔记
- matlab matconvnet
- matlab多变量牛顿方法求解非线性方程组
- 数据挖掘-matlab实现基于MovieLens数据集的协同过滤电影推荐系统
- 初学决策树之用Matlab工具箱函数实现性别识别
- matlab之simulink仿真入门
- matlab下利用K-Means进行图像分类
- 用matlab实现视频的空间滤波和直方图均衡化