This document contains a MATLAB code to draw a Bezier curve for a given number of points. The code takes the x and y coordinates of points as input, calculates the Bezier curve equation for different values of t from 0 to 1, and plots the curve. It displays the last x and y values to verify the input coordinates.
This document contains a MATLAB code to draw a Bezier curve for a given number of points. The code takes the x and y coordinates of points as input, calculates the Bezier curve equation for different values of t from 0 to 1, and plots the curve. It displays the last x and y values to verify the input coordinates.
This document contains a MATLAB code to draw a Bezier curve for a given number of points. The code takes the x and y coordinates of points as input, calculates the Bezier curve equation for different values of t from 0 to 1, and plots the curve. It displays the last x and y values to verify the input coordinates.
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]