0% found this document useful (0 votes)
17 views3 pages

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

The document contains code to draw lines, circles, and bresenham's line algorithm in MATLAB. It takes user input for coordinates and radius and plots the corresponding shapes step-by-step. For lines, it calculates the slope and increments coordinates in each step. For circles, it implements the bresenham circle algorithm using decision parameter D.

Uploaded by

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

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

The document contains code to draw lines, circles, and bresenham's line algorithm in MATLAB. It takes user input for coordinates and radius and plots the corresponding shapes step-by-step. For lines, it calculates the slope and increments coordinates in each step. For circles, it implements the bresenham circle algorithm using decision parameter D.

Uploaded by

Akshy Kolekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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