function B = rotateB(A,degrees)
    % Translate backwards
    % bepaal dimentie
    B = A;
    degrees_rad = degrees * pi / 180;
    %rotatiematrix
    R = [ cos(-degrees_rad), sin(-degrees_rad), 0;
          sin(degrees_rad), cos(-degrees_rad), 0;
          0, 0, 1];
    %bepaal buitenzijden en midden
    [in_size_x, in_size_y] = size(A);
    in_mid_x = ( in_size_x-1) / 2;
    in_mid_y = ( in_size_y-1) / 2;
    %max grootte van het nieuwe plaatje is de helft de diameter
    % en dan 'rechtop'
    dia = int64(sqrt(in_size_x^2  + in_size_y^2 ));
    B = zeros([dia,dia]);
    %grootte van de nieuwe matrix
    [out_size_x, out_size_y] = size(B);
    out_mid_x = ( out_size_x-1) / 2;
    out_mid_y = ( out_size_y-1) / 2;
    %
    %translatiematrix
    Tout = [ 1, 0, -out_mid_x;
             0, 1, -out_mid_y;
             0, 0, 1;];
    Tin = [ 1, 0, in_mid_x;
            0, 1, in_mid_y;
            0, 0, 1; ];
    Trans = Tin * R * Tout;
    % Laten we maar gaan draaien ;-)
    for i=1:out_size_x
        for j=1:out_size_y
            out = round(Trans * [i;j;1;]);
            %controleren of punt bestaat
            if ( out(1) >= 1 && out(1) <= in_size_x && ...
                 out(2) >= 1 && out(2) <= in_size_y )
                %gegevens overhevelen
                B(i,j) = A(out(1),out(2));
            else
                %puntje zwart maken
                B(i,j) = 0;
            end
        end
    end



