You are on page 1of 2

assignment 1

n=1e6;
u=0:1/n:1;
%a=input('angle of inclination \n');
fprintf('\n Enter the value for the center of the circle xc yc :');
xc=input('Enter the value of xc: ');
yc=input('Enter the value of yc: ');
r=input('Enter the value of radius: ');
k = input('Location of tangent [0-1]: ');
%co=cosd(a);
%si=sind(a);
%parametric equation
for i=1:n+1
x(i)=xc+r*cos(2*pi*u(i))-r*sin(2*pi*u(i));
y(i)=yc+r*cos(2*pi*u(i))+r*sin(2*pi*u(i));
end
%plotting circle
plot(x,y,'r');
grid on
hold on
Ck = cos(2*pi*k);
Sk = sin(2*pi*k);
xt = xc + r*Ck - r*Sk;
yt = yc + r*Ck + r*Sk;
quiver(xt, yt, -r*Sk - r*Ck,-r*Sk + r*Ck,'r') %plot tangent
axis equal
grid on
hold off

assignment 2 (2question)

clc
clear
close all
fprintf('\n enter the first point of the curve \n');
x0=input('\nx0 value \n :');
y0=input('y0 value \n :');
fprintf('\n enter the second point of the curve');
x1=input('\n x1 value \n :');
y1=input('\n y1 value \n :');
fprintf('\n enter first Tangent vectors');
x0dash=input('\n x0_dash value \n :');
y0dash=input('\n y0_dash value \n :');
fprintf('\n enter the second tangent vectors');
x1dash=input('\n x1_dash value \n :');
y1dash=input('\n y1_dash value \n :');
po=[x0 y0];
p1=[x1 y1];
p0dash=[x0dash y0dash];
p1dash=[x1dash y1dash];
N = [ 2 -2 1 1;...
-3 3 -2 -1;...
0 0 1 0;...
1 0 0 0];
plot(x0,y0);
plot(x1,y1);
hold on
grid on
t=linspace(-1,1,50);
for j=1:50
T = [t(j)^3 t(j)^2 t(j) 1];
G = [po;p1;p0dash;p1dash];
PS(j,:) = T*N*G;
plot(PS(j,1),PS(j,2),'b*','LineWidth',2) % Plot various points on Cubic spline
hold on
grid on
end

You might also like