所以我在MATLAB上有一个3D图,由下图表示。
每次运行GUI时,每次都要在绘图上打印红色,绿色和蓝色框,粉色平面也是如此,这会减慢我的程序。
无论如何,在第一个循环的情况下打印那些飞机和盒子并且永远不再在情节中打印?但仍然有能力在那些粉红色的平面内绘制小棒图?
以下代码:
function plotscene(RS,LS,LH,RH,cam_coor,handles)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
%Frontwall
axis equal
point1 = [410,0,-1000]
point2 = [-1130,0,-1000]
point3 = [-1130,0,2000]
point4 = [410,0,2000]
points = [point1' point2' point3' point4']
fill3(points(1,:),points(2,:),points(3,:),[1,0.4,0.5],'Parent',handles.axes2)
axes(handles.axes2)
alpha(0.3)
hold (handles.axes2,'on')
%SideWall#1
point1 = [410,0,-1000]
point2 = [410,3500,-1000]
point3 = [410,3500,2000]
point4 = [410,0,2000]
points = [point1' point2' point3' point4']
fill3(points(1,:),points(2,:),points(3,:),[1,0.4,0.5],'Parent',handles.axes2)
%axis vis3d
axes(handles.axes2);
alpha(0.3)
%SideWall#2
point1 = [-1130,0,-1000]
point2 = [-1130,3500,-1000]
point3 = [-1130,3500,2000]
point4 = [-1130,0,2000]
points = [point1' point2' point3' point4']
fill3(points(1,:),points(2,:),points(3,:),[1,0.4,0.5],'Parent',handles.axes2)
%axis vis3d
axes(handles.axes2);
alpha(0.3)
axes(handles.axes2);
plotcube([580 950 860],[-170 1570 -1000], .8, [1 0 0])
plotcube([360 400 600],[-50 960 -1000], .8, [0 1 0])
plotcube([1540 750 450],[-1130 0 -1000], .8, [0 0 1])
plot3(RS(1,1),RS(3,1),RS(2,1),'b*','Parent',handles.axes2); %%%SWAP Y n Z
% axis vis3d
plot3(RH(1,1),RH(3,1),RH(2,1),'r*','Parent',handles.axes2);
% axis vis3d
plot3(LS(1,1),LS(3,1),LS(2,1),'y*','Parent',handles.axes2);
% axis vis3d
plot3(LH(1,1),LH(3,1),LH(2,1),'g*','Parent',handles.axes2);
% axis vis3d
pts_shld = [RS(1,1),RS(3,1),RS(2,1);LS(1,1),LS(3,1),LS(2,1)];
pts_hip = [RH(1,1),RH(3,1),RH(2,1);LH(1,1),LH(3,1),LH(2,1)];
plot3(pts_shld(:,1),pts_shld(:,2),pts_shld(:,3),'Parent',handles.axes2);
% axis vis3d
plot3(pts_hip(:,1),pts_hip(:,2),pts_hip(:,3),'Parent',handles.axes2)
% axis vis3d
shld_mid_pt = (LS+RS)/2
plot3(shld_mid_pt(1,1),shld_mid_pt(3,1),shld_mid_pt(2,1),'co','Parent',handles.axes2);
% axis vis3d
hip_mid_pt = (RH+LH)/2
plot3(hip_mid_pt(1,1),hip_mid_pt(3,1),hip_mid_pt(2,1),'mo','Parent',handles.axes2);
% axis vis3d
pts_mid = [hip_mid_pt(1,1),hip_mid_pt(3,1),hip_mid_pt(2,1);
shld_mid_pt(1,1),shld_mid_pt(3,1),shld_mid_pt(2,1)]
plot3(pts_mid(:,1),pts_mid(:,2),pts_mid(:,3),'Parent',handles.axes2)
% axis vis3d
grid(handles.axes2, 'on')
axis vis3d
plotcube([50 100 50], [cam_coor(1,1) cam_coor(3,1) cam_coor(2,1)],1,[0.2 0.2 0.2]); hold on
grid on
axis equal
xlim([-1130 410])
ylim([0 3500])
zlim([-1000 2000])
xlabel('x-axis','Parent',handles.axes2)
ylabel('z-axis','Parent',handles.axes2)
zlabel('y-axis','Parent',handles.axes2)
hold (handles.axes2,'off')
end