function X = sph2cartm2(sco)
% [ X ] = sph2cartm2( sco )
% Transforms hypershperical to cartesian coordinates, assumes that the radius is one.
% 
% Input: 
%   sco     angles of spherical coordinates, vector of dim-1 entries
%           radius is fixed to 1
% 
% Output:
%   X       cartesian coordinates
% 
% E.g.: sph2cartm2(cart2sphm2([2 3 1]))
%       sph2cartm(cart2sphm([2 3 1]))
%
%
% See also: sph2cartm2, cart2sphm, sph2cartm, cart2sphm2
%
% Written by: tommsch, 2018

%r=sco(end);

sinval=sin(sco);
cosval=cos(sco);

dim=length(sco)+1;
X=zeros(1,dim);
%XC=cell(1,dim);
cosval(end+1)=1;
for i=1:dim
    X(i)=prod([sinval(1:i-1) cosval(i)]);
   % XC{i}=[sinval(1:i-1) cosval(i)];
end

end

function dummy; end %#ok<DEFNU> %Generates an error, if the 'end' of a function is missing.   