% Douglas N. Arnold, dna@math.psu.edu, 11/96
% requires the Matlab spline toolbox

% This Matlab file demonstrates parametric splines by drawing Bill
% Clinton's signature.  Data was entered by clicking mouse over an image
% of the actual signature.

bline=[
   19.8647  -54.4921
   22.1579  -49.6510
   24.7059  -39.2042
   25.7251  -27.7382
   26.2347  -23.6614
   26.4895  -21.1134
   27.2539  -20.0942
   28.7827  -19.3298
];

bill=[
   15.5332  -27.7382
   14.0044  -26.2094
   11.9660  -22.1326
   15.7880  -18.0558
   27.5087  -14.2339
   42.0323  -12.4503
   50.4407  -15.2531
   41.0131  -20.8586
   44.3255  -23.6614
   49.1667  -24.6806
   63.6902  -37.1658
   60.1230  -47.3578
   59.6134  -42.5166
   70.5698  -28.7574
   72.6082  -31.5602
   73.8822  -38.9494
   76.4302  -44.5550
   83.3098  -44.5550
   89.6798  -37.6754
   90.4442  -30.7958
   91.7182  -40.4782
   96.5593  -46.0838
  104.9677  -42.7714
  108.2801  -37.9302
  109.2993  -30.7958
  109.2993  -39.9686
  112.8665  -47.1030
];

idot1 = [
   69.8054  -17.8010
   71.3342  -17.8010
   71.8438  -19.5846
];

clinton = [
  152.1056  -20.3490
  153.8892  -24.4258
  155.6728  -28.5026
  156.9468  -25.1902
  155.9276  -21.6230
  149.8124  -17.2914
  140.8944  -29.2670
  140.6396  -44.0454
  145.4808  -48.3770
  168.4127  -23.1518
  167.6483  -22.1326
  163.5716  -31.3054
  165.1003  -40.2234
  170.9607  -42.2618
  178.3499  -38.9494
  179.1143  -31.3054
  179.3691  -39.7138
  183.1911  -42.2618
  187.0131  -42.2618
  192.1091  -36.4014
  191.0899  -32.8342
  196.9503  -42.7714
  201.0271  -42.5166
  202.5558  -34.8726
  208.4162  -40.2234
  215.2958  -40.2234
  230.3290  -26.9738
  222.1754  -36.4014
  222.1754  -43.5358
  226.5070  -44.0454
  226.7618  -34.6178
  219.1178  -31.0506
  216.5698  -32.8342
  220.6466  -35.1274
  239.2469  -33.8534
  244.0881  -33.3438
  237.4634  -36.4014
  236.9538  -42.2618
  242.3045  -43.7906
  249.1841  -41.2426
  250.7129  -35.3822
  244.3429  -33.3438
  249.4389  -35.1274
  250.2033  -39.4590
  252.7513  -39.4590
  262.4337  -33.8534
  260.9049  -32.3246
  259.6309  -42.0070
  268.2941  -42.2618
  275.6832  -36.6562
  282.8176  -40.9878
];

idot2 = [
  200.0079  -13.4695
  201.0271  -11.9407
  201.5366  -14.2339
];
npoints=500;

[breaks,coefs,l,k,d0]=ppbrk(cscvn(bline'));
dt=breaks(1)+[0:npoints]*((breaks(l+1)-breaks(1))/npoints);
s1=ppual(cscvn(bline'),dt);

[breaks,coefs,l,k,d0]=ppbrk(cscvn(bill'));
dt=breaks(1)+[0:npoints]*((breaks(l+1)-breaks(1))/npoints);
s2=ppual(cscvn(bill'),dt);

[breaks,coefs,l,k,d0]=ppbrk(cscvn(idot1'));
dt=breaks(1)+[0:npoints]*((breaks(l+1)-breaks(1))/npoints);
s3=ppual(cscvn(idot1'),dt);

[breaks,coefs,l,k,d0]=ppbrk(cscvn(clinton'));
dt=breaks(1)+[0:npoints]*((breaks(l+1)-breaks(1))/npoints);
s4=ppual(cscvn(clinton'),dt);

[breaks,coefs,l,k,d0]=ppbrk(cscvn(idot2'));
dt=breaks(1)+[0:npoints]*((breaks(l+1)-breaks(1))/npoints);
s5=ppual(cscvn(idot2'),dt);


sigfig = figure;
set(sigfig,'color','white','position',[100 500 800 200],'defaultlinelinewidth',5);
set(get(sigfig,'currentaxes'),'box','off','aspectratio',[NaN 1],'position',[.1 .1 .8 .9]);
sig=plot(s1(1,:),s1(2,:),...
   s2(1,:),s2(2,:),...
   s3(1,:),s3(2,:),...
   s4(1,:),s4(2,:),...
   s5(1,:),s5(2,:));
set(sig,'color',[0 0 .75])
axis equal
