function [X Y] = trn (x, y, q, om, tx, ty)
% [X Y] = trn (x, y, q, om, tx, ty)
% lin. transfomace: x(i,j), y -> X(i,j), Y
% q: meritko
% om: uhel stoceni [rad]
% tx, ty: posuny

if nargin ~= 6
    error('Nutnych je 6 vstupnich parametru! (zadano %i)',nargin)
end
if ~all(size(x,1) == size(y,1) & size(x,1) == size(q,1) & size(x,1) == size(om,1) & size(x,1) == size(tx,1) & size(x,1) == size(ty,1))
    error('Vstupni parametry musi mit shodny pocet radku!')
end

for i = 1:size(x,1)
% matice rotace
R = [ cos(om(i,1)) -sin(om(i,1))
      sin(om(i,1))  cos(om(i,1)) ];

% vector posunu
t = repmat([tx(i,1) ty(i,1)]',1,size(x,2));

%vypocet transformace
XY = q(i,1) .* R * [x(i,:); y(i,:)] + t;
X(i,:) = XY(1,:);
Y(i,:) = XY(2,:);
end
