% sBatch - demonstrates the B-spline fitting on superquadrics
%	Points on the suirface of superquadrics are generated and then fitted 

% Create the test-points as points on the surface of a superquadrics
[x1,y1,z1] = superquad(0.3,1.5,3);
t = 1:prod(size(x1));
  x = x1(t); y = y1(t); z = z1(t);

[az, el, r] = cart2sph(x,y,z); % transform points to spherical coordinates

sM = sFit(az,el, r);	       % fit points with splines

sPlotSurf(sM, x1,y1,z1);       % plot the spline surface and the original mesh

%k = size(sM,1);
%fi   = -pi   + 2*pi/k * floor((0:k*k-1)/k);
%teta = -pi/2 +   pi/k * rem(0:k*k-1,k);
%rho  = sM(1:k*k);
% I = find(teta<0); rho(I) = zeros(size(I));
%[x2,y2,z2] = sph2cart(fi,teta,rho);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%A = zeros(6,6); A(3:4,3:4)=ones(2,2);
%fi = 2*pi/6*rem((0:36-1),6); teta = pi/2/6*floor((0:35)/6); rho=A(1:36);


