пятница, 24 марта 2017 г.

Simple graphics examples for Matlab 3D

1. Elefant
[x,y,z] = meshgrid(-2:0.1:2);
F=(x.^2 + y.^2 + z.^2) - 3;
isosurface(x,y,z,F,0);
 F=(x.^3 + y.^3 + z.^3) -2;
 isosurface(x,y,z,F,0);
 axis auto
 axis([-3, +3 , -3, +3, -3, +3]);

2. 
[x,y,z] = meshgrid(-2:0.1:2); 
 F=x.^2 + y.^2 + z.^2 -3;
 isosurface(x,y,z,F,0);
 F=x.^2 + y.^3 + z.^2 -3;
 isosurface(x,y,z,F,0);
 F=x.^2 + y.^3 + z.^2 +3;
 isosurface(x,y,z,F,0); 
 axis([-2.5, +2.5 , -2.5, +2.5,-2.5, +2.5]);

 % axis auto

3.
clc
[x,y,z] = meshgrid(-2:0.1:2);  
F=x.^4 + y.^4 + z.^4 - (x.^2 + y.^2 + z.^2); 
% surface(x,y,z,F,0)
% isosurface(x,y,z,F,0)
 hpatch = patch(isosurface(x,y,z,F,0)); 
 isonormals(x,y,z,F,hpatch); %посчитаем нормали для красоты
 set(hpatch,'FaceColor','r','EdgeColor','none'); %немного цвета для красоты

 camlight left; lighting phong; %немного света для красоты

Комментариев нет:

Отправить комментарий