1 Star 0 Fork 0

ACertainUser/我的赛博大物实验

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
seeMesh.m 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
%这个octave/matlab代码演示了简易的透视
clc
clear
M = 15;
n = 4;
for i = 1:M
for j = 1:M
point_real(i,j).x = i - M/2; %create points in world
point_real(i,j).y = j + 5;
point_real(i,j).z = -5;
point_screen(i,j).x = n*point_real(i,j).x/point_real(i,j).y; %create relavent points on screen
point_screen(i,j).y = n;
point_screen(i,j).z = n*point_real(i,j).z/point_real(i,j).y;
endfor
end
figure()
hold on
axis equal
view(0,0)
xlabel('x')
ylabel('y')
zlabel('z')
scatter3(0,0,0);
[x y] = meshgrid(-5:0.5:5,n-4:0.5:n+1); %draw screen
z=zeros(size(x));
s = surf(x,y,z,'EdgeColor','none','FaceColor',[0.9 0.9 0.9]);
rotate(s,[1 0 0],90,[0,n,0]);
for i = 1:M
j=i;
line([point_real(i,1).x point_real(i,M).x], [point_real(i,1).y point_real(i,M).y], [point_real(i,1).z point_real(i,M).z],'color','r');
line([point_real(1,j).x point_real(M,j).x], [point_real(1,j).y point_real(M,j).y], [point_real(1,j).z point_real(M,j).z],'color','b');
line([point_screen(i,1).x point_screen(i,M).x], [point_screen(i,1).y point_screen(i,M).y], [point_screen(i,1).z point_screen(i,M).z],'color','r');
line([point_screen(1,j).x point_screen(M,j).x], [point_screen(1,j).y point_screen(M,j).y], [point_screen(1,j).z point_screen(M,j).z],'color','b');
end
i = int32(rand()*M/2+1);
j = int32(rand()*M/2+1);
line([0 point_real(i,j).x], [0 point_real(i,j).y], [0 point_real(i,j).z],'color','k');
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Matlab
1
https://gitee.com/acertainuser/my---matlab-script.git
git@gitee.com:acertainuser/my---matlab-script.git
acertainuser
my---matlab-script
我的赛博大物实验
master

搜索帮助