function rotatedImage = rotateImage (image , angle , method )

% Create the necessary rotation matrix
R = rot(angle);

% Obtain indices needed for interpolation
c = size(image);
d = c / 2;
x = c(2);
y = c(1);

points = [repmat([1:x], 1, y); floor([x:x*y+x-1]/x); ones(1,x*y)];
transl = repmat([d(2); d(1); 0], 1, size(points, 2));
points = points - transl;

points = zRotate(-angle, points);
points = points + transl;

%allocate matrix for result
newpixels = zeros(size(image));

% Obtain colors for the whole rotatedImage matrix
for a = 1:size(points, 2);
    % using the specified interpolation method
    newpixels(a) = pixelValue(image, points(2, a), points(1, a), method);
end
rotatedImage = reshape(newpixels, c);