function klic = trn_klic(x, y, xx, yy)
% klic = trn_klic(x, y, xx, yy)
% klic = [tx, ty, q, omega]

%% test vstupnich parametru
if nargin~=4
    error( 'Neplatny pocet vstupnich parametru!' )
end
if length(x)~=2 | length(y)~=2 | length(xx)~=2 | length(yy)~=2
    errot( 'Pocet identickych bodu jsou dva!' )
end

%% vypocet
dx = x(2)-x(1);
dy = y(2)-y(1);
dxx = xx(2)-xx(1);
dyy = yy(2)-yy(1);

a1 = (dx*dxx + dy*dyy) / (dx^2+dy^2);
a2 = (dxx*dy - dyy*dx) / (dx^2+dy^2);
q = sqrt(a1^2 + a2^2);
omega = atan2(a2, a1) * 200/pi;
tx = xx(1) -a1*x(1) -a2*y(1);
ty = yy(1) +a2*x(1) -a1*y(1);

klic = [tx, ty, q, omega];
