1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| close all, clear all,clc
n=100;
%%%% Cardinal Spline 3D Interpolation %%%%%%%%%%
Px=[35 35 16 15 25 40 65 50 60 80 80];
Py=[47 47 40 15 36 15 25 40 42 27 27];
Pz=[-17 -17 20 15 36 15 25 20 25 -7 -7];
% Note first and last points are repeated so that spline curve passes
% through all points
figure
hold on
plot3(Px,Py,Pz,'ro','linewidth',2)
Tension=0;
for k=1:length(Px)-3
[MatOut3]=crdatnplusoneval([Px(k),Py(k),Pz(k)],[Px(k+1),Py(k+1),Pz(k+1)],[Px(k+2),Py(k+2),Pz(k+2)],[Px(k+3),Py(k+3),Pz(k+3)],Tension,n);
% Between each pair of control points plotting n+1 values of first three rows of MatOut
plot3(MatOut3(1,:),MatOut3(2,:),MatOut3(3,:),'b','linewidth',2)
end
title('\bf3D Cardinal Spline')
view(3);
box;
%%%% Cardinal Spline 3D Interpolation |
Partager