Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- P = [1 0;1 1;0 1];
- w = [1 1 1];
- w2 = [1 1 0.5];
- t=[0:0.01:1];
- %hyperbole
- x=(1-(t.^2));
- y=t;
- %plot(x,y,'Color',"blue");
- hold on
- for i = 1:1:length(P)
- plot(P(i,1),P(i,2),'O');
- end
- hold off
- bases_rationelles(P,w,100,'O');
- %bases_rationelles(P,w2,100,'.');
- function nb = Binomial(n,k)
- nb = factorial(n)/(factorial(k)*factorial(n-k));
- end
- %exists function "bernstein" which does almost the same thing
- function polynome = Bernstein(i,n,t)
- for j = 1:1:length(t)
- polynome(1,j) = (Binomial(n,i))*((t(1,j))^i)*((1-(t(1,j)))^(n-i));
- end
- end
- function polynome = Rational(i,n,w,t)
- tmp = zeros(1,length(t));
- for j = 1:1:n
- tmp = tmp + w(j) * Bernstein(j-1,n-1,t);
- end
- polynome = (w(i)*Bernstein(i-1,n-1,t))./tmp;
- end
- function courbe = bases_rationelles(P,w,nb,forme)
- t = linspace(0,1,nb);
- n = length(P);
- courbeX = zeros(1,length(t));
- courbeY = zeros(1,length(t));
- for i = 1:1:n
- courbeX = courbeX + (P(i,1) * Rational(i,n,w,t));
- courbeY = courbeY + (P(i,2) * Rational(i,n,w,t));
- end
- courbe = [courbeX;courbeY];
- hold on
- for i = 1:1:length(courbe)
- plot(courbe(1,i),courbe(2,i),forme);
- end
- hold off
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement