%% Other "Patch Work" Details 
% These are all of the matrices from the memo I talked about in the "Patch
% Work" blog post.

%% Basis matrices
%
Mbezier = [-1  3 -3 1; ...
            3 -6  3 0; ...
           -3  3  0 0; ...
            1  0  0 0];

%%
%
Mbspline = [-1  3 -3 1; ...
             3 -6  3 0; ...
            -3  0  3 0; ...
             1  4  1 0] / 6;

%%
%
Mcatmullrom = [-1  3 -3  1; ...
                2 -5  4 -1; ...
               -1  0  1  0; ...
                0  2  0  0] / 2;

%%
%
Mhermite = [2 -3 0 1; ...
           -2  3 0 0; ...
            1 -2 1 0; ...
            1 -1 0 0];
        
%%
%
Mpower = eye(4);

%% To-From Matrices
%
Mbezier_to_bspline = [6 -7  2 0; ...
                      0  2 -1 0; ...
                      0 -1  2 0; ...
                      0  2 -7 6];
                  
%%
%
Mbezier_to_catmullrom = [6 -6  0 1; ...
                         1  0  0 0; ...
                         0  0  0 1; ...
                         1  0 -6 6];
%%
%
Mbezier_to_hermite = [1 0  0 0; ...
                      0 0  0 1; ...
                     -3 3  0 0; ...
                      0 0 -3 3];

%%
%
Mbezier_to_power = [-1  3 -3 1; ...
                     3 -6  3 0; ...
                    -3  3  0 0; ...
                     1  0  0 0];

%%
%
Mbspline_to_bezier = [1 4 1 0; ...
                      0 4 2 0; ...
                      0 2 4 0; ...
                      0 1 4 1] / 6;
                  
%%
% 
Mbspline_to_catmullrom = [6  1 -2 1; ...
                          1  4  1 0; ...
                          0  1  4 1; ...
                          1 -2  1 6] / 6;

%%
%
Mbspline_to_hermite = [1  4 1 0; ...
                       0  1 4 1; ...
                      -3  0 3 0; ...
                       0 -3 0 3] / 6;
                   
%%
%
Mbspline_to_power = [-1  3 -3 1; ...
                      3 -6  3 0; ...
                     -3  0  3 0; ...
                      1  4  1 0] / 6;

%%
%
Mcatmullrom_to_bezier = [0 6 0  0; ...
                        -1 6 1  0; ...
                         0 1 6 -1; ...
                         0 0 6  0] / 6;
                     
%%
%
Mcatmullrom_to_bspline = [7 -4  5 -3; ...
                         -2 11 -4  1; ...
                          1 -4 11 -3; ...
                         -2  6 -4  7] / 6;

%%
%
Mcatmullrom_to_hermite = [0  2 0 0; ...
                          0  0 2 0; ...
                         -1  0 1 0; ...
                          0 -1 0 1] / 2;

%%
%
Mcatmullrom_to_power = [-1  3 -3  1; ...
                         2 -5  4 -1; ...
                        -1  0  1  0; ...
                         0  2  0  0] / 2;
                     
%%
%
Mhermite_to_bezier = [3 0 0  0; ...
                      3 0 1  0; ...
                      0 3 0 -1; ...
                      0 3 0  0] / 3;

%%
%
Mhermite_to_bspline = [-3  6 -7 -2; ...
                        6 -3  2  1; ...
                       -3  6 -1 -2; ...
                        6 -3  2  7] / 3;

%%
%
Mhermite_to_catmullrom = [0 1 -2 0; ...
                          1 0  0 0; ...
                          0 1  0 0; ...
                          1 0  0 2];

%%
%
Mhermite_to_power = [2 -2  1  1; ...
                    -3  3 -2 -1; ...
                     0  0  1  0; ...
                     1  0  0  0];
                 
%%
%
Mpower_to_bezier = [0 0 0 3; ...
                    0 0 1 3; ...
                    0 1 2 3; ...
                    3 3 3 3]/3;
                
%%
%
Mpower_to_bspline = [0  2 -3 3; ...
                     0 -1  0 3; ...
                     0  2  3 3; ...
                    18 11  6 3] / 3;
                
%%
%
Mpower_to_catmullrom = [1 1 -1 1; ...
                        0 0  0 1; ...
                        1 1  1 1; ...
                        6 4  2 1];
                    
%%
%
Mpower_to_hermite = [0 0 0 1; ...
                     1 1 1 1; ...
                     0 0 1 0; ...
                     3 2 1 0];
  
%% Derivative Matrices
%
dv = [0 0 0 0; ...
      3 0 0 0; ...
      0 2 0 0; ...
      0 0 1 0];
  
du = [0 3 0 0; ...
      0 0 2 0; ...
      0 0 0 1; ...
      0 0 0 0];
  
%% Forward Difference Matrices
%
ustep = .1;
vstep = .1;
Mufd = [0, ustep^3, 6*ustep^3, 6*ustep^3; ...
        0, ustep^2, 2*ustep^2,         0; ...
        0, ustep  ,         0,         0;
        1,       0,         0,         0];
Mvfd = [      0,         0,     0, 1; ...
        vstep^3,   vstep^2, vstep, 0; ...
      6*vstep^3, 2*vstep^2,     0, 0; ...
      6*vstep^3,         0,     0, 0];
