%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tema 3. Integracio en R^n
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dominis problema 23 apartat f
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a = 2;

t=linspace(1,a,101);
[m,n]=size(t);
b=a*ones(1,n);
c=ones(1,n);

x=inline('1./(u.*v.^2.*w.^4).^(1/7)','u','v','w');
y=inline('1./(u.^4.*v.*w.^2).^(1/7)','u','v','w');
z=inline('1./(u.^2.*v.^4.*w).^(1/7)','u','v','w');

xmin = x(a,a,a);
ymin = y(a,a,a);
zmin = z(a,a,a);

xmax = x(1,1,1);
ymax = y(1,1,1);
zmax = z(1,1,1);

UVWTick = 1:0.25:a;
XYZTick = xmin:0.125:xmax;

figA=figure;
xlabel('$U$','interpreter','latex')
ylabel('$V$','interpreter','latex')
zlabel('$W$','interpreter','latex')
grid on
hold on
axis equal
axis([1,a,1,a,1,a]);
set(gca,'XTick',UVWTick);
set(gca,'YTick',UVWTick);
set(gca,'ZTick',UVWTick);
plot3(t,c,c,'k-','Linewidth',2);  %1
plot3(c,c,t,'k-','Linewidth',3);  %2
plot3(b,c,t,'k-','Linewidth',2);  %3
plot3(b,t,b,'k-','Linewidth',2);  %4

plot3(b,t,c,'k-','Linewidth',2);  %5
plot3(b,b,t,'k-','Linewidth',2);  %6
plot3(t,b,c,'k-','Linewidth',2);  %7
plot3(c,t,c,'k-','Linewidth',2);  %8

plot3(c,b,t,'k-','Linewidth',2);  %9
plot3(t,b,b,'k-','Linewidth',2);  %10
plot3(c,t,b,'k-','Linewidth',2);  %11
plot3(t,c,b,'k-','Linewidth',2);  %12

view(60,30)
hold off

figB = figure;
xlabel('$X$','interpreter','latex')
ylabel('$Y$','interpreter','latex')
zlabel('$Z$','interpreter','latex')
grid on
hold on
axis equal
axis([xmin,xmax,ymin,ymax,zmin,zmax]);
set(gca,'XTick',XYZTick);
set(gca,'YTick',XYZTick);
set(gca,'ZTick',XYZTick);
plot3(x(t,c,c),y(t,c,c),z(t,c,c),'k-','Linewidth',2); %1
plot3(x(c,c,t),y(c,c,t),z(c,c,t),'k-','Linewidth',2); %2 
plot3(x(b,c,t),y(b,c,t),z(b,c,t),'k-','Linewidth',2); %3 
plot3(x(b,t,b),y(b,t,b),z(b,t,b),'k-','Linewidth',2); %4

plot3(x(b,t,c),y(b,t,c),z(b,t,c),'k-','Linewidth',2); %5
plot3(x(b,b,t),y(b,b,t),z(b,b,t),'k-','Linewidth',2); %6
plot3(x(t,b,c),y(t,b,c),z(t,b,c),'k-','Linewidth',2); %7
plot3(x(c,t,c),y(c,t,c),z(c,t,c),'k-','Linewidth',2); %8

plot3(x(c,b,t),y(c,b,t),z(c,b,t),'k-','Linewidth',2); %9
plot3(x(t,b,b),y(t,b,b),z(t,b,b),'k-','Linewidth',2); %10
plot3(x(c,t,b),y(c,t,b),z(c,t,b),'k-','Linewidth',2); %11
plot3(x(t,c,b),y(t,c,b),z(t,c,b),'k-','Linewidth',2); %12

view(60,30)
hold off