scan-context/src2/example/longterm_localization/NCLT/2012-01-15/1_DataMaker/helper/getThetaFromXY.m

18 lines
367 B
Matlab

function [ theta ] = getThetaFromXY( x, y )
if (x >= 0 && y >= 0)
theta = 180/pi * atan(y/x);
end
if (x < 0 && y >= 0)
theta = 180 - ((180/pi) * atan(y/(-x)));
end
if (x < 0 && y < 0)
theta = 180 + ((180/pi) * atan(y/x));
end
if ( x >= 0 && y < 0)
theta = 360 - ((180/pi) * atan((-y)/x));
end
end