Prev: scrollbar/slider for the axes
Next: TechTradeTool help
From: Danna on 30 Jul 2010 19:22 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
From: Roger Stafford on 31 Jul 2010 20:40 "Danna " <silver_girl(a)hotmail.com> wrote in message <i2vmqu$i78$1(a)fred.mathworks.com>... > 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)) > ......... - - - - - - - - - - - - It is the whole purpose of Bezier parametric curves to create "smooth" curves. If you are troubled by the discontinuity of the curve's slope at (3,2) as it passes from the quadratic section (P1) to the cubic section (P), then you need to select the two points (4,-2) and/or (5,6) or else the point (3,2) differently. The slope between the second and third points of the quadratic section should equal that between the first and second points of the cubic section to avoid such a discontinuity. That is, P1(2,:), P1(3,:)=P((1,:), P(2,:) should all three lie along a single straight line and in that order. I think you need to read up a little more on the theory of Bezier curves. For example take a look at the Wikipedia article at: http://en.wikipedia.org/wiki/Bézier_curve Roger Stafford
|
Pages: 1 Prev: scrollbar/slider for the axes Next: TechTradeTool help |