You are on page 1of 2

Mathematical Elements for Geometrical Modelling

Assignment no 2
Name: - Gaikwad Shantanu Rajendra

Problem Description:Draw Bezier curve for D no of point.


MATLAB CODE:%ME14MTECH11024
clear all;
D=input('enter no. of points');
N=input('enter x-co-ordinate of points'); % Enter value in form [N1 N2 N3
N4...........]
M=input('enter y-co-ordinate of points'); % Enter value in form [M1 M2 M3
M4...........]
for k=0:0.001:1
sum=0; sum1=0;
for i=0:1:D-1
G= ((factorial(D-1)/((factorial(i)*factorial((D-1-i))))));
x=(G*(1-k)^((D-1)-i)*k^i*N(i+1));
y=(G*(1-k)^((D-1)-i)*k^i*M(i+1));
sum=sum+x;
sum1=sum1+y;
end
plot(sum,sum1);
hold on;
end
Xl=sum;
Yl=sum1;
Xl
%Show only last value of x-co-ordinate input to verify only
Yl
%Show only last value of y-co-ordinate input to verify only
xlabel('X Axis')
ylabel('Y Axis')
legend( 'Bezier Curve','location', 'northwest')

OUTPUT:-

enter no. of points5


enter x-co-ordinate of points[ 1 2 3 45 100]
enter y-co-ordinate of points[34 56 78 90 234]

Xl =

100

Yl =

234

You might also like