function [xr,yr]=rotate2d(x,y,angle,x0,y0)
%[xr,yr]=rotate2d(x,y,angle,x0,y0)
%rotate2d rotates x,y around x0,y0 counterclockwise for 'angle' of degree.
%x,y are old coordinate, xr,yr are new coordinate,
% the coordinate system are *NOT* changed
% it is the same as rotate the coordinate system CW of 'angle'
% x,y can be a matrix.

% Xia Ma

t=angle*pi/180;
x=x-x0;y=y-y0;

xr=x*cos(t)-y*sin(t);
yr=x*sin(t)+y*cos(t);
xr=xr+x0;yr=yr+y0;

% its jacobian matrix is the same as rotation matrix

