function [ celkem ] = vzdalenostOdCentroidu3D( obrys )
%VZDALENOSTODCENTROIDU Summary of this function goes here
%   Detailed explanation goes here
    
    
    rp = regionprops(obrys);
    
    centre = rp.Centroid;
%     [x, y, z] = find(obrys);
    
    x = []; y = []; z = [];
    for i = 1:size(obrys,1)
        for j=1:size(obrys,2)
            for k = 1:size(obrys,3)
               if obrys(i,j,k) == 1
                  x = [x i];
                  y = [y j];
                  z = [z k];
               end
            end
        end
    end
    
    distsXY = sqrt((x-centre(2)).^2 + (y-centre(1)).^2);
    distsXZ = sqrt((y-centre(1)).^2 + (z-centre(3)).^2);
    
    dists = sqrt((x-centre(2)).^2 + (y-centre(1)).^2 + (z-centre(3)).^2);
    

    
    
    
    x = x - centre(2);
    y = y - centre(1);
    z = z - centre(3);
    r = sqrt(x.^2 + y.^2 + z.^2);
    
    uhel3 = acosd(x./r);
    uhel4 = atand(y./z);
    
    azimuth = atan2d(z,y);
    azimuth2 = atan2d(x,y);
    elevation = atan2d(x,sqrt(y.^2 + z.^2));
    r = sqrt(x.^2 + y.^2 + z.^2);
    
    celkem(1,:) = r;
    celkem(2,:) = azimuth;
    celkem(3,:) = azimuth2;
    celkem(4,:) = elevation;
    
    
    
end



   


    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    

