function r = myAffine (image , x1 , y1 , x2 , y2 , x3 , y3 , m, n, method )
%calculate X
B = [x1 , x2 , x3; y1 , y2 , y3];
A = [1, m, m; 1, 1, n; 1, 1, 1];
X = B / A;

%allocate new image of correct size
r = zeros(n, m);

%make a list of all coordinates
points = [repmat([1:m], 1, n); floor([m:m*n+m-1]/m); ones(1,m*n)];

%transform them
points = X * points;

%interpolate them
for xa = 1:m
    for ya = 1:n
        % using the specified interpolation method
        r(ya, xa) = pixelValue(image, points(1, (ya-1)*m+xa), points(2, (ya-1)*m+xa), method);
    end
end
r = reshape(r, n, m);

