Bline: All All 'Give Coordinate in Form of (x0 Y0 x1 Y1) : '

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Bline

clear all
close all
clc
point = input('Give coordinate in form of [x0 y0 x1 y1]: ');
X1=point(1);
Y1=point(2);
Xn=point(3);
Yn=point(4);
Dx = Xn-X1;
Dy = Yn-Y1;
P = 2*Dy-Dx;
C1 = 2*Dy;
C2 = 2*(Dy-Dx);
X=X1;
Y=Y1;
figure();
plot (X,Y);
while(X1 < Xn)
if(P < 0)
P = P + C1;
else
P = P + C2;
Y1 = Y1 + 1;
end
X1 =X1 +1;
figure();
plot(X,Y);
end
Dda

clear all
close all
clc
point = input('Give coordinate in form of [x0 y0 x1 y1]: ');
X1=point(1);
Y1=point(2);
Xn=point(3);
Yn=point(4);
M = (Yn-Y1)/(Xn- X1);
for i= X1:Xn
if (M <= 1)
Dx = 1;
Dy = M * Dx;
else
Dy = 1;
Dx = Dy / M ;
end
X1 = X1 + Dx;
Y1 = Y1 + Dy;
plot(X1, Y1);
end
Bcircle

clear all
close all
clc
Xc=input('Enter center point of X Coordinate:');
Yc=input('Enter center point of y Coordinate:');
R=input('Enter Radius of circle:');
X=0;
Y=R;
D=3-2*R;
plot (Xc, Yc, X, Y);
while(X < Y)
if(D<0)
D = D + 4*X + 6;
else
Y = Y - 1;
D = D + 4*(X-Y) + 10;
end
plot (Xc, Yc, X, Y);
X = X + 1;
end

You might also like