function [u,theta] = AxisFromRotMat(R)

costheta = (trace(R) - 1)/2;
Ksintheta = (R-R')/2
u(1) = Ksintheta(3,2);
u(2) = Ksintheta(1,3);
u(3) = Ksintheta(2,1);

sintheta = norm(u);
u = -u(:)/norm(u);
theta = atan2(sintheta,costheta);
