function out = rotate_z(X,phi) % % % This function rotates a set of points around the z-axis by phi degrees. % The x,y,z coordinates of the points are given in X. % % Peter Schall, 2003. % % phi = phi*pi/180; % Center the set of points x0 = max(X(:,1)) / 2; y0 = max(X(:,2)) / 2; X(:,1) = X(:,1) - x0; X(:,2) = X(:,2) - y0; % Define Rotation matrix M = [cos(phi) sin(phi) 0; -sin(phi) cos(phi) 0; 0 0 1]; % Rotate X = X * M; % Displace back xmin = min(X(:,1)); ymin = min(X(:,2)); X(:,1) = X(:,1) - xmin + 1; X(:,2) = X(:,2) - ymin + 1; out = X;