اینم کدهای متلب لازم برای رسم تعدادی جسم به صورت سه بعدی (کپی شده از یک سایت دیگر) :
نتیجه اجرای کد متلب بالا :
منبع کدها :
http://people.rit.edu/pnveme/pigf/ThreeD..._cube.html
کد:
% 3D Graphics: Cube
% Dr. P.Venkataraman
format compact
set(gcf,'Menubar','none','Name','Cube', ...
'NumberTitle','off','Position',[10,350,300,200], ...
'Color',[0.3 0.1 0.3]);
% the cube
h(1) = axes('Position',[0.2 0.2 0.6 0.6]);
vert = [1 1 1; 1 2 1; 2 2 1; 2 1 1 ; ...
1 1 2;1 2 2; 2 2 2;2 1 2];
fac = [1 2 3 4; ...
2 6 7 3; ...
4 3 7 8; ...
1 5 8 4; ...
1 2 6 5; ...
5 6 7 8];
patch('Faces',fac,'Vertices',vert,'FaceColor','r'); % patch function
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny;
alpha('color');
alphamap('rampdown');
camlight(45,45);
lighting phong
view(30,30);
% cylinder
h(2) = axes('Position',[0.1 0.1 0.5 0.5]);
[Xs Ys Zs]=cylinder([1 0.5 1],20);
hs2 = surf(Xs, Ys, Zs);
set(hs2,'EdgeColor',[0.5 0.5 0.5], ...
'FaceColor','interp', ...
'FaceAlpha','interp');
alpha('color');
alphamap('rampdown');
alpha(0.3);
camlight right;
lighting phong
hidden off
axis equal
rotate(hs2,[1 0 0],45); % cylinder is rotated
% sphere
h(3)= axes('Position',[0.17 0.17 0.4 0.4]);
[Xs Ys Zs]=sphere(30);
hs3 = surf(Xs, Ys, Zs);
set(hs3,'EdgeColor','none', ...
'FaceColor','y', ...
'FaceLighting','phong', ...
'AmbientStrength',0.3, ...
'DiffuseStrength',0.8, ...
'SpecularStrength',0.9, ...
'SpecularExponent',25, ...
'BackFaceLighting','lit');
camlight left;
hidden off
set(h,'Visible','off')
axis square
نتیجه اجرای کد متلب بالا :
منبع کدها :
http://people.rit.edu/pnveme/pigf/ThreeD..._cube.html
لطفا برای درج کد، از دکمه مخصوص درج کد در ادیتور انجمن استفاده کنید.
در مورد برنامه نویسی، مدیران تنها راهنمایی می کنند و نوشتن برنامه نهایی، به عهده کاربران می باشد (اینجا محلی برای یادگیری است، نه سفارش کدنویسی).
کاربران باید ابتدا خود به خطایابی برنامه بپردازند، نه اینکه به محض دیدن خطا، کدها را در انجمن، copy و paste کرده و از مدیران انتظار بررسی داشته باشند.