0% found this document useful (0 votes)
28 views8 pages

MATLAB Bezier & Hermite Curves

Uploaded by

anas.bepari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views8 pages

MATLAB Bezier & Hermite Curves

Uploaded by

anas.bepari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

BEZIER CURVE
MATLAB CODE :-

% Cubic Bezier curve

clc

clear

syms u

% Parameter matrix

U=[u^3,u^2,u,1]

% Bezier matrix

H=[-1,3,-3,1;3,-6,3,0;-3,3,0,0;1,0,0,0]

% Geometry matrix will vary for problem

G=[0,0;2,1;5,2;6,1]

B=U*H

u=linspace(0,1);

% Blending functions

b1=subs(B(1));

b2=subs(B(2));

b3=subs(B(3));

b4=subs(B(4));

% plot Blending functions

figure(1)

plot(u,b1)

hold on

plot(u,b2)

plot(u,b3)

plot(u,b4)

grid on
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

hold off

%Property of basis function

a=b1+b2+b3+b4;

figure(2)

plot(u,a)

P=U*(H*G)

X=P(1)

Y=P(2)

% X coordinates of Bezier curve

Px=subs(X);

% Y coordiantes of Bezier curve

Py=subs(Y);

figure(3)

% Plotting of Bezier curve

scatter(G(:,1),G(:,2),'filled')

hold on

plot(Px,Py)

grid on

axis tight

RESULTS:-

U=

[u^3, u^2, u, 1]

H=
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

-1 3 -3 1

3 -6 3 0

-3 3 0 0

1 0 0 0

G=

0 0

2 1

5 2

6 1

B=

[- u^3 + 3*u^2 - 3*u + 1, 3*u^3 - 6*u^2 + 3*u, - 3*u^3 + 3*u^2, u^3]

P=

[- 3*u^3 + 3*u^2 + 6*u, - 2*u^3 + 3*u]

X=

- 3*u^3 + 3*u^2 + 6*u


ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

Y=

- 2*u^3 + 3*u

GRAPHS:-
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

HERMITE CURVE

MATLAB CODE :-

% Hermite curve with blending functions

clc

clear

syms u

% Parameter matrix

U=[u^3,u^2,u,1]

% hermite matrix

H=[2,-2,1,1;-3,3,-2,-1;0,0,1,0;1,0,0,0]

% Geometry matrix will vary for problem

G=[1,1;7,4;7,6;-1,-3]

B=U*H

u=linspace(0,1);

% Blending functions

b1=subs(B(1));

b2=subs(B(2));

b3=subs(B(3));

b4=subs(B(4));

% plot Blending functions

figure(1)

plot(u,b1)

hold on

plot(u,b2)

plot(u,b3)
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

plot(u,b4)

grid on

hold off

P=U*(H*G)

X=P(1)

Y=P(2)

% X coordinates of Hermite curve

Px=subs(X);

% Y coordiantes of Hermite curve

Py=subs(Y);

figure(2)

% Plotting of hermite curve

plot(Px,Py)

grid on

axis tight

RESULTS:-

U=

[u^3, u^2, u, 1]

H=

2 -2 1 1

-3 3 -2 -1

0 0 1 0
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

1 0 0 0

G=

1 1

7 4

7 6

-1 -3

B=

[2*u^3 - 3*u^2 + 1, - 2*u^3 + 3*u^2, u^3 - 2*u^2 + u, u^3 - u^2]

P=

[- 6*u^3 + 5*u^2 + 7*u + 1, - 3*u^3 + 6*u + 1]

X=

- 6*u^3 + 5*u^2 + 7*u + 1

Y=

- 3*u^3 + 6*u + 1
ANAS BEPARI

FYMTECHCCR

ROLL NO- 16031224001

>>

GRAPHS:-

You might also like