
if ( ~exist('dist') ),
	cd D:\LAZA\DICKST~1
	path(path, 'D:\LAZA\DICKST~1');
%	cd G:\DICKST~1
%	path(path, 'G:\DICKST~1');
	filename = 'meat102';
	% [dist,k,h,w] = dLoadData(filename);
	disp('Loading data ...');
	load meat102
	more off
	dTeta;		% Calculating goodness of the signal
	dDelBad;	% Removing bad signals from the matrices
end; %if ( ~exist('dist') )

n = size(dist,2); k = size(dist,1)/n;
x = zeros(n,k); y = zeros(n,k); z = zeros(n,k); 
R = sqrt(1/3)*mean(mean( dist(1:n,1:n) ));

[x1,y1,z1] = dInitial( dPlane(dist,1), dPlane(teta,1) );

disp('Calculating points coordinates');
tic;
tmax = k;
for t = 1:tmax,
	d = dPlane(dist,t);
	tt= dPlane(teta,t);
	[x1,y1,z1,e] = ...
		dMinNoZero( x1,y1,z1, d , tt );
	x(1:n,t) = x1;
	y(1:n,t) = y1;
	z(1:n,t) = z1;
%    if( rem(k-1,100) == 0),
	disp(sprintf('%d/%d  e = %f ',t,k, e));
%    end; %if
end; %for
toc;
disp('Calculating distances between new points...');
d2 = zeros(size(dist));
for t = 1:k,
	d2(n*(t-1)+(1:n), 1:n ) = dDistances(x(:,t),y(:,t),z(:,t));
end;
disp('Calculations done');
toc

disp('Saving Data...');
%save dtxyz3 dist teta x y z n k filename

t = 1:n;
xyz = zeros( size(x,2), 3*size(x,1));
xyz(:,3*(t-1)+1) = x';
xyz(:,3*(t-1)+2) = y';
xyz(:,3*(t-1)+3) = z';
%

disp('Done');

