function [ bvhchannels ] = expmap2bvh2( skel, expchannels, bvhfile, fl)
%Converts an exp map representation to bvh file

bvhchannels = zeros(size(expchannels));
bvhchannels(:,1:3) = expchannels(:,1:3);

for i=1:size(expchannels,1)
    %for j=4:3:(size(expchannels,2))
     for k=1:length(skel.tree)
         
         if ~isempty(skel.tree(k).rotInd)
             %expmap = expchannels(i,j:j+2);
             
             expmap = expchannels(i,skel.tree(k).expmapInd);
             R = RotationMatrix(expmap,'exponentialMap');
             euler = R.GetEulerAngles();
             
             E = -rad2deg(euler(1,:));
             
             bvhchannels(i,skel.tree(k).rotInd) = E;
        end
    end
end


% bvhWriteFileZYX(bvhfile,skel,bvhchannels,fl);
bvhWriteFileXYZ(bvhfile,skel,bvhchannels,fl);
end

     

