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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| %Angular function
function AngFuncDescrp(curve)
%Function
X=curve(1,:);Y=curve(2,:);
M=size(X,2);%number points
%Arc length
S=zeros(1,m);
S(1)=sqrt((X(1)-X(m))^2+(Y(1)-Y(m))^2);
for i=2:m
S(i)=S(i-1)+sqrt((X(i)-X(i-1))^2+(Y(i)-Y(i-1))^2);
end
L=S(m);
%Normalised Parameter
t=(2*pi*S)/L;
%Graph of the curve
subplot(3,3,1);
plot(X,Y);
mx=max(max(X),max(Y))+10;
axis([0,mx,0,mx]); axis square; %Aspect ratio
%Graph of the angular function y/x
avrg=10;
A=zeros(1,m);
for i=1:m
x1=0; x2=0; y1=0; y2=0;
for j=1:avrg
pa=i-j; pb=i+j;
if(pa<1) pa=m+pa;
end
if(pb>m) pb=pb-m;
end
x1=x1+X(pa); y1=y1+Y(pa);
x2=x2+X(pb); y2=y2+Y(pb);
end
x1=x1/avrg; y1=y1/avrg;
x2=x2/avrg; y2=y2/avrg;
dx=x2-x1; dy=y2-y1;
if(dx==0) dx=.00001;
end
if dx>0 & dy>0
A(i)=atan(dy/dx);
elseif dx>0 & dy<0
A(i)=atan(dy/dx)+2*pi;
else
A(i)=atan(dy/dx)+pi;
end
end
subplot(3,3,2);
plot(S,A);
axis([0,S(m),-1,2*pi+1]);
%Cumulative angular G(s)=-2pi
G=zeros(1,m);
for i=2:m
d=min(abs(A(i)-A(i-1)),abs(abs(A(i)-A(i-1))-2*pi));
if d>.5
G(i)=G(i-1);
elseif (A(i)-A(i-1))<-pi
G(i)=G(i-1)-(A(i)-A(i-1)+2*pi);
elseif (A(i)-A(i-1))>pi
G(i)=G(i-1)-(A(i)-A(i-1)-2*pi);
else
G(i)=G(i-1)-(A(i)-A(i-1));
end
end
subplot(3,3,3);
plot(S,G);
axis([0,S(m),-2*pi-1,1]);
%Cumulative angular Normalised
F=G+t;
subplot(3,3,4);
plot(t,F);
axis([0,2*pi,-2*pi,2*pi]); |
Partager