function mat = config2mat(config)

ni = size(config,2);
nj = size(config,3);

mat = zeros([3 3 ni nj]);
mat(1:2,3,:) = config(1:2,:);
st = sin(config(3,:));
ct = cos(config(3,:));
mat(1,1,:) = ct;
mat(1,2,:) = -st;
mat(2,1,:) = st;
mat(2,2,:) = ct;
mat(3,3,:) = 1;
