|
I have this code, the P1(3,1)(3,2) points are the same as P(1,1)(1,2), and i need to subtitude them to smooth the result
P1=[-5,3;4,-2;3,2];
P=[3,2;5,6;2,4;3,4];
t=0:0.01:1;
X(:,1)=(1-t).^2*P1(1,1)+2*(1-t).*t*P1(2,1)+t.^2*P1(3,1);
X(:,2)=(1-t).^2*P1(1,2)+2*(1-t).*t*P1(2,2)+t.^2*P1(3,2);
plot(X(:,1),X(:,2))
hold on
X1(:,1)=(1-t).^3*P(1,1)+3*(1-t).^2.*t*P(2,1)+3*(1-t).*t.^2*P(3,1)+t.^3*P(4,1);
X1(:,2)=(1-t).^3*P(1,2)+3*(1-t).^2.*t*P(2,2)+3*(1-t).*t.^2*P(3,2)+t.^3*P(4,2);
plot(X1(:,1),X1(:,2))
I tried this, but it didn´t work out:
P1=[-5,3;4,-2;3,2];
P=[3,2;5,6;2,4;3,4];
t=0:0.01:1;
P1(3,1)=(1-t)*P(3,1)+P1(1,1);
P1(3,2)=(1-t)*P(3,2)+P1(1,2);
P(1,1)=(1-t)*P(3,1)+P1(1,1);
P(1,2)=(1-t)*P(3,1)+P1(1,1);
X(:,1)=(1-t).^2*P1(1,1)+2*(1-t).*t*P1(2,1)+t.^2*P1(3,1);
X(:,2)=(1-t).^2*P1(1,2)+2*(1-t).*t*P1(2,2)+t.^2*P1(3,2);
plot(X(:,1),X(:,2))
hold on
X1(:,1)=(1-t).^3*P(1,1)+3*(1-t).^2.*t*P(2,1)+3*(1-t).*t.^2*P(3,1)+t.^3*P(4,1);
X1(:,2)=(1-t).^3*P(1,2)+3*(1-t).^2.*t*P(2,2)+3*(1-t).*t.^2*P(3,2)+t.^3*P(4,2);
plot(X1(:,1),X1(:,2))
what can i do???
thanks
|