%p = patch(isosurface(x,y,z,v,-3));
%isonormals(x,y,z,v,p)
%set(p,'FaceColor','red','EdgeColor','none');

clf
set(0,'defaulttextinterpreter','latex')
F1=@(x,y,z) y.^2.*z; F2=@(x,y,z) 2*x.*y.*z+z.^2; F3=@(x,y,z) x.*y.^2+2*y.*z+2*z;
x=linspace(-3,3,7);y=linspace(-3,3,8);z=linspace(-3,3,8);
[X,Y,Z]=meshgrid(x,y,z);
quiver3(X,Y,Z,F1(X,Y,Z),F2(X,Y,Z),F3(X,Y,Z),2,'Color','r','LineWidth',1.5)
rotate3d on
hold on
title('$\mathbf{F}(x,y,z) = y^2z \mathbf{i} +(2xyz+z^2)\mathbf{j}+(xy^2+2yz+2z)\mathbf{k}$','FontSize',14)
pause
[S1 S2 S3]=meshgrid(linspace(-1.5,1.5,6));
streamline(X,Y,Z,F1(X,Y,Z),F2(X,Y,Z),F3(X,Y,Z),S1,S2,S3)
te=text(-2,-2.5,-4,'Faltlinjer','FontSize',14);
pause
phi=@(x,y,z) x.*y.^2.*z+y.*z.^2+z.^2;
%isosurface(X,Y,Z,phi(X,Y,Z),2)
V=phi(X,Y,Z);
isosurface(X,Y,Z,V,2);
camlight
axis equal
pause
p = patch(isosurface(X,Y,Z,V,8));
isonormals(X,Y,Z,V,p)
set(p,'FaceColor','red','EdgeColor','none');
p = patch(isosurface(X,Y,Z,V,-13));
isonormals(X,Y,Z,V,p)
set(p,'FaceColor','cyan','EdgeColor','none');
daspect([1,1,1])
view(3); axis tight
camlight 
lighting gouraud
%set(p,'EdgeColor','black');
%shading interp
axis equal
%axis off
te=text(0,-2,-4,'Ekvipotentialyta','FontSize',14);